diff --git a/resource-manager/cdn/2024-09-01/secrets/model_urlsigningkeyparameters.go b/resource-manager/cdn/2024-09-01/secrets/model_urlsigningkeyparameters.go index 5030e7658ac..4fc241a63a6 100644 --- a/resource-manager/cdn/2024-09-01/secrets/model_urlsigningkeyparameters.go +++ b/resource-manager/cdn/2024-09-01/secrets/model_urlsigningkeyparameters.go @@ -13,7 +13,7 @@ var _ SecretParameters = URLSigningKeyParameters{} type URLSigningKeyParameters struct { KeyId string `json:"keyId"` SecretSource ResourceReference `json:"secretSource"` - SecretVersion *string `json:"secretVersion,omitempty"` + SecretVersion string `json:"secretVersion"` // Fields inherited from SecretParameters diff --git a/resource-manager/cosmosdb/2024-11-15/client.go b/resource-manager/cosmosdb/2024-11-15/client.go new file mode 100644 index 00000000000..973541455fd --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/client.go @@ -0,0 +1,136 @@ +package v2024_11_15 + +// 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/cosmosdb/2024-11-15/cosmosdb" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/datatransfer" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/graphapicompute" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/managedcassandras" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/mongorbacs" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/privateendpointconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/privatelinkresources" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/rbacs" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/restorables" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/services" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + CosmosDB *cosmosdb.CosmosDBClient + DataTransfer *datatransfer.DataTransferClient + GraphAPICompute *graphapicompute.GraphAPIComputeClient + ManagedCassandras *managedcassandras.ManagedCassandrasClient + MaterializedViewsBuilder *materializedviewsbuilder.MaterializedViewsBuilderClient + Mongorbacs *mongorbacs.MongorbacsClient + NotebookWorkspacesResource *notebookworkspacesresource.NotebookWorkspacesResourceClient + PrivateEndpointConnections *privateendpointconnections.PrivateEndpointConnectionsClient + PrivateLinkResources *privatelinkresources.PrivateLinkResourcesClient + Rbacs *rbacs.RbacsClient + Restorables *restorables.RestorablesClient + Services *services.ServicesClient + SqlDedicatedGateway *sqldedicatedgateway.SqlDedicatedGatewayClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + cosmosDBClient, err := cosmosdb.NewCosmosDBClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CosmosDB client: %+v", err) + } + configureFunc(cosmosDBClient.Client) + + dataTransferClient, err := datatransfer.NewDataTransferClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DataTransfer client: %+v", err) + } + configureFunc(dataTransferClient.Client) + + graphAPIComputeClient, err := graphapicompute.NewGraphAPIComputeClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building GraphAPICompute client: %+v", err) + } + configureFunc(graphAPIComputeClient.Client) + + managedCassandrasClient, err := managedcassandras.NewManagedCassandrasClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ManagedCassandras client: %+v", err) + } + configureFunc(managedCassandrasClient.Client) + + materializedViewsBuilderClient, err := materializedviewsbuilder.NewMaterializedViewsBuilderClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building MaterializedViewsBuilder client: %+v", err) + } + configureFunc(materializedViewsBuilderClient.Client) + + mongorbacsClient, err := mongorbacs.NewMongorbacsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Mongorbacs client: %+v", err) + } + configureFunc(mongorbacsClient.Client) + + notebookWorkspacesResourceClient, err := notebookworkspacesresource.NewNotebookWorkspacesResourceClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NotebookWorkspacesResource client: %+v", err) + } + configureFunc(notebookWorkspacesResourceClient.Client) + + privateEndpointConnectionsClient, err := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PrivateEndpointConnections client: %+v", err) + } + configureFunc(privateEndpointConnectionsClient.Client) + + privateLinkResourcesClient, err := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PrivateLinkResources client: %+v", err) + } + configureFunc(privateLinkResourcesClient.Client) + + rbacsClient, err := rbacs.NewRbacsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Rbacs client: %+v", err) + } + configureFunc(rbacsClient.Client) + + restorablesClient, err := restorables.NewRestorablesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Restorables client: %+v", err) + } + configureFunc(restorablesClient.Client) + + servicesClient, err := services.NewServicesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Services client: %+v", err) + } + configureFunc(servicesClient.Client) + + sqlDedicatedGatewayClient, err := sqldedicatedgateway.NewSqlDedicatedGatewayClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SqlDedicatedGateway client: %+v", err) + } + configureFunc(sqlDedicatedGatewayClient.Client) + + return &Client{ + CosmosDB: cosmosDBClient, + DataTransfer: dataTransferClient, + GraphAPICompute: graphAPIComputeClient, + ManagedCassandras: managedCassandrasClient, + MaterializedViewsBuilder: materializedViewsBuilderClient, + Mongorbacs: mongorbacsClient, + NotebookWorkspacesResource: notebookWorkspacesResourceClient, + PrivateEndpointConnections: privateEndpointConnectionsClient, + PrivateLinkResources: privateLinkResourcesClient, + Rbacs: rbacsClient, + Restorables: restorablesClient, + Services: servicesClient, + SqlDedicatedGateway: sqlDedicatedGatewayClient, + }, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/README.md b/resource-manager/cosmosdb/2024-11-15/cosmosdb/README.md new file mode 100644 index 00000000000..3b743b05aa8 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/README.md @@ -0,0 +1,1893 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/cosmosdb` Documentation + +The `cosmosdb` SDK allows for interaction with Azure Resource Manager `cosmosdb` (API Version `2024-11-15`). + +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/cosmosdb/2024-11-15/cosmosdb" +``` + + +### Client Initialization + +```go +client := cosmosdb.NewCosmosDBClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CosmosDBClient.CassandraResourcesCreateUpdateCassandraKeyspace` + +```go +ctx := context.TODO() +id := cosmosdb.NewCassandraKeyspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "cassandraKeyspaceName") + +payload := cosmosdb.CassandraKeyspaceCreateUpdateParameters{ + // ... +} + + +if err := client.CassandraResourcesCreateUpdateCassandraKeyspaceThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.CassandraResourcesCreateUpdateCassandraTable` + +```go +ctx := context.TODO() +id := cosmosdb.NewCassandraKeyspaceTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "cassandraKeyspaceName", "tableName") + +payload := cosmosdb.CassandraTableCreateUpdateParameters{ + // ... +} + + +if err := client.CassandraResourcesCreateUpdateCassandraTableThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.CassandraResourcesDeleteCassandraKeyspace` + +```go +ctx := context.TODO() +id := cosmosdb.NewCassandraKeyspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "cassandraKeyspaceName") + +if err := client.CassandraResourcesDeleteCassandraKeyspaceThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.CassandraResourcesDeleteCassandraTable` + +```go +ctx := context.TODO() +id := cosmosdb.NewCassandraKeyspaceTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "cassandraKeyspaceName", "tableName") + +if err := client.CassandraResourcesDeleteCassandraTableThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.CassandraResourcesGetCassandraKeyspace` + +```go +ctx := context.TODO() +id := cosmosdb.NewCassandraKeyspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "cassandraKeyspaceName") + +read, err := client.CassandraResourcesGetCassandraKeyspace(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.CassandraResourcesGetCassandraKeyspaceThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewCassandraKeyspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "cassandraKeyspaceName") + +read, err := client.CassandraResourcesGetCassandraKeyspaceThroughput(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.CassandraResourcesGetCassandraTable` + +```go +ctx := context.TODO() +id := cosmosdb.NewCassandraKeyspaceTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "cassandraKeyspaceName", "tableName") + +read, err := client.CassandraResourcesGetCassandraTable(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.CassandraResourcesGetCassandraTableThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewCassandraKeyspaceTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "cassandraKeyspaceName", "tableName") + +read, err := client.CassandraResourcesGetCassandraTableThroughput(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.CassandraResourcesListCassandraKeyspaces` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.CassandraResourcesListCassandraKeyspaces(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.CassandraResourcesListCassandraTables` + +```go +ctx := context.TODO() +id := cosmosdb.NewCassandraKeyspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "cassandraKeyspaceName") + +read, err := client.CassandraResourcesListCassandraTables(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.CassandraResourcesMigrateCassandraKeyspaceToAutoscale` + +```go +ctx := context.TODO() +id := cosmosdb.NewCassandraKeyspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "cassandraKeyspaceName") + +if err := client.CassandraResourcesMigrateCassandraKeyspaceToAutoscaleThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.CassandraResourcesMigrateCassandraKeyspaceToManualThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewCassandraKeyspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "cassandraKeyspaceName") + +if err := client.CassandraResourcesMigrateCassandraKeyspaceToManualThroughputThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.CassandraResourcesMigrateCassandraTableToAutoscale` + +```go +ctx := context.TODO() +id := cosmosdb.NewCassandraKeyspaceTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "cassandraKeyspaceName", "tableName") + +if err := client.CassandraResourcesMigrateCassandraTableToAutoscaleThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.CassandraResourcesMigrateCassandraTableToManualThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewCassandraKeyspaceTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "cassandraKeyspaceName", "tableName") + +if err := client.CassandraResourcesMigrateCassandraTableToManualThroughputThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.CassandraResourcesUpdateCassandraKeyspaceThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewCassandraKeyspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "cassandraKeyspaceName") + +payload := cosmosdb.ThroughputSettingsUpdateParameters{ + // ... +} + + +if err := client.CassandraResourcesUpdateCassandraKeyspaceThroughputThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.CassandraResourcesUpdateCassandraTableThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewCassandraKeyspaceTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "cassandraKeyspaceName", "tableName") + +payload := cosmosdb.ThroughputSettingsUpdateParameters{ + // ... +} + + +if err := client.CassandraResourcesUpdateCassandraTableThroughputThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.CollectionListMetricDefinitions` + +```go +ctx := context.TODO() +id := cosmosdb.NewCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "databaseName", "collectionName") + +read, err := client.CollectionListMetricDefinitions(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.CollectionListMetrics` + +```go +ctx := context.TODO() +id := cosmosdb.NewCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "databaseName", "collectionName") + +read, err := client.CollectionListMetrics(ctx, id, cosmosdb.DefaultCollectionListMetricsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.CollectionListUsages` + +```go +ctx := context.TODO() +id := cosmosdb.NewCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "databaseName", "collectionName") + +read, err := client.CollectionListUsages(ctx, id, cosmosdb.DefaultCollectionListUsagesOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.CollectionPartitionListMetrics` + +```go +ctx := context.TODO() +id := cosmosdb.NewCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "databaseName", "collectionName") + +read, err := client.CollectionPartitionListMetrics(ctx, id, cosmosdb.DefaultCollectionPartitionListMetricsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.CollectionPartitionListUsages` + +```go +ctx := context.TODO() +id := cosmosdb.NewCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "databaseName", "collectionName") + +read, err := client.CollectionPartitionListUsages(ctx, id, cosmosdb.DefaultCollectionPartitionListUsagesOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.CollectionPartitionRegionListMetrics` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "regionName", "databaseName", "collectionName") + +read, err := client.CollectionPartitionRegionListMetrics(ctx, id, cosmosdb.DefaultCollectionPartitionRegionListMetricsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.CollectionRegionListMetrics` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "regionName", "databaseName", "collectionName") + +read, err := client.CollectionRegionListMetrics(ctx, id, cosmosdb.DefaultCollectionRegionListMetricsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.DatabaseAccountRegionListMetrics` + +```go +ctx := context.TODO() +id := cosmosdb.NewRegionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "regionName") + +read, err := client.DatabaseAccountRegionListMetrics(ctx, id, cosmosdb.DefaultDatabaseAccountRegionListMetricsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.DatabaseAccountsCheckNameExists` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseAccountNameID("accountName") + +read, err := client.DatabaseAccountsCheckNameExists(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.DatabaseAccountsCreateOrUpdate` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +payload := cosmosdb.DatabaseAccountCreateUpdateParameters{ + // ... +} + + +if err := client.DatabaseAccountsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.DatabaseAccountsDelete` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +if err := client.DatabaseAccountsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.DatabaseAccountsFailoverPriorityChange` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +payload := cosmosdb.FailoverPolicies{ + // ... +} + + +if err := client.DatabaseAccountsFailoverPriorityChangeThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.DatabaseAccountsGet` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.DatabaseAccountsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.DatabaseAccountsGetReadOnlyKeys` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.DatabaseAccountsGetReadOnlyKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.DatabaseAccountsList` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.DatabaseAccountsList(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.DatabaseAccountsListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +read, err := client.DatabaseAccountsListByResourceGroup(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.DatabaseAccountsListConnectionStrings` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.DatabaseAccountsListConnectionStrings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.DatabaseAccountsListKeys` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.DatabaseAccountsListKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.DatabaseAccountsListMetricDefinitions` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.DatabaseAccountsListMetricDefinitions(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.DatabaseAccountsListMetrics` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.DatabaseAccountsListMetrics(ctx, id, cosmosdb.DefaultDatabaseAccountsListMetricsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.DatabaseAccountsListReadOnlyKeys` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.DatabaseAccountsListReadOnlyKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.DatabaseAccountsListUsages` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.DatabaseAccountsListUsages(ctx, id, cosmosdb.DefaultDatabaseAccountsListUsagesOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.DatabaseAccountsOfflineRegion` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +payload := cosmosdb.RegionForOnlineOffline{ + // ... +} + + +if err := client.DatabaseAccountsOfflineRegionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.DatabaseAccountsOnlineRegion` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +payload := cosmosdb.RegionForOnlineOffline{ + // ... +} + + +if err := client.DatabaseAccountsOnlineRegionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.DatabaseAccountsRegenerateKey` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +payload := cosmosdb.DatabaseAccountRegenerateKeyParameters{ + // ... +} + + +if err := client.DatabaseAccountsRegenerateKeyThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.DatabaseAccountsUpdate` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +payload := cosmosdb.DatabaseAccountUpdateParameters{ + // ... +} + + +if err := client.DatabaseAccountsUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.DatabaseListMetricDefinitions` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "databaseName") + +read, err := client.DatabaseListMetricDefinitions(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.DatabaseListMetrics` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "databaseName") + +read, err := client.DatabaseListMetrics(ctx, id, cosmosdb.DefaultDatabaseListMetricsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.DatabaseListUsages` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "databaseName") + +read, err := client.DatabaseListUsages(ctx, id, cosmosdb.DefaultDatabaseListUsagesOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.GremlinResourcesCreateUpdateGremlinDatabase` + +```go +ctx := context.TODO() +id := cosmosdb.NewGremlinDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "gremlinDatabaseName") + +payload := cosmosdb.GremlinDatabaseCreateUpdateParameters{ + // ... +} + + +if err := client.GremlinResourcesCreateUpdateGremlinDatabaseThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.GremlinResourcesCreateUpdateGremlinGraph` + +```go +ctx := context.TODO() +id := cosmosdb.NewGraphID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "gremlinDatabaseName", "graphName") + +payload := cosmosdb.GremlinGraphCreateUpdateParameters{ + // ... +} + + +if err := client.GremlinResourcesCreateUpdateGremlinGraphThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.GremlinResourcesDeleteGremlinDatabase` + +```go +ctx := context.TODO() +id := cosmosdb.NewGremlinDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "gremlinDatabaseName") + +if err := client.GremlinResourcesDeleteGremlinDatabaseThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.GremlinResourcesDeleteGremlinGraph` + +```go +ctx := context.TODO() +id := cosmosdb.NewGraphID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "gremlinDatabaseName", "graphName") + +if err := client.GremlinResourcesDeleteGremlinGraphThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.GremlinResourcesGetGremlinDatabase` + +```go +ctx := context.TODO() +id := cosmosdb.NewGremlinDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "gremlinDatabaseName") + +read, err := client.GremlinResourcesGetGremlinDatabase(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.GremlinResourcesGetGremlinDatabaseThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewGremlinDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "gremlinDatabaseName") + +read, err := client.GremlinResourcesGetGremlinDatabaseThroughput(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.GremlinResourcesGetGremlinGraph` + +```go +ctx := context.TODO() +id := cosmosdb.NewGraphID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "gremlinDatabaseName", "graphName") + +read, err := client.GremlinResourcesGetGremlinGraph(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.GremlinResourcesGetGremlinGraphThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewGraphID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "gremlinDatabaseName", "graphName") + +read, err := client.GremlinResourcesGetGremlinGraphThroughput(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.GremlinResourcesListGremlinDatabases` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.GremlinResourcesListGremlinDatabases(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.GremlinResourcesListGremlinGraphs` + +```go +ctx := context.TODO() +id := cosmosdb.NewGremlinDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "gremlinDatabaseName") + +read, err := client.GremlinResourcesListGremlinGraphs(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.GremlinResourcesMigrateGremlinDatabaseToAutoscale` + +```go +ctx := context.TODO() +id := cosmosdb.NewGremlinDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "gremlinDatabaseName") + +if err := client.GremlinResourcesMigrateGremlinDatabaseToAutoscaleThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.GremlinResourcesMigrateGremlinDatabaseToManualThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewGremlinDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "gremlinDatabaseName") + +if err := client.GremlinResourcesMigrateGremlinDatabaseToManualThroughputThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.GremlinResourcesMigrateGremlinGraphToAutoscale` + +```go +ctx := context.TODO() +id := cosmosdb.NewGraphID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "gremlinDatabaseName", "graphName") + +if err := client.GremlinResourcesMigrateGremlinGraphToAutoscaleThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.GremlinResourcesMigrateGremlinGraphToManualThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewGraphID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "gremlinDatabaseName", "graphName") + +if err := client.GremlinResourcesMigrateGremlinGraphToManualThroughputThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.GremlinResourcesUpdateGremlinDatabaseThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewGremlinDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "gremlinDatabaseName") + +payload := cosmosdb.ThroughputSettingsUpdateParameters{ + // ... +} + + +if err := client.GremlinResourcesUpdateGremlinDatabaseThroughputThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.GremlinResourcesUpdateGremlinGraphThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewGraphID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "gremlinDatabaseName", "graphName") + +payload := cosmosdb.ThroughputSettingsUpdateParameters{ + // ... +} + + +if err := client.GremlinResourcesUpdateGremlinGraphThroughputThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.LocationsGet` + +```go +ctx := context.TODO() +id := cosmosdb.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +read, err := client.LocationsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.LocationsList` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.LocationsList(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.MongoDBResourcesCreateUpdateMongoDBCollection` + +```go +ctx := context.TODO() +id := cosmosdb.NewMongodbDatabaseCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongodbDatabaseName", "collectionName") + +payload := cosmosdb.MongoDBCollectionCreateUpdateParameters{ + // ... +} + + +if err := client.MongoDBResourcesCreateUpdateMongoDBCollectionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.MongoDBResourcesCreateUpdateMongoDBDatabase` + +```go +ctx := context.TODO() +id := cosmosdb.NewMongodbDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongodbDatabaseName") + +payload := cosmosdb.MongoDBDatabaseCreateUpdateParameters{ + // ... +} + + +if err := client.MongoDBResourcesCreateUpdateMongoDBDatabaseThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.MongoDBResourcesDeleteMongoDBCollection` + +```go +ctx := context.TODO() +id := cosmosdb.NewMongodbDatabaseCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongodbDatabaseName", "collectionName") + +if err := client.MongoDBResourcesDeleteMongoDBCollectionThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.MongoDBResourcesDeleteMongoDBDatabase` + +```go +ctx := context.TODO() +id := cosmosdb.NewMongodbDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongodbDatabaseName") + +if err := client.MongoDBResourcesDeleteMongoDBDatabaseThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.MongoDBResourcesGetMongoDBCollection` + +```go +ctx := context.TODO() +id := cosmosdb.NewMongodbDatabaseCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongodbDatabaseName", "collectionName") + +read, err := client.MongoDBResourcesGetMongoDBCollection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.MongoDBResourcesGetMongoDBCollectionThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewMongodbDatabaseCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongodbDatabaseName", "collectionName") + +read, err := client.MongoDBResourcesGetMongoDBCollectionThroughput(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.MongoDBResourcesGetMongoDBDatabase` + +```go +ctx := context.TODO() +id := cosmosdb.NewMongodbDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongodbDatabaseName") + +read, err := client.MongoDBResourcesGetMongoDBDatabase(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.MongoDBResourcesGetMongoDBDatabaseThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewMongodbDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongodbDatabaseName") + +read, err := client.MongoDBResourcesGetMongoDBDatabaseThroughput(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.MongoDBResourcesListMongoDBCollections` + +```go +ctx := context.TODO() +id := cosmosdb.NewMongodbDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongodbDatabaseName") + +read, err := client.MongoDBResourcesListMongoDBCollections(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.MongoDBResourcesListMongoDBDatabases` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.MongoDBResourcesListMongoDBDatabases(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.MongoDBResourcesMigrateMongoDBCollectionToAutoscale` + +```go +ctx := context.TODO() +id := cosmosdb.NewMongodbDatabaseCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongodbDatabaseName", "collectionName") + +if err := client.MongoDBResourcesMigrateMongoDBCollectionToAutoscaleThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.MongoDBResourcesMigrateMongoDBCollectionToManualThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewMongodbDatabaseCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongodbDatabaseName", "collectionName") + +if err := client.MongoDBResourcesMigrateMongoDBCollectionToManualThroughputThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.MongoDBResourcesMigrateMongoDBDatabaseToAutoscale` + +```go +ctx := context.TODO() +id := cosmosdb.NewMongodbDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongodbDatabaseName") + +if err := client.MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.MongoDBResourcesMigrateMongoDBDatabaseToManualThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewMongodbDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongodbDatabaseName") + +if err := client.MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.MongoDBResourcesUpdateMongoDBCollectionThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewMongodbDatabaseCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongodbDatabaseName", "collectionName") + +payload := cosmosdb.ThroughputSettingsUpdateParameters{ + // ... +} + + +if err := client.MongoDBResourcesUpdateMongoDBCollectionThroughputThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.MongoDBResourcesUpdateMongoDBDatabaseThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewMongodbDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongodbDatabaseName") + +payload := cosmosdb.ThroughputSettingsUpdateParameters{ + // ... +} + + +if err := client.MongoDBResourcesUpdateMongoDBDatabaseThroughputThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.PartitionKeyRangeIdListMetrics` + +```go +ctx := context.TODO() +id := cosmosdb.NewPartitionKeyRangeIdID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "databaseName", "collectionName", "partitionKeyRangeId") + +read, err := client.PartitionKeyRangeIdListMetrics(ctx, id, cosmosdb.DefaultPartitionKeyRangeIdListMetricsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.PartitionKeyRangeIdRegionListMetrics` + +```go +ctx := context.TODO() +id := cosmosdb.NewCollectionPartitionKeyRangeIdID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "regionName", "databaseName", "collectionName", "partitionKeyRangeId") + +read, err := client.PartitionKeyRangeIdRegionListMetrics(ctx, id, cosmosdb.DefaultPartitionKeyRangeIdRegionListMetricsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.PercentileListMetrics` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.PercentileListMetrics(ctx, id, cosmosdb.DefaultPercentileListMetricsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.PercentileSourceTargetListMetrics` + +```go +ctx := context.TODO() +id := cosmosdb.NewSourceRegionTargetRegionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sourceRegionName", "targetRegionName") + +read, err := client.PercentileSourceTargetListMetrics(ctx, id, cosmosdb.DefaultPercentileSourceTargetListMetricsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.PercentileTargetListMetrics` + +```go +ctx := context.TODO() +id := cosmosdb.NewTargetRegionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "targetRegionName") + +read, err := client.PercentileTargetListMetrics(ctx, id, cosmosdb.DefaultPercentileTargetListMetricsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesCreateUpdateClientEncryptionKey` + +```go +ctx := context.TODO() +id := cosmosdb.NewClientEncryptionKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "clientEncryptionKeyName") + +payload := cosmosdb.ClientEncryptionKeyCreateUpdateParameters{ + // ... +} + + +if err := client.SqlResourcesCreateUpdateClientEncryptionKeyThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesCreateUpdateSqlContainer` + +```go +ctx := context.TODO() +id := cosmosdb.NewContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName") + +payload := cosmosdb.SqlContainerCreateUpdateParameters{ + // ... +} + + +if err := client.SqlResourcesCreateUpdateSqlContainerThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesCreateUpdateSqlDatabase` + +```go +ctx := context.TODO() +id := cosmosdb.NewSqlDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName") + +payload := cosmosdb.SqlDatabaseCreateUpdateParameters{ + // ... +} + + +if err := client.SqlResourcesCreateUpdateSqlDatabaseThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesCreateUpdateSqlStoredProcedure` + +```go +ctx := context.TODO() +id := cosmosdb.NewStoredProcedureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName", "storedProcedureName") + +payload := cosmosdb.SqlStoredProcedureCreateUpdateParameters{ + // ... +} + + +if err := client.SqlResourcesCreateUpdateSqlStoredProcedureThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesCreateUpdateSqlTrigger` + +```go +ctx := context.TODO() +id := cosmosdb.NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName", "triggerName") + +payload := cosmosdb.SqlTriggerCreateUpdateParameters{ + // ... +} + + +if err := client.SqlResourcesCreateUpdateSqlTriggerThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesCreateUpdateSqlUserDefinedFunction` + +```go +ctx := context.TODO() +id := cosmosdb.NewUserDefinedFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName", "userDefinedFunctionName") + +payload := cosmosdb.SqlUserDefinedFunctionCreateUpdateParameters{ + // ... +} + + +if err := client.SqlResourcesCreateUpdateSqlUserDefinedFunctionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesDeleteSqlContainer` + +```go +ctx := context.TODO() +id := cosmosdb.NewContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName") + +if err := client.SqlResourcesDeleteSqlContainerThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesDeleteSqlDatabase` + +```go +ctx := context.TODO() +id := cosmosdb.NewSqlDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName") + +if err := client.SqlResourcesDeleteSqlDatabaseThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesDeleteSqlStoredProcedure` + +```go +ctx := context.TODO() +id := cosmosdb.NewStoredProcedureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName", "storedProcedureName") + +if err := client.SqlResourcesDeleteSqlStoredProcedureThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesDeleteSqlTrigger` + +```go +ctx := context.TODO() +id := cosmosdb.NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName", "triggerName") + +if err := client.SqlResourcesDeleteSqlTriggerThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesDeleteSqlUserDefinedFunction` + +```go +ctx := context.TODO() +id := cosmosdb.NewUserDefinedFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName", "userDefinedFunctionName") + +if err := client.SqlResourcesDeleteSqlUserDefinedFunctionThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesGetClientEncryptionKey` + +```go +ctx := context.TODO() +id := cosmosdb.NewClientEncryptionKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "clientEncryptionKeyName") + +read, err := client.SqlResourcesGetClientEncryptionKey(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesGetSqlContainer` + +```go +ctx := context.TODO() +id := cosmosdb.NewContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName") + +read, err := client.SqlResourcesGetSqlContainer(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesGetSqlContainerThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName") + +read, err := client.SqlResourcesGetSqlContainerThroughput(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesGetSqlDatabase` + +```go +ctx := context.TODO() +id := cosmosdb.NewSqlDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName") + +read, err := client.SqlResourcesGetSqlDatabase(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesGetSqlDatabaseThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewSqlDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName") + +read, err := client.SqlResourcesGetSqlDatabaseThroughput(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesGetSqlStoredProcedure` + +```go +ctx := context.TODO() +id := cosmosdb.NewStoredProcedureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName", "storedProcedureName") + +read, err := client.SqlResourcesGetSqlStoredProcedure(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesGetSqlTrigger` + +```go +ctx := context.TODO() +id := cosmosdb.NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName", "triggerName") + +read, err := client.SqlResourcesGetSqlTrigger(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesGetSqlUserDefinedFunction` + +```go +ctx := context.TODO() +id := cosmosdb.NewUserDefinedFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName", "userDefinedFunctionName") + +read, err := client.SqlResourcesGetSqlUserDefinedFunction(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesListClientEncryptionKeys` + +```go +ctx := context.TODO() +id := cosmosdb.NewSqlDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName") + +read, err := client.SqlResourcesListClientEncryptionKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesListSqlContainers` + +```go +ctx := context.TODO() +id := cosmosdb.NewSqlDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName") + +read, err := client.SqlResourcesListSqlContainers(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesListSqlDatabases` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.SqlResourcesListSqlDatabases(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesListSqlStoredProcedures` + +```go +ctx := context.TODO() +id := cosmosdb.NewContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName") + +read, err := client.SqlResourcesListSqlStoredProcedures(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesListSqlTriggers` + +```go +ctx := context.TODO() +id := cosmosdb.NewContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName") + +read, err := client.SqlResourcesListSqlTriggers(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesListSqlUserDefinedFunctions` + +```go +ctx := context.TODO() +id := cosmosdb.NewContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName") + +read, err := client.SqlResourcesListSqlUserDefinedFunctions(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesMigrateSqlContainerToAutoscale` + +```go +ctx := context.TODO() +id := cosmosdb.NewContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName") + +if err := client.SqlResourcesMigrateSqlContainerToAutoscaleThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesMigrateSqlContainerToManualThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName") + +if err := client.SqlResourcesMigrateSqlContainerToManualThroughputThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesMigrateSqlDatabaseToAutoscale` + +```go +ctx := context.TODO() +id := cosmosdb.NewSqlDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName") + +if err := client.SqlResourcesMigrateSqlDatabaseToAutoscaleThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesMigrateSqlDatabaseToManualThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewSqlDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName") + +if err := client.SqlResourcesMigrateSqlDatabaseToManualThroughputThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesUpdateSqlContainerThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName") + +payload := cosmosdb.ThroughputSettingsUpdateParameters{ + // ... +} + + +if err := client.SqlResourcesUpdateSqlContainerThroughputThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.SqlResourcesUpdateSqlDatabaseThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewSqlDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName") + +payload := cosmosdb.ThroughputSettingsUpdateParameters{ + // ... +} + + +if err := client.SqlResourcesUpdateSqlDatabaseThroughputThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.TableResourcesCreateUpdateTable` + +```go +ctx := context.TODO() +id := cosmosdb.NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "tableName") + +payload := cosmosdb.TableCreateUpdateParameters{ + // ... +} + + +if err := client.TableResourcesCreateUpdateTableThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.TableResourcesDeleteTable` + +```go +ctx := context.TODO() +id := cosmosdb.NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "tableName") + +if err := client.TableResourcesDeleteTableThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.TableResourcesGetTable` + +```go +ctx := context.TODO() +id := cosmosdb.NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "tableName") + +read, err := client.TableResourcesGetTable(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.TableResourcesGetTableThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "tableName") + +read, err := client.TableResourcesGetTableThroughput(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.TableResourcesListTables` + +```go +ctx := context.TODO() +id := cosmosdb.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.TableResourcesListTables(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CosmosDBClient.TableResourcesMigrateTableToAutoscale` + +```go +ctx := context.TODO() +id := cosmosdb.NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "tableName") + +if err := client.TableResourcesMigrateTableToAutoscaleThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.TableResourcesMigrateTableToManualThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "tableName") + +if err := client.TableResourcesMigrateTableToManualThroughputThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CosmosDBClient.TableResourcesUpdateTableThroughput` + +```go +ctx := context.TODO() +id := cosmosdb.NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "tableName") + +payload := cosmosdb.ThroughputSettingsUpdateParameters{ + // ... +} + + +if err := client.TableResourcesUpdateTableThroughputThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/client.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/client.go new file mode 100644 index 00000000000..68f649fae55 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/client.go @@ -0,0 +1,26 @@ +package cosmosdb + +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 CosmosDBClient struct { + Client *resourcemanager.Client +} + +func NewCosmosDBClientWithBaseURI(sdkApi sdkEnv.Api) (*CosmosDBClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "cosmosdb", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CosmosDBClient: %+v", err) + } + + return &CosmosDBClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/constants.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/constants.go new file mode 100644 index 00000000000..c4e44d244bd --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/constants.go @@ -0,0 +1,1510 @@ +package cosmosdb + +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 AnalyticalStorageSchemaType string + +const ( + AnalyticalStorageSchemaTypeFullFidelity AnalyticalStorageSchemaType = "FullFidelity" + AnalyticalStorageSchemaTypeWellDefined AnalyticalStorageSchemaType = "WellDefined" +) + +func PossibleValuesForAnalyticalStorageSchemaType() []string { + return []string{ + string(AnalyticalStorageSchemaTypeFullFidelity), + string(AnalyticalStorageSchemaTypeWellDefined), + } +} + +func (s *AnalyticalStorageSchemaType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAnalyticalStorageSchemaType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAnalyticalStorageSchemaType(input string) (*AnalyticalStorageSchemaType, error) { + vals := map[string]AnalyticalStorageSchemaType{ + "fullfidelity": AnalyticalStorageSchemaTypeFullFidelity, + "welldefined": AnalyticalStorageSchemaTypeWellDefined, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AnalyticalStorageSchemaType(input) + return &out, nil +} + +type BackupPolicyMigrationStatus string + +const ( + BackupPolicyMigrationStatusCompleted BackupPolicyMigrationStatus = "Completed" + BackupPolicyMigrationStatusFailed BackupPolicyMigrationStatus = "Failed" + BackupPolicyMigrationStatusInProgress BackupPolicyMigrationStatus = "InProgress" + BackupPolicyMigrationStatusInvalid BackupPolicyMigrationStatus = "Invalid" +) + +func PossibleValuesForBackupPolicyMigrationStatus() []string { + return []string{ + string(BackupPolicyMigrationStatusCompleted), + string(BackupPolicyMigrationStatusFailed), + string(BackupPolicyMigrationStatusInProgress), + string(BackupPolicyMigrationStatusInvalid), + } +} + +func (s *BackupPolicyMigrationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupPolicyMigrationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackupPolicyMigrationStatus(input string) (*BackupPolicyMigrationStatus, error) { + vals := map[string]BackupPolicyMigrationStatus{ + "completed": BackupPolicyMigrationStatusCompleted, + "failed": BackupPolicyMigrationStatusFailed, + "inprogress": BackupPolicyMigrationStatusInProgress, + "invalid": BackupPolicyMigrationStatusInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupPolicyMigrationStatus(input) + return &out, nil +} + +type BackupPolicyType string + +const ( + BackupPolicyTypeContinuous BackupPolicyType = "Continuous" + BackupPolicyTypePeriodic BackupPolicyType = "Periodic" +) + +func PossibleValuesForBackupPolicyType() []string { + return []string{ + string(BackupPolicyTypeContinuous), + string(BackupPolicyTypePeriodic), + } +} + +func (s *BackupPolicyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupPolicyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackupPolicyType(input string) (*BackupPolicyType, error) { + vals := map[string]BackupPolicyType{ + "continuous": BackupPolicyTypeContinuous, + "periodic": BackupPolicyTypePeriodic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupPolicyType(input) + return &out, nil +} + +type BackupStorageRedundancy string + +const ( + BackupStorageRedundancyGeo BackupStorageRedundancy = "Geo" + BackupStorageRedundancyLocal BackupStorageRedundancy = "Local" + BackupStorageRedundancyZone BackupStorageRedundancy = "Zone" +) + +func PossibleValuesForBackupStorageRedundancy() []string { + return []string{ + string(BackupStorageRedundancyGeo), + string(BackupStorageRedundancyLocal), + string(BackupStorageRedundancyZone), + } +} + +func (s *BackupStorageRedundancy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupStorageRedundancy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackupStorageRedundancy(input string) (*BackupStorageRedundancy, error) { + vals := map[string]BackupStorageRedundancy{ + "geo": BackupStorageRedundancyGeo, + "local": BackupStorageRedundancyLocal, + "zone": BackupStorageRedundancyZone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupStorageRedundancy(input) + return &out, nil +} + +type CompositePathSortOrder string + +const ( + CompositePathSortOrderAscending CompositePathSortOrder = "ascending" + CompositePathSortOrderDescending CompositePathSortOrder = "descending" +) + +func PossibleValuesForCompositePathSortOrder() []string { + return []string{ + string(CompositePathSortOrderAscending), + string(CompositePathSortOrderDescending), + } +} + +func (s *CompositePathSortOrder) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCompositePathSortOrder(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCompositePathSortOrder(input string) (*CompositePathSortOrder, error) { + vals := map[string]CompositePathSortOrder{ + "ascending": CompositePathSortOrderAscending, + "descending": CompositePathSortOrderDescending, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CompositePathSortOrder(input) + return &out, nil +} + +type ConflictResolutionMode string + +const ( + ConflictResolutionModeCustom ConflictResolutionMode = "Custom" + ConflictResolutionModeLastWriterWins ConflictResolutionMode = "LastWriterWins" +) + +func PossibleValuesForConflictResolutionMode() []string { + return []string{ + string(ConflictResolutionModeCustom), + string(ConflictResolutionModeLastWriterWins), + } +} + +func (s *ConflictResolutionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConflictResolutionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConflictResolutionMode(input string) (*ConflictResolutionMode, error) { + vals := map[string]ConflictResolutionMode{ + "custom": ConflictResolutionModeCustom, + "lastwriterwins": ConflictResolutionModeLastWriterWins, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConflictResolutionMode(input) + return &out, nil +} + +type ConnectorOffer string + +const ( + ConnectorOfferSmall ConnectorOffer = "Small" +) + +func PossibleValuesForConnectorOffer() []string { + return []string{ + string(ConnectorOfferSmall), + } +} + +func (s *ConnectorOffer) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectorOffer(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectorOffer(input string) (*ConnectorOffer, error) { + vals := map[string]ConnectorOffer{ + "small": ConnectorOfferSmall, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectorOffer(input) + return &out, nil +} + +type ContinuousTier string + +const ( + ContinuousTierContinuousSevenDays ContinuousTier = "Continuous7Days" + ContinuousTierContinuousThreeZeroDays ContinuousTier = "Continuous30Days" +) + +func PossibleValuesForContinuousTier() []string { + return []string{ + string(ContinuousTierContinuousSevenDays), + string(ContinuousTierContinuousThreeZeroDays), + } +} + +func (s *ContinuousTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseContinuousTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseContinuousTier(input string) (*ContinuousTier, error) { + vals := map[string]ContinuousTier{ + "continuous7days": ContinuousTierContinuousSevenDays, + "continuous30days": ContinuousTierContinuousThreeZeroDays, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ContinuousTier(input) + return &out, nil +} + +type CreateMode string + +const ( + CreateModeDefault CreateMode = "Default" + CreateModeRestore CreateMode = "Restore" +) + +func PossibleValuesForCreateMode() []string { + return []string{ + string(CreateModeDefault), + string(CreateModeRestore), + } +} + +func (s *CreateMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCreateMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCreateMode(input string) (*CreateMode, error) { + vals := map[string]CreateMode{ + "default": CreateModeDefault, + "restore": CreateModeRestore, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreateMode(input) + return &out, nil +} + +type DataType string + +const ( + DataTypeLineString DataType = "LineString" + DataTypeMultiPolygon DataType = "MultiPolygon" + DataTypeNumber DataType = "Number" + DataTypePoint DataType = "Point" + DataTypePolygon DataType = "Polygon" + DataTypeString DataType = "String" +) + +func PossibleValuesForDataType() []string { + return []string{ + string(DataTypeLineString), + string(DataTypeMultiPolygon), + string(DataTypeNumber), + string(DataTypePoint), + string(DataTypePolygon), + string(DataTypeString), + } +} + +func (s *DataType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataType(input string) (*DataType, error) { + vals := map[string]DataType{ + "linestring": DataTypeLineString, + "multipolygon": DataTypeMultiPolygon, + "number": DataTypeNumber, + "point": DataTypePoint, + "polygon": DataTypePolygon, + "string": DataTypeString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataType(input) + return &out, nil +} + +type DatabaseAccountKind string + +const ( + DatabaseAccountKindGlobalDocumentDB DatabaseAccountKind = "GlobalDocumentDB" + DatabaseAccountKindMongoDB DatabaseAccountKind = "MongoDB" + DatabaseAccountKindParse DatabaseAccountKind = "Parse" +) + +func PossibleValuesForDatabaseAccountKind() []string { + return []string{ + string(DatabaseAccountKindGlobalDocumentDB), + string(DatabaseAccountKindMongoDB), + string(DatabaseAccountKindParse), + } +} + +func (s *DatabaseAccountKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDatabaseAccountKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDatabaseAccountKind(input string) (*DatabaseAccountKind, error) { + vals := map[string]DatabaseAccountKind{ + "globaldocumentdb": DatabaseAccountKindGlobalDocumentDB, + "mongodb": DatabaseAccountKindMongoDB, + "parse": DatabaseAccountKindParse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DatabaseAccountKind(input) + return &out, nil +} + +type DatabaseAccountOfferType string + +const ( + DatabaseAccountOfferTypeStandard DatabaseAccountOfferType = "Standard" +) + +func PossibleValuesForDatabaseAccountOfferType() []string { + return []string{ + string(DatabaseAccountOfferTypeStandard), + } +} + +func (s *DatabaseAccountOfferType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDatabaseAccountOfferType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDatabaseAccountOfferType(input string) (*DatabaseAccountOfferType, error) { + vals := map[string]DatabaseAccountOfferType{ + "standard": DatabaseAccountOfferTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DatabaseAccountOfferType(input) + return &out, nil +} + +type DefaultConsistencyLevel string + +const ( + DefaultConsistencyLevelBoundedStaleness DefaultConsistencyLevel = "BoundedStaleness" + DefaultConsistencyLevelConsistentPrefix DefaultConsistencyLevel = "ConsistentPrefix" + DefaultConsistencyLevelEventual DefaultConsistencyLevel = "Eventual" + DefaultConsistencyLevelSession DefaultConsistencyLevel = "Session" + DefaultConsistencyLevelStrong DefaultConsistencyLevel = "Strong" +) + +func PossibleValuesForDefaultConsistencyLevel() []string { + return []string{ + string(DefaultConsistencyLevelBoundedStaleness), + string(DefaultConsistencyLevelConsistentPrefix), + string(DefaultConsistencyLevelEventual), + string(DefaultConsistencyLevelSession), + string(DefaultConsistencyLevelStrong), + } +} + +func (s *DefaultConsistencyLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDefaultConsistencyLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDefaultConsistencyLevel(input string) (*DefaultConsistencyLevel, error) { + vals := map[string]DefaultConsistencyLevel{ + "boundedstaleness": DefaultConsistencyLevelBoundedStaleness, + "consistentprefix": DefaultConsistencyLevelConsistentPrefix, + "eventual": DefaultConsistencyLevelEventual, + "session": DefaultConsistencyLevelSession, + "strong": DefaultConsistencyLevelStrong, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DefaultConsistencyLevel(input) + return &out, nil +} + +type DistanceFunction string + +const ( + DistanceFunctionCosine DistanceFunction = "cosine" + DistanceFunctionDotproduct DistanceFunction = "dotproduct" + DistanceFunctionEuclidean DistanceFunction = "euclidean" +) + +func PossibleValuesForDistanceFunction() []string { + return []string{ + string(DistanceFunctionCosine), + string(DistanceFunctionDotproduct), + string(DistanceFunctionEuclidean), + } +} + +func (s *DistanceFunction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDistanceFunction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDistanceFunction(input string) (*DistanceFunction, error) { + vals := map[string]DistanceFunction{ + "cosine": DistanceFunctionCosine, + "dotproduct": DistanceFunctionDotproduct, + "euclidean": DistanceFunctionEuclidean, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DistanceFunction(input) + return &out, nil +} + +type IndexKind string + +const ( + IndexKindHash IndexKind = "Hash" + IndexKindRange IndexKind = "Range" + IndexKindSpatial IndexKind = "Spatial" +) + +func PossibleValuesForIndexKind() []string { + return []string{ + string(IndexKindHash), + string(IndexKindRange), + string(IndexKindSpatial), + } +} + +func (s *IndexKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIndexKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIndexKind(input string) (*IndexKind, error) { + vals := map[string]IndexKind{ + "hash": IndexKindHash, + "range": IndexKindRange, + "spatial": IndexKindSpatial, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IndexKind(input) + return &out, nil +} + +type IndexingMode string + +const ( + IndexingModeConsistent IndexingMode = "consistent" + IndexingModeLazy IndexingMode = "lazy" + IndexingModeNone IndexingMode = "none" +) + +func PossibleValuesForIndexingMode() []string { + return []string{ + string(IndexingModeConsistent), + string(IndexingModeLazy), + string(IndexingModeNone), + } +} + +func (s *IndexingMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIndexingMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIndexingMode(input string) (*IndexingMode, error) { + vals := map[string]IndexingMode{ + "consistent": IndexingModeConsistent, + "lazy": IndexingModeLazy, + "none": IndexingModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IndexingMode(input) + return &out, nil +} + +type KeyKind string + +const ( + KeyKindPrimary KeyKind = "primary" + KeyKindPrimaryReadonly KeyKind = "primaryReadonly" + KeyKindSecondary KeyKind = "secondary" + KeyKindSecondaryReadonly KeyKind = "secondaryReadonly" +) + +func PossibleValuesForKeyKind() []string { + return []string{ + string(KeyKindPrimary), + string(KeyKindPrimaryReadonly), + string(KeyKindSecondary), + string(KeyKindSecondaryReadonly), + } +} + +func (s *KeyKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyKind(input string) (*KeyKind, error) { + vals := map[string]KeyKind{ + "primary": KeyKindPrimary, + "primaryreadonly": KeyKindPrimaryReadonly, + "secondary": KeyKindSecondary, + "secondaryreadonly": KeyKindSecondaryReadonly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyKind(input) + return &out, nil +} + +type Kind string + +const ( + KindPrimary Kind = "Primary" + KindPrimaryReadonly Kind = "PrimaryReadonly" + KindSecondary Kind = "Secondary" + KindSecondaryReadonly Kind = "SecondaryReadonly" +) + +func PossibleValuesForKind() []string { + return []string{ + string(KindPrimary), + string(KindPrimaryReadonly), + string(KindSecondary), + string(KindSecondaryReadonly), + } +} + +func (s *Kind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKind(input string) (*Kind, error) { + vals := map[string]Kind{ + "primary": KindPrimary, + "primaryreadonly": KindPrimaryReadonly, + "secondary": KindSecondary, + "secondaryreadonly": KindSecondaryReadonly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Kind(input) + return &out, nil +} + +type MinimalTlsVersion string + +const ( + MinimalTlsVersionTls MinimalTlsVersion = "Tls" + MinimalTlsVersionTlsOneOne MinimalTlsVersion = "Tls11" + MinimalTlsVersionTlsOneTwo MinimalTlsVersion = "Tls12" +) + +func PossibleValuesForMinimalTlsVersion() []string { + return []string{ + string(MinimalTlsVersionTls), + string(MinimalTlsVersionTlsOneOne), + string(MinimalTlsVersionTlsOneTwo), + } +} + +func (s *MinimalTlsVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMinimalTlsVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMinimalTlsVersion(input string) (*MinimalTlsVersion, error) { + vals := map[string]MinimalTlsVersion{ + "tls": MinimalTlsVersionTls, + "tls11": MinimalTlsVersionTlsOneOne, + "tls12": MinimalTlsVersionTlsOneTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MinimalTlsVersion(input) + return &out, nil +} + +type NetworkAclBypass string + +const ( + NetworkAclBypassAzureServices NetworkAclBypass = "AzureServices" + NetworkAclBypassNone NetworkAclBypass = "None" +) + +func PossibleValuesForNetworkAclBypass() []string { + return []string{ + string(NetworkAclBypassAzureServices), + string(NetworkAclBypassNone), + } +} + +func (s *NetworkAclBypass) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkAclBypass(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkAclBypass(input string) (*NetworkAclBypass, error) { + vals := map[string]NetworkAclBypass{ + "azureservices": NetworkAclBypassAzureServices, + "none": NetworkAclBypassNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkAclBypass(input) + return &out, nil +} + +type PartitionKind string + +const ( + PartitionKindHash PartitionKind = "Hash" + PartitionKindMultiHash PartitionKind = "MultiHash" + PartitionKindRange PartitionKind = "Range" +) + +func PossibleValuesForPartitionKind() []string { + return []string{ + string(PartitionKindHash), + string(PartitionKindMultiHash), + string(PartitionKindRange), + } +} + +func (s *PartitionKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePartitionKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePartitionKind(input string) (*PartitionKind, error) { + vals := map[string]PartitionKind{ + "hash": PartitionKindHash, + "multihash": PartitionKindMultiHash, + "range": PartitionKindRange, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PartitionKind(input) + return &out, nil +} + +type PrimaryAggregationType string + +const ( + PrimaryAggregationTypeAverage PrimaryAggregationType = "Average" + PrimaryAggregationTypeLast PrimaryAggregationType = "Last" + PrimaryAggregationTypeMaximum PrimaryAggregationType = "Maximum" + PrimaryAggregationTypeMinimum PrimaryAggregationType = "Minimum" + PrimaryAggregationTypeNone PrimaryAggregationType = "None" + PrimaryAggregationTypeTotal PrimaryAggregationType = "Total" +) + +func PossibleValuesForPrimaryAggregationType() []string { + return []string{ + string(PrimaryAggregationTypeAverage), + string(PrimaryAggregationTypeLast), + string(PrimaryAggregationTypeMaximum), + string(PrimaryAggregationTypeMinimum), + string(PrimaryAggregationTypeNone), + string(PrimaryAggregationTypeTotal), + } +} + +func (s *PrimaryAggregationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrimaryAggregationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrimaryAggregationType(input string) (*PrimaryAggregationType, error) { + vals := map[string]PrimaryAggregationType{ + "average": PrimaryAggregationTypeAverage, + "last": PrimaryAggregationTypeLast, + "maximum": PrimaryAggregationTypeMaximum, + "minimum": PrimaryAggregationTypeMinimum, + "none": PrimaryAggregationTypeNone, + "total": PrimaryAggregationTypeTotal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrimaryAggregationType(input) + return &out, nil +} + +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" + PublicNetworkAccessSecuredByPerimeter PublicNetworkAccess = "SecuredByPerimeter" +) + +func PossibleValuesForPublicNetworkAccess() []string { + return []string{ + string(PublicNetworkAccessDisabled), + string(PublicNetworkAccessEnabled), + string(PublicNetworkAccessSecuredByPerimeter), + } +} + +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { + vals := map[string]PublicNetworkAccess{ + "disabled": PublicNetworkAccessDisabled, + "enabled": PublicNetworkAccessEnabled, + "securedbyperimeter": PublicNetworkAccessSecuredByPerimeter, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccess(input) + return &out, nil +} + +type RestoreMode string + +const ( + RestoreModePointInTime RestoreMode = "PointInTime" +) + +func PossibleValuesForRestoreMode() []string { + return []string{ + string(RestoreModePointInTime), + } +} + +func (s *RestoreMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRestoreMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRestoreMode(input string) (*RestoreMode, error) { + vals := map[string]RestoreMode{ + "pointintime": RestoreModePointInTime, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RestoreMode(input) + return &out, nil +} + +type ServerVersion string + +const ( + ServerVersionFivePointZero ServerVersion = "5.0" + ServerVersionFourPointTwo ServerVersion = "4.2" + ServerVersionFourPointZero ServerVersion = "4.0" + ServerVersionSevenPointZero ServerVersion = "7.0" + ServerVersionSixPointZero ServerVersion = "6.0" + ServerVersionThreePointSix ServerVersion = "3.6" + ServerVersionThreePointTwo ServerVersion = "3.2" +) + +func PossibleValuesForServerVersion() []string { + return []string{ + string(ServerVersionFivePointZero), + string(ServerVersionFourPointTwo), + string(ServerVersionFourPointZero), + string(ServerVersionSevenPointZero), + string(ServerVersionSixPointZero), + string(ServerVersionThreePointSix), + string(ServerVersionThreePointTwo), + } +} + +func (s *ServerVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServerVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServerVersion(input string) (*ServerVersion, error) { + vals := map[string]ServerVersion{ + "5.0": ServerVersionFivePointZero, + "4.2": ServerVersionFourPointTwo, + "4.0": ServerVersionFourPointZero, + "7.0": ServerVersionSevenPointZero, + "6.0": ServerVersionSixPointZero, + "3.6": ServerVersionThreePointSix, + "3.2": ServerVersionThreePointTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServerVersion(input) + return &out, nil +} + +type SpatialType string + +const ( + SpatialTypeLineString SpatialType = "LineString" + SpatialTypeMultiPolygon SpatialType = "MultiPolygon" + SpatialTypePoint SpatialType = "Point" + SpatialTypePolygon SpatialType = "Polygon" +) + +func PossibleValuesForSpatialType() []string { + return []string{ + string(SpatialTypeLineString), + string(SpatialTypeMultiPolygon), + string(SpatialTypePoint), + string(SpatialTypePolygon), + } +} + +func (s *SpatialType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSpatialType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSpatialType(input string) (*SpatialType, error) { + vals := map[string]SpatialType{ + "linestring": SpatialTypeLineString, + "multipolygon": SpatialTypeMultiPolygon, + "point": SpatialTypePoint, + "polygon": SpatialTypePolygon, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SpatialType(input) + return &out, nil +} + +type Status string + +const ( + StatusDeleting Status = "Deleting" + StatusInitializing Status = "Initializing" + StatusInternallyReady Status = "InternallyReady" + StatusOnline Status = "Online" + StatusUninitialized Status = "Uninitialized" +) + +func PossibleValuesForStatus() []string { + return []string{ + string(StatusDeleting), + string(StatusInitializing), + string(StatusInternallyReady), + string(StatusOnline), + string(StatusUninitialized), + } +} + +func (s *Status) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStatus(input string) (*Status, error) { + vals := map[string]Status{ + "deleting": StatusDeleting, + "initializing": StatusInitializing, + "internallyready": StatusInternallyReady, + "online": StatusOnline, + "uninitialized": StatusUninitialized, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Status(input) + return &out, nil +} + +type TriggerOperation string + +const ( + TriggerOperationAll TriggerOperation = "All" + TriggerOperationCreate TriggerOperation = "Create" + TriggerOperationDelete TriggerOperation = "Delete" + TriggerOperationReplace TriggerOperation = "Replace" + TriggerOperationUpdate TriggerOperation = "Update" +) + +func PossibleValuesForTriggerOperation() []string { + return []string{ + string(TriggerOperationAll), + string(TriggerOperationCreate), + string(TriggerOperationDelete), + string(TriggerOperationReplace), + string(TriggerOperationUpdate), + } +} + +func (s *TriggerOperation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTriggerOperation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTriggerOperation(input string) (*TriggerOperation, error) { + vals := map[string]TriggerOperation{ + "all": TriggerOperationAll, + "create": TriggerOperationCreate, + "delete": TriggerOperationDelete, + "replace": TriggerOperationReplace, + "update": TriggerOperationUpdate, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TriggerOperation(input) + return &out, nil +} + +type TriggerType string + +const ( + TriggerTypePost TriggerType = "Post" + TriggerTypePre TriggerType = "Pre" +) + +func PossibleValuesForTriggerType() []string { + return []string{ + string(TriggerTypePost), + string(TriggerTypePre), + } +} + +func (s *TriggerType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTriggerType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTriggerType(input string) (*TriggerType, error) { + vals := map[string]TriggerType{ + "post": TriggerTypePost, + "pre": TriggerTypePre, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TriggerType(input) + return &out, nil +} + +type Type string + +const ( + TypeCassandra Type = "Cassandra" + TypeCassandraConnectorMetadata Type = "CassandraConnectorMetadata" + TypeGremlin Type = "Gremlin" + TypeGremlinVTwo Type = "GremlinV2" + TypeMongoDB Type = "MongoDB" + TypeSql Type = "Sql" + TypeSqlDedicatedGateway Type = "SqlDedicatedGateway" + TypeTable Type = "Table" + TypeUndefined Type = "Undefined" +) + +func PossibleValuesForType() []string { + return []string{ + string(TypeCassandra), + string(TypeCassandraConnectorMetadata), + string(TypeGremlin), + string(TypeGremlinVTwo), + string(TypeMongoDB), + string(TypeSql), + string(TypeSqlDedicatedGateway), + string(TypeTable), + string(TypeUndefined), + } +} + +func (s *Type) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseType(input string) (*Type, error) { + vals := map[string]Type{ + "cassandra": TypeCassandra, + "cassandraconnectormetadata": TypeCassandraConnectorMetadata, + "gremlin": TypeGremlin, + "gremlinv2": TypeGremlinVTwo, + "mongodb": TypeMongoDB, + "sql": TypeSql, + "sqldedicatedgateway": TypeSqlDedicatedGateway, + "table": TypeTable, + "undefined": TypeUndefined, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Type(input) + return &out, nil +} + +type UnitType string + +const ( + UnitTypeBytes UnitType = "Bytes" + UnitTypeBytesPerSecond UnitType = "BytesPerSecond" + UnitTypeCount UnitType = "Count" + UnitTypeCountPerSecond UnitType = "CountPerSecond" + UnitTypeMilliseconds UnitType = "Milliseconds" + UnitTypePercent UnitType = "Percent" + UnitTypeSeconds UnitType = "Seconds" +) + +func PossibleValuesForUnitType() []string { + return []string{ + string(UnitTypeBytes), + string(UnitTypeBytesPerSecond), + string(UnitTypeCount), + string(UnitTypeCountPerSecond), + string(UnitTypeMilliseconds), + string(UnitTypePercent), + string(UnitTypeSeconds), + } +} + +func (s *UnitType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUnitType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUnitType(input string) (*UnitType, error) { + vals := map[string]UnitType{ + "bytes": UnitTypeBytes, + "bytespersecond": UnitTypeBytesPerSecond, + "count": UnitTypeCount, + "countpersecond": UnitTypeCountPerSecond, + "milliseconds": UnitTypeMilliseconds, + "percent": UnitTypePercent, + "seconds": UnitTypeSeconds, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UnitType(input) + return &out, nil +} + +type VectorDataType string + +const ( + VectorDataTypeFloatThreeTwo VectorDataType = "float32" + VectorDataTypeIntEight VectorDataType = "int8" + VectorDataTypeUintEight VectorDataType = "uint8" +) + +func PossibleValuesForVectorDataType() []string { + return []string{ + string(VectorDataTypeFloatThreeTwo), + string(VectorDataTypeIntEight), + string(VectorDataTypeUintEight), + } +} + +func (s *VectorDataType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVectorDataType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVectorDataType(input string) (*VectorDataType, error) { + vals := map[string]VectorDataType{ + "float32": VectorDataTypeFloatThreeTwo, + "int8": VectorDataTypeIntEight, + "uint8": VectorDataTypeUintEight, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VectorDataType(input) + return &out, nil +} + +type VectorIndexType string + +const ( + VectorIndexTypeDiskANN VectorIndexType = "diskANN" + VectorIndexTypeFlat VectorIndexType = "flat" + VectorIndexTypeQuantizedFlat VectorIndexType = "quantizedFlat" +) + +func PossibleValuesForVectorIndexType() []string { + return []string{ + string(VectorIndexTypeDiskANN), + string(VectorIndexTypeFlat), + string(VectorIndexTypeQuantizedFlat), + } +} + +func (s *VectorIndexType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVectorIndexType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVectorIndexType(input string) (*VectorIndexType, error) { + vals := map[string]VectorIndexType{ + "diskann": VectorIndexTypeDiskANN, + "flat": VectorIndexTypeFlat, + "quantizedflat": VectorIndexTypeQuantizedFlat, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VectorIndexType(input) + return &out, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_cassandrakeyspace.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_cassandrakeyspace.go new file mode 100644 index 00000000000..c7e797b1802 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_cassandrakeyspace.go @@ -0,0 +1,139 @@ +package cosmosdb + +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(&CassandraKeyspaceId{}) +} + +var _ resourceids.ResourceId = &CassandraKeyspaceId{} + +// CassandraKeyspaceId is a struct representing the Resource ID for a Cassandra Keyspace +type CassandraKeyspaceId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + CassandraKeyspaceName string +} + +// NewCassandraKeyspaceID returns a new CassandraKeyspaceId struct +func NewCassandraKeyspaceID(subscriptionId string, resourceGroupName string, databaseAccountName string, cassandraKeyspaceName string) CassandraKeyspaceId { + return CassandraKeyspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + CassandraKeyspaceName: cassandraKeyspaceName, + } +} + +// ParseCassandraKeyspaceID parses 'input' into a CassandraKeyspaceId +func ParseCassandraKeyspaceID(input string) (*CassandraKeyspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&CassandraKeyspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CassandraKeyspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCassandraKeyspaceIDInsensitively parses 'input' case-insensitively into a CassandraKeyspaceId +// note: this method should only be used for API response data and not user input +func ParseCassandraKeyspaceIDInsensitively(input string) (*CassandraKeyspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&CassandraKeyspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CassandraKeyspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CassandraKeyspaceId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.CassandraKeyspaceName, ok = input.Parsed["cassandraKeyspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cassandraKeyspaceName", input) + } + + return nil +} + +// ValidateCassandraKeyspaceID checks that 'input' can be parsed as a Cassandra Keyspace ID +func ValidateCassandraKeyspaceID(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 := ParseCassandraKeyspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cassandra Keyspace ID +func (id CassandraKeyspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/cassandraKeyspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.CassandraKeyspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cassandra Keyspace ID +func (id CassandraKeyspaceId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticCassandraKeyspaces", "cassandraKeyspaces", "cassandraKeyspaces"), + resourceids.UserSpecifiedSegment("cassandraKeyspaceName", "cassandraKeyspaceName"), + } +} + +// String returns a human-readable description of this Cassandra Keyspace ID +func (id CassandraKeyspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Cassandra Keyspace Name: %q", id.CassandraKeyspaceName), + } + return fmt.Sprintf("Cassandra Keyspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_cassandrakeyspace_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_cassandrakeyspace_test.go new file mode 100644 index 00000000000..1f760780ed8 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_cassandrakeyspace_test.go @@ -0,0 +1,327 @@ +package cosmosdb + +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 = &CassandraKeyspaceId{} + +func TestNewCassandraKeyspaceID(t *testing.T) { + id := NewCassandraKeyspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "cassandraKeyspaceName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.CassandraKeyspaceName != "cassandraKeyspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'CassandraKeyspaceName'", id.CassandraKeyspaceName, "cassandraKeyspaceName") + } +} + +func TestFormatCassandraKeyspaceID(t *testing.T) { + actual := NewCassandraKeyspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "cassandraKeyspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/cassandraKeyspaces/cassandraKeyspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCassandraKeyspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CassandraKeyspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/cassandraKeyspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/cassandraKeyspaces/cassandraKeyspaceName", + Expected: &CassandraKeyspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + CassandraKeyspaceName: "cassandraKeyspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/cassandraKeyspaces/cassandraKeyspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCassandraKeyspaceID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.CassandraKeyspaceName != v.Expected.CassandraKeyspaceName { + t.Fatalf("Expected %q but got %q for CassandraKeyspaceName", v.Expected.CassandraKeyspaceName, actual.CassandraKeyspaceName) + } + + } +} + +func TestParseCassandraKeyspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CassandraKeyspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/cassandraKeyspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/cAsSaNdRaKeYsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/cassandraKeyspaces/cassandraKeyspaceName", + Expected: &CassandraKeyspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + CassandraKeyspaceName: "cassandraKeyspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/cassandraKeyspaces/cassandraKeyspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/cAsSaNdRaKeYsPaCeS/cAsSaNdRaKeYsPaCeNaMe", + Expected: &CassandraKeyspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + CassandraKeyspaceName: "cAsSaNdRaKeYsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/cAsSaNdRaKeYsPaCeS/cAsSaNdRaKeYsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCassandraKeyspaceIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.CassandraKeyspaceName != v.Expected.CassandraKeyspaceName { + t.Fatalf("Expected %q but got %q for CassandraKeyspaceName", v.Expected.CassandraKeyspaceName, actual.CassandraKeyspaceName) + } + + } +} + +func TestSegmentsForCassandraKeyspaceId(t *testing.T) { + segments := CassandraKeyspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CassandraKeyspaceId 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/cosmosdb/2024-11-15/cosmosdb/id_cassandrakeyspacetable.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_cassandrakeyspacetable.go new file mode 100644 index 00000000000..5609bfaea81 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_cassandrakeyspacetable.go @@ -0,0 +1,148 @@ +package cosmosdb + +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(&CassandraKeyspaceTableId{}) +} + +var _ resourceids.ResourceId = &CassandraKeyspaceTableId{} + +// CassandraKeyspaceTableId is a struct representing the Resource ID for a Cassandra Keyspace Table +type CassandraKeyspaceTableId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + CassandraKeyspaceName string + TableName string +} + +// NewCassandraKeyspaceTableID returns a new CassandraKeyspaceTableId struct +func NewCassandraKeyspaceTableID(subscriptionId string, resourceGroupName string, databaseAccountName string, cassandraKeyspaceName string, tableName string) CassandraKeyspaceTableId { + return CassandraKeyspaceTableId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + CassandraKeyspaceName: cassandraKeyspaceName, + TableName: tableName, + } +} + +// ParseCassandraKeyspaceTableID parses 'input' into a CassandraKeyspaceTableId +func ParseCassandraKeyspaceTableID(input string) (*CassandraKeyspaceTableId, error) { + parser := resourceids.NewParserFromResourceIdType(&CassandraKeyspaceTableId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CassandraKeyspaceTableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCassandraKeyspaceTableIDInsensitively parses 'input' case-insensitively into a CassandraKeyspaceTableId +// note: this method should only be used for API response data and not user input +func ParseCassandraKeyspaceTableIDInsensitively(input string) (*CassandraKeyspaceTableId, error) { + parser := resourceids.NewParserFromResourceIdType(&CassandraKeyspaceTableId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CassandraKeyspaceTableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CassandraKeyspaceTableId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.CassandraKeyspaceName, ok = input.Parsed["cassandraKeyspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cassandraKeyspaceName", input) + } + + if id.TableName, ok = input.Parsed["tableName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "tableName", input) + } + + return nil +} + +// ValidateCassandraKeyspaceTableID checks that 'input' can be parsed as a Cassandra Keyspace Table ID +func ValidateCassandraKeyspaceTableID(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 := ParseCassandraKeyspaceTableID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cassandra Keyspace Table ID +func (id CassandraKeyspaceTableId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/cassandraKeyspaces/%s/tables/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.CassandraKeyspaceName, id.TableName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cassandra Keyspace Table ID +func (id CassandraKeyspaceTableId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticCassandraKeyspaces", "cassandraKeyspaces", "cassandraKeyspaces"), + resourceids.UserSpecifiedSegment("cassandraKeyspaceName", "cassandraKeyspaceName"), + resourceids.StaticSegment("staticTables", "tables", "tables"), + resourceids.UserSpecifiedSegment("tableName", "tableName"), + } +} + +// String returns a human-readable description of this Cassandra Keyspace Table ID +func (id CassandraKeyspaceTableId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Cassandra Keyspace Name: %q", id.CassandraKeyspaceName), + fmt.Sprintf("Table Name: %q", id.TableName), + } + return fmt.Sprintf("Cassandra Keyspace Table (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_cassandrakeyspacetable_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_cassandrakeyspacetable_test.go new file mode 100644 index 00000000000..de5ca96190f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_cassandrakeyspacetable_test.go @@ -0,0 +1,372 @@ +package cosmosdb + +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 = &CassandraKeyspaceTableId{} + +func TestNewCassandraKeyspaceTableID(t *testing.T) { + id := NewCassandraKeyspaceTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "cassandraKeyspaceName", "tableName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.CassandraKeyspaceName != "cassandraKeyspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'CassandraKeyspaceName'", id.CassandraKeyspaceName, "cassandraKeyspaceName") + } + + if id.TableName != "tableName" { + t.Fatalf("Expected %q but got %q for Segment 'TableName'", id.TableName, "tableName") + } +} + +func TestFormatCassandraKeyspaceTableID(t *testing.T) { + actual := NewCassandraKeyspaceTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "cassandraKeyspaceName", "tableName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/cassandraKeyspaces/cassandraKeyspaceName/tables/tableName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCassandraKeyspaceTableID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CassandraKeyspaceTableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/cassandraKeyspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/cassandraKeyspaces/cassandraKeyspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/cassandraKeyspaces/cassandraKeyspaceName/tables", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/cassandraKeyspaces/cassandraKeyspaceName/tables/tableName", + Expected: &CassandraKeyspaceTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + CassandraKeyspaceName: "cassandraKeyspaceName", + TableName: "tableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/cassandraKeyspaces/cassandraKeyspaceName/tables/tableName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCassandraKeyspaceTableID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.CassandraKeyspaceName != v.Expected.CassandraKeyspaceName { + t.Fatalf("Expected %q but got %q for CassandraKeyspaceName", v.Expected.CassandraKeyspaceName, actual.CassandraKeyspaceName) + } + + if actual.TableName != v.Expected.TableName { + t.Fatalf("Expected %q but got %q for TableName", v.Expected.TableName, actual.TableName) + } + + } +} + +func TestParseCassandraKeyspaceTableIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CassandraKeyspaceTableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/cassandraKeyspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/cAsSaNdRaKeYsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/cassandraKeyspaces/cassandraKeyspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/cAsSaNdRaKeYsPaCeS/cAsSaNdRaKeYsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/cassandraKeyspaces/cassandraKeyspaceName/tables", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/cAsSaNdRaKeYsPaCeS/cAsSaNdRaKeYsPaCeNaMe/tAbLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/cassandraKeyspaces/cassandraKeyspaceName/tables/tableName", + Expected: &CassandraKeyspaceTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + CassandraKeyspaceName: "cassandraKeyspaceName", + TableName: "tableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/cassandraKeyspaces/cassandraKeyspaceName/tables/tableName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/cAsSaNdRaKeYsPaCeS/cAsSaNdRaKeYsPaCeNaMe/tAbLeS/tAbLeNaMe", + Expected: &CassandraKeyspaceTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + CassandraKeyspaceName: "cAsSaNdRaKeYsPaCeNaMe", + TableName: "tAbLeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/cAsSaNdRaKeYsPaCeS/cAsSaNdRaKeYsPaCeNaMe/tAbLeS/tAbLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCassandraKeyspaceTableIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.CassandraKeyspaceName != v.Expected.CassandraKeyspaceName { + t.Fatalf("Expected %q but got %q for CassandraKeyspaceName", v.Expected.CassandraKeyspaceName, actual.CassandraKeyspaceName) + } + + if actual.TableName != v.Expected.TableName { + t.Fatalf("Expected %q but got %q for TableName", v.Expected.TableName, actual.TableName) + } + + } +} + +func TestSegmentsForCassandraKeyspaceTableId(t *testing.T) { + segments := CassandraKeyspaceTableId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CassandraKeyspaceTableId 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/cosmosdb/2024-11-15/cosmosdb/id_clientencryptionkey.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_clientencryptionkey.go new file mode 100644 index 00000000000..1369551418f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_clientencryptionkey.go @@ -0,0 +1,148 @@ +package cosmosdb + +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(&ClientEncryptionKeyId{}) +} + +var _ resourceids.ResourceId = &ClientEncryptionKeyId{} + +// ClientEncryptionKeyId is a struct representing the Resource ID for a Client Encryption Key +type ClientEncryptionKeyId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + SqlDatabaseName string + ClientEncryptionKeyName string +} + +// NewClientEncryptionKeyID returns a new ClientEncryptionKeyId struct +func NewClientEncryptionKeyID(subscriptionId string, resourceGroupName string, databaseAccountName string, sqlDatabaseName string, clientEncryptionKeyName string) ClientEncryptionKeyId { + return ClientEncryptionKeyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + SqlDatabaseName: sqlDatabaseName, + ClientEncryptionKeyName: clientEncryptionKeyName, + } +} + +// ParseClientEncryptionKeyID parses 'input' into a ClientEncryptionKeyId +func ParseClientEncryptionKeyID(input string) (*ClientEncryptionKeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&ClientEncryptionKeyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ClientEncryptionKeyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseClientEncryptionKeyIDInsensitively parses 'input' case-insensitively into a ClientEncryptionKeyId +// note: this method should only be used for API response data and not user input +func ParseClientEncryptionKeyIDInsensitively(input string) (*ClientEncryptionKeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&ClientEncryptionKeyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ClientEncryptionKeyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ClientEncryptionKeyId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.SqlDatabaseName, ok = input.Parsed["sqlDatabaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sqlDatabaseName", input) + } + + if id.ClientEncryptionKeyName, ok = input.Parsed["clientEncryptionKeyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "clientEncryptionKeyName", input) + } + + return nil +} + +// ValidateClientEncryptionKeyID checks that 'input' can be parsed as a Client Encryption Key ID +func ValidateClientEncryptionKeyID(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 := ParseClientEncryptionKeyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Client Encryption Key ID +func (id ClientEncryptionKeyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/sqlDatabases/%s/clientEncryptionKeys/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.SqlDatabaseName, id.ClientEncryptionKeyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Client Encryption Key ID +func (id ClientEncryptionKeyId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticSqlDatabases", "sqlDatabases", "sqlDatabases"), + resourceids.UserSpecifiedSegment("sqlDatabaseName", "sqlDatabaseName"), + resourceids.StaticSegment("staticClientEncryptionKeys", "clientEncryptionKeys", "clientEncryptionKeys"), + resourceids.UserSpecifiedSegment("clientEncryptionKeyName", "clientEncryptionKeyName"), + } +} + +// String returns a human-readable description of this Client Encryption Key ID +func (id ClientEncryptionKeyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Sql Database Name: %q", id.SqlDatabaseName), + fmt.Sprintf("Client Encryption Key Name: %q", id.ClientEncryptionKeyName), + } + return fmt.Sprintf("Client Encryption Key (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_clientencryptionkey_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_clientencryptionkey_test.go new file mode 100644 index 00000000000..e0353898a57 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_clientencryptionkey_test.go @@ -0,0 +1,372 @@ +package cosmosdb + +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 = &ClientEncryptionKeyId{} + +func TestNewClientEncryptionKeyID(t *testing.T) { + id := NewClientEncryptionKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "clientEncryptionKeyName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.SqlDatabaseName != "sqlDatabaseName" { + t.Fatalf("Expected %q but got %q for Segment 'SqlDatabaseName'", id.SqlDatabaseName, "sqlDatabaseName") + } + + if id.ClientEncryptionKeyName != "clientEncryptionKeyName" { + t.Fatalf("Expected %q but got %q for Segment 'ClientEncryptionKeyName'", id.ClientEncryptionKeyName, "clientEncryptionKeyName") + } +} + +func TestFormatClientEncryptionKeyID(t *testing.T) { + actual := NewClientEncryptionKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "clientEncryptionKeyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/clientEncryptionKeys/clientEncryptionKeyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseClientEncryptionKeyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ClientEncryptionKeyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/clientEncryptionKeys", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/clientEncryptionKeys/clientEncryptionKeyName", + Expected: &ClientEncryptionKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + SqlDatabaseName: "sqlDatabaseName", + ClientEncryptionKeyName: "clientEncryptionKeyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/clientEncryptionKeys/clientEncryptionKeyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseClientEncryptionKeyID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.SqlDatabaseName != v.Expected.SqlDatabaseName { + t.Fatalf("Expected %q but got %q for SqlDatabaseName", v.Expected.SqlDatabaseName, actual.SqlDatabaseName) + } + + if actual.ClientEncryptionKeyName != v.Expected.ClientEncryptionKeyName { + t.Fatalf("Expected %q but got %q for ClientEncryptionKeyName", v.Expected.ClientEncryptionKeyName, actual.ClientEncryptionKeyName) + } + + } +} + +func TestParseClientEncryptionKeyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ClientEncryptionKeyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/clientEncryptionKeys", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cLiEnTeNcRyPtIoNkEyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/clientEncryptionKeys/clientEncryptionKeyName", + Expected: &ClientEncryptionKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + SqlDatabaseName: "sqlDatabaseName", + ClientEncryptionKeyName: "clientEncryptionKeyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/clientEncryptionKeys/clientEncryptionKeyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cLiEnTeNcRyPtIoNkEyS/cLiEnTeNcRyPtIoNkEyNaMe", + Expected: &ClientEncryptionKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + SqlDatabaseName: "sQlDaTaBaSeNaMe", + ClientEncryptionKeyName: "cLiEnTeNcRyPtIoNkEyNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cLiEnTeNcRyPtIoNkEyS/cLiEnTeNcRyPtIoNkEyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseClientEncryptionKeyIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.SqlDatabaseName != v.Expected.SqlDatabaseName { + t.Fatalf("Expected %q but got %q for SqlDatabaseName", v.Expected.SqlDatabaseName, actual.SqlDatabaseName) + } + + if actual.ClientEncryptionKeyName != v.Expected.ClientEncryptionKeyName { + t.Fatalf("Expected %q but got %q for ClientEncryptionKeyName", v.Expected.ClientEncryptionKeyName, actual.ClientEncryptionKeyName) + } + + } +} + +func TestSegmentsForClientEncryptionKeyId(t *testing.T) { + segments := ClientEncryptionKeyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ClientEncryptionKeyId 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/cosmosdb/2024-11-15/cosmosdb/id_collection.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_collection.go new file mode 100644 index 00000000000..20b1d5d4051 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_collection.go @@ -0,0 +1,148 @@ +package cosmosdb + +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(&CollectionId{}) +} + +var _ resourceids.ResourceId = &CollectionId{} + +// CollectionId is a struct representing the Resource ID for a Collection +type CollectionId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + DatabaseName string + CollectionName string +} + +// NewCollectionID returns a new CollectionId struct +func NewCollectionID(subscriptionId string, resourceGroupName string, databaseAccountName string, databaseName string, collectionName string) CollectionId { + return CollectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + DatabaseName: databaseName, + CollectionName: collectionName, + } +} + +// ParseCollectionID parses 'input' into a CollectionId +func ParseCollectionID(input string) (*CollectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&CollectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CollectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCollectionIDInsensitively parses 'input' case-insensitively into a CollectionId +// note: this method should only be used for API response data and not user input +func ParseCollectionIDInsensitively(input string) (*CollectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&CollectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CollectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CollectionId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.DatabaseName, ok = input.Parsed["databaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseName", input) + } + + if id.CollectionName, ok = input.Parsed["collectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "collectionName", input) + } + + return nil +} + +// ValidateCollectionID checks that 'input' can be parsed as a Collection ID +func ValidateCollectionID(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 := ParseCollectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Collection ID +func (id CollectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/databases/%s/collections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.DatabaseName, id.CollectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Collection ID +func (id CollectionId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticDatabases", "databases", "databases"), + resourceids.UserSpecifiedSegment("databaseName", "databaseName"), + resourceids.StaticSegment("staticCollections", "collections", "collections"), + resourceids.UserSpecifiedSegment("collectionName", "collectionName"), + } +} + +// String returns a human-readable description of this Collection ID +func (id CollectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Database Name: %q", id.DatabaseName), + fmt.Sprintf("Collection Name: %q", id.CollectionName), + } + return fmt.Sprintf("Collection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_collection_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_collection_test.go new file mode 100644 index 00000000000..5d25b21a81e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_collection_test.go @@ -0,0 +1,372 @@ +package cosmosdb + +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 = &CollectionId{} + +func TestNewCollectionID(t *testing.T) { + id := NewCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "databaseName", "collectionName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.DatabaseName != "databaseName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseName'", id.DatabaseName, "databaseName") + } + + if id.CollectionName != "collectionName" { + t.Fatalf("Expected %q but got %q for Segment 'CollectionName'", id.CollectionName, "collectionName") + } +} + +func TestFormatCollectionID(t *testing.T) { + actual := NewCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "databaseName", "collectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName/collections/collectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCollectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CollectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName/collections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName/collections/collectionName", + Expected: &CollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + DatabaseName: "databaseName", + CollectionName: "collectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName/collections/collectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCollectionID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.DatabaseName != v.Expected.DatabaseName { + t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) + } + + if actual.CollectionName != v.Expected.CollectionName { + t.Fatalf("Expected %q but got %q for CollectionName", v.Expected.CollectionName, actual.CollectionName) + } + + } +} + +func TestParseCollectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CollectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/dAtAbAsEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/dAtAbAsEs/dAtAbAsEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName/collections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/dAtAbAsEs/dAtAbAsEnAmE/cOlLeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName/collections/collectionName", + Expected: &CollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + DatabaseName: "databaseName", + CollectionName: "collectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName/collections/collectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/dAtAbAsEs/dAtAbAsEnAmE/cOlLeCtIoNs/cOlLeCtIoNnAmE", + Expected: &CollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + DatabaseName: "dAtAbAsEnAmE", + CollectionName: "cOlLeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/dAtAbAsEs/dAtAbAsEnAmE/cOlLeCtIoNs/cOlLeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCollectionIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.DatabaseName != v.Expected.DatabaseName { + t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) + } + + if actual.CollectionName != v.Expected.CollectionName { + t.Fatalf("Expected %q but got %q for CollectionName", v.Expected.CollectionName, actual.CollectionName) + } + + } +} + +func TestSegmentsForCollectionId(t *testing.T) { + segments := CollectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CollectionId 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/cosmosdb/2024-11-15/cosmosdb/id_collectionpartitionkeyrangeid.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_collectionpartitionkeyrangeid.go new file mode 100644 index 00000000000..a8f1146d844 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_collectionpartitionkeyrangeid.go @@ -0,0 +1,166 @@ +package cosmosdb + +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(&CollectionPartitionKeyRangeIdId{}) +} + +var _ resourceids.ResourceId = &CollectionPartitionKeyRangeIdId{} + +// CollectionPartitionKeyRangeIdId is a struct representing the Resource ID for a Collection Partition Key Range Id +type CollectionPartitionKeyRangeIdId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + RegionName string + DatabaseName string + CollectionName string + PartitionKeyRangeId string +} + +// NewCollectionPartitionKeyRangeIdID returns a new CollectionPartitionKeyRangeIdId struct +func NewCollectionPartitionKeyRangeIdID(subscriptionId string, resourceGroupName string, databaseAccountName string, regionName string, databaseName string, collectionName string, partitionKeyRangeId string) CollectionPartitionKeyRangeIdId { + return CollectionPartitionKeyRangeIdId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + RegionName: regionName, + DatabaseName: databaseName, + CollectionName: collectionName, + PartitionKeyRangeId: partitionKeyRangeId, + } +} + +// ParseCollectionPartitionKeyRangeIdID parses 'input' into a CollectionPartitionKeyRangeIdId +func ParseCollectionPartitionKeyRangeIdID(input string) (*CollectionPartitionKeyRangeIdId, error) { + parser := resourceids.NewParserFromResourceIdType(&CollectionPartitionKeyRangeIdId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CollectionPartitionKeyRangeIdId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCollectionPartitionKeyRangeIdIDInsensitively parses 'input' case-insensitively into a CollectionPartitionKeyRangeIdId +// note: this method should only be used for API response data and not user input +func ParseCollectionPartitionKeyRangeIdIDInsensitively(input string) (*CollectionPartitionKeyRangeIdId, error) { + parser := resourceids.NewParserFromResourceIdType(&CollectionPartitionKeyRangeIdId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CollectionPartitionKeyRangeIdId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CollectionPartitionKeyRangeIdId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.RegionName, ok = input.Parsed["regionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "regionName", input) + } + + if id.DatabaseName, ok = input.Parsed["databaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseName", input) + } + + if id.CollectionName, ok = input.Parsed["collectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "collectionName", input) + } + + if id.PartitionKeyRangeId, ok = input.Parsed["partitionKeyRangeId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "partitionKeyRangeId", input) + } + + return nil +} + +// ValidateCollectionPartitionKeyRangeIdID checks that 'input' can be parsed as a Collection Partition Key Range Id ID +func ValidateCollectionPartitionKeyRangeIdID(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 := ParseCollectionPartitionKeyRangeIdID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Collection Partition Key Range Id ID +func (id CollectionPartitionKeyRangeIdId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/region/%s/databases/%s/collections/%s/partitionKeyRangeId/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.RegionName, id.DatabaseName, id.CollectionName, id.PartitionKeyRangeId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Collection Partition Key Range Id ID +func (id CollectionPartitionKeyRangeIdId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticRegion", "region", "region"), + resourceids.UserSpecifiedSegment("regionName", "regionName"), + resourceids.StaticSegment("staticDatabases", "databases", "databases"), + resourceids.UserSpecifiedSegment("databaseName", "databaseName"), + resourceids.StaticSegment("staticCollections", "collections", "collections"), + resourceids.UserSpecifiedSegment("collectionName", "collectionName"), + resourceids.StaticSegment("staticPartitionKeyRangeId", "partitionKeyRangeId", "partitionKeyRangeId"), + resourceids.UserSpecifiedSegment("partitionKeyRangeId", "partitionKeyRangeId"), + } +} + +// String returns a human-readable description of this Collection Partition Key Range Id ID +func (id CollectionPartitionKeyRangeIdId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Region Name: %q", id.RegionName), + fmt.Sprintf("Database Name: %q", id.DatabaseName), + fmt.Sprintf("Collection Name: %q", id.CollectionName), + fmt.Sprintf("Partition Key Range: %q", id.PartitionKeyRangeId), + } + return fmt.Sprintf("Collection Partition Key Range Id (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_collectionpartitionkeyrangeid_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_collectionpartitionkeyrangeid_test.go new file mode 100644 index 00000000000..7a4dd109319 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_collectionpartitionkeyrangeid_test.go @@ -0,0 +1,462 @@ +package cosmosdb + +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 = &CollectionPartitionKeyRangeIdId{} + +func TestNewCollectionPartitionKeyRangeIdID(t *testing.T) { + id := NewCollectionPartitionKeyRangeIdID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "regionName", "databaseName", "collectionName", "partitionKeyRangeId") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.RegionName != "regionName" { + t.Fatalf("Expected %q but got %q for Segment 'RegionName'", id.RegionName, "regionName") + } + + if id.DatabaseName != "databaseName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseName'", id.DatabaseName, "databaseName") + } + + if id.CollectionName != "collectionName" { + t.Fatalf("Expected %q but got %q for Segment 'CollectionName'", id.CollectionName, "collectionName") + } + + if id.PartitionKeyRangeId != "partitionKeyRangeId" { + t.Fatalf("Expected %q but got %q for Segment 'PartitionKeyRangeId'", id.PartitionKeyRangeId, "partitionKeyRangeId") + } +} + +func TestFormatCollectionPartitionKeyRangeIdID(t *testing.T) { + actual := NewCollectionPartitionKeyRangeIdID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "regionName", "databaseName", "collectionName", "partitionKeyRangeId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases/databaseName/collections/collectionName/partitionKeyRangeId/partitionKeyRangeId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCollectionPartitionKeyRangeIdID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CollectionPartitionKeyRangeIdId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases/databaseName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases/databaseName/collections", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases/databaseName/collections/collectionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases/databaseName/collections/collectionName/partitionKeyRangeId", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases/databaseName/collections/collectionName/partitionKeyRangeId/partitionKeyRangeId", + Expected: &CollectionPartitionKeyRangeIdId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + RegionName: "regionName", + DatabaseName: "databaseName", + CollectionName: "collectionName", + PartitionKeyRangeId: "partitionKeyRangeId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases/databaseName/collections/collectionName/partitionKeyRangeId/partitionKeyRangeId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCollectionPartitionKeyRangeIdID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.RegionName != v.Expected.RegionName { + t.Fatalf("Expected %q but got %q for RegionName", v.Expected.RegionName, actual.RegionName) + } + + if actual.DatabaseName != v.Expected.DatabaseName { + t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) + } + + if actual.CollectionName != v.Expected.CollectionName { + t.Fatalf("Expected %q but got %q for CollectionName", v.Expected.CollectionName, actual.CollectionName) + } + + if actual.PartitionKeyRangeId != v.Expected.PartitionKeyRangeId { + t.Fatalf("Expected %q but got %q for PartitionKeyRangeId", v.Expected.PartitionKeyRangeId, actual.PartitionKeyRangeId) + } + + } +} + +func TestParseCollectionPartitionKeyRangeIdIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CollectionPartitionKeyRangeIdId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/rEgIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/rEgIoN/rEgIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/rEgIoN/rEgIoNnAmE/dAtAbAsEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases/databaseName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/rEgIoN/rEgIoNnAmE/dAtAbAsEs/dAtAbAsEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases/databaseName/collections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/rEgIoN/rEgIoNnAmE/dAtAbAsEs/dAtAbAsEnAmE/cOlLeCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases/databaseName/collections/collectionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/rEgIoN/rEgIoNnAmE/dAtAbAsEs/dAtAbAsEnAmE/cOlLeCtIoNs/cOlLeCtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases/databaseName/collections/collectionName/partitionKeyRangeId", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/rEgIoN/rEgIoNnAmE/dAtAbAsEs/dAtAbAsEnAmE/cOlLeCtIoNs/cOlLeCtIoNnAmE/pArTiTiOnKeYrAnGeId", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases/databaseName/collections/collectionName/partitionKeyRangeId/partitionKeyRangeId", + Expected: &CollectionPartitionKeyRangeIdId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + RegionName: "regionName", + DatabaseName: "databaseName", + CollectionName: "collectionName", + PartitionKeyRangeId: "partitionKeyRangeId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases/databaseName/collections/collectionName/partitionKeyRangeId/partitionKeyRangeId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/rEgIoN/rEgIoNnAmE/dAtAbAsEs/dAtAbAsEnAmE/cOlLeCtIoNs/cOlLeCtIoNnAmE/pArTiTiOnKeYrAnGeId/pArTiTiOnKeYrAnGeId", + Expected: &CollectionPartitionKeyRangeIdId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + RegionName: "rEgIoNnAmE", + DatabaseName: "dAtAbAsEnAmE", + CollectionName: "cOlLeCtIoNnAmE", + PartitionKeyRangeId: "pArTiTiOnKeYrAnGeId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/rEgIoN/rEgIoNnAmE/dAtAbAsEs/dAtAbAsEnAmE/cOlLeCtIoNs/cOlLeCtIoNnAmE/pArTiTiOnKeYrAnGeId/pArTiTiOnKeYrAnGeId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCollectionPartitionKeyRangeIdIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.RegionName != v.Expected.RegionName { + t.Fatalf("Expected %q but got %q for RegionName", v.Expected.RegionName, actual.RegionName) + } + + if actual.DatabaseName != v.Expected.DatabaseName { + t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) + } + + if actual.CollectionName != v.Expected.CollectionName { + t.Fatalf("Expected %q but got %q for CollectionName", v.Expected.CollectionName, actual.CollectionName) + } + + if actual.PartitionKeyRangeId != v.Expected.PartitionKeyRangeId { + t.Fatalf("Expected %q but got %q for PartitionKeyRangeId", v.Expected.PartitionKeyRangeId, actual.PartitionKeyRangeId) + } + + } +} + +func TestSegmentsForCollectionPartitionKeyRangeIdId(t *testing.T) { + segments := CollectionPartitionKeyRangeIdId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CollectionPartitionKeyRangeIdId 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/cosmosdb/2024-11-15/cosmosdb/id_container.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_container.go new file mode 100644 index 00000000000..52411ec0fb4 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_container.go @@ -0,0 +1,148 @@ +package cosmosdb + +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(&ContainerId{}) +} + +var _ resourceids.ResourceId = &ContainerId{} + +// ContainerId is a struct representing the Resource ID for a Container +type ContainerId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + SqlDatabaseName string + ContainerName string +} + +// NewContainerID returns a new ContainerId struct +func NewContainerID(subscriptionId string, resourceGroupName string, databaseAccountName string, sqlDatabaseName string, containerName string) ContainerId { + return ContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + SqlDatabaseName: sqlDatabaseName, + ContainerName: containerName, + } +} + +// ParseContainerID parses 'input' into a ContainerId +func ParseContainerID(input string) (*ContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseContainerIDInsensitively parses 'input' case-insensitively into a ContainerId +// note: this method should only be used for API response data and not user input +func ParseContainerIDInsensitively(input string) (*ContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ContainerId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.SqlDatabaseName, ok = input.Parsed["sqlDatabaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sqlDatabaseName", input) + } + + if id.ContainerName, ok = input.Parsed["containerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerName", input) + } + + return nil +} + +// ValidateContainerID checks that 'input' can be parsed as a Container ID +func ValidateContainerID(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 := ParseContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Container ID +func (id ContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/sqlDatabases/%s/containers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Container ID +func (id ContainerId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticSqlDatabases", "sqlDatabases", "sqlDatabases"), + resourceids.UserSpecifiedSegment("sqlDatabaseName", "sqlDatabaseName"), + resourceids.StaticSegment("staticContainers", "containers", "containers"), + resourceids.UserSpecifiedSegment("containerName", "containerName"), + } +} + +// String returns a human-readable description of this Container ID +func (id ContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Sql Database Name: %q", id.SqlDatabaseName), + fmt.Sprintf("Container Name: %q", id.ContainerName), + } + return fmt.Sprintf("Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_container_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_container_test.go new file mode 100644 index 00000000000..f6673f4842c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_container_test.go @@ -0,0 +1,372 @@ +package cosmosdb + +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 = &ContainerId{} + +func TestNewContainerID(t *testing.T) { + id := NewContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.SqlDatabaseName != "sqlDatabaseName" { + t.Fatalf("Expected %q but got %q for Segment 'SqlDatabaseName'", id.SqlDatabaseName, "sqlDatabaseName") + } + + if id.ContainerName != "containerName" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerName'", id.ContainerName, "containerName") + } +} + +func TestFormatContainerID(t *testing.T) { + actual := NewContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName", + Expected: &ContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + SqlDatabaseName: "sqlDatabaseName", + ContainerName: "containerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContainerID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.SqlDatabaseName != v.Expected.SqlDatabaseName { + t.Fatalf("Expected %q but got %q for SqlDatabaseName", v.Expected.SqlDatabaseName, actual.SqlDatabaseName) + } + + if actual.ContainerName != v.Expected.ContainerName { + t.Fatalf("Expected %q but got %q for ContainerName", v.Expected.ContainerName, actual.ContainerName) + } + + } +} + +func TestParseContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cOnTaInErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName", + Expected: &ContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + SqlDatabaseName: "sqlDatabaseName", + ContainerName: "containerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cOnTaInErS/cOnTaInErNaMe", + Expected: &ContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + SqlDatabaseName: "sQlDaTaBaSeNaMe", + ContainerName: "cOnTaInErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cOnTaInErS/cOnTaInErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContainerIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.SqlDatabaseName != v.Expected.SqlDatabaseName { + t.Fatalf("Expected %q but got %q for SqlDatabaseName", v.Expected.SqlDatabaseName, actual.SqlDatabaseName) + } + + if actual.ContainerName != v.Expected.ContainerName { + t.Fatalf("Expected %q but got %q for ContainerName", v.Expected.ContainerName, actual.ContainerName) + } + + } +} + +func TestSegmentsForContainerId(t *testing.T) { + segments := ContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ContainerId 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/cosmosdb/2024-11-15/cosmosdb/id_database.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_database.go new file mode 100644 index 00000000000..c73ee48b681 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_database.go @@ -0,0 +1,139 @@ +package cosmosdb + +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(&DatabaseId{}) +} + +var _ resourceids.ResourceId = &DatabaseId{} + +// DatabaseId is a struct representing the Resource ID for a Database +type DatabaseId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + DatabaseName string +} + +// NewDatabaseID returns a new DatabaseId struct +func NewDatabaseID(subscriptionId string, resourceGroupName string, databaseAccountName string, databaseName string) DatabaseId { + return DatabaseId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + DatabaseName: databaseName, + } +} + +// ParseDatabaseID parses 'input' into a DatabaseId +func ParseDatabaseID(input string) (*DatabaseId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDatabaseIDInsensitively parses 'input' case-insensitively into a DatabaseId +// note: this method should only be used for API response data and not user input +func ParseDatabaseIDInsensitively(input string) (*DatabaseId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DatabaseId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.DatabaseName, ok = input.Parsed["databaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseName", input) + } + + return nil +} + +// ValidateDatabaseID checks that 'input' can be parsed as a Database ID +func ValidateDatabaseID(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 := ParseDatabaseID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Database ID +func (id DatabaseId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/databases/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.DatabaseName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Database ID +func (id DatabaseId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticDatabases", "databases", "databases"), + resourceids.UserSpecifiedSegment("databaseName", "databaseName"), + } +} + +// String returns a human-readable description of this Database ID +func (id DatabaseId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Database Name: %q", id.DatabaseName), + } + return fmt.Sprintf("Database (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_database_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_database_test.go new file mode 100644 index 00000000000..c1750285bd3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_database_test.go @@ -0,0 +1,327 @@ +package cosmosdb + +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 = &DatabaseId{} + +func TestNewDatabaseID(t *testing.T) { + id := NewDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "databaseName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.DatabaseName != "databaseName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseName'", id.DatabaseName, "databaseName") + } +} + +func TestFormatDatabaseID(t *testing.T) { + actual := NewDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "databaseName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDatabaseID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName", + Expected: &DatabaseId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + DatabaseName: "databaseName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.DatabaseName != v.Expected.DatabaseName { + t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) + } + + } +} + +func TestParseDatabaseIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/dAtAbAsEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName", + Expected: &DatabaseId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + DatabaseName: "databaseName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/dAtAbAsEs/dAtAbAsEnAmE", + Expected: &DatabaseId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + DatabaseName: "dAtAbAsEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/dAtAbAsEs/dAtAbAsEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.DatabaseName != v.Expected.DatabaseName { + t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) + } + + } +} + +func TestSegmentsForDatabaseId(t *testing.T) { + segments := DatabaseId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DatabaseId 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/cosmosdb/2024-11-15/cosmosdb/id_databaseaccount.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_databaseaccount.go new file mode 100644 index 00000000000..dfad7d15d85 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_databaseaccount.go @@ -0,0 +1,130 @@ +package cosmosdb + +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(&DatabaseAccountId{}) +} + +var _ resourceids.ResourceId = &DatabaseAccountId{} + +// DatabaseAccountId is a struct representing the Resource ID for a Database Account +type DatabaseAccountId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string +} + +// NewDatabaseAccountID returns a new DatabaseAccountId struct +func NewDatabaseAccountID(subscriptionId string, resourceGroupName string, databaseAccountName string) DatabaseAccountId { + return DatabaseAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + } +} + +// ParseDatabaseAccountID parses 'input' into a DatabaseAccountId +func ParseDatabaseAccountID(input string) (*DatabaseAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDatabaseAccountIDInsensitively parses 'input' case-insensitively into a DatabaseAccountId +// note: this method should only be used for API response data and not user input +func ParseDatabaseAccountIDInsensitively(input string) (*DatabaseAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DatabaseAccountId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + return nil +} + +// ValidateDatabaseAccountID checks that 'input' can be parsed as a Database Account ID +func ValidateDatabaseAccountID(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 := ParseDatabaseAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Database Account ID +func (id DatabaseAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Database Account ID +func (id DatabaseAccountId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + } +} + +// String returns a human-readable description of this Database Account ID +func (id DatabaseAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + } + return fmt.Sprintf("Database Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_databaseaccount_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_databaseaccount_test.go new file mode 100644 index 00000000000..d8132b226fc --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_databaseaccount_test.go @@ -0,0 +1,282 @@ +package cosmosdb + +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 = &DatabaseAccountId{} + +func TestNewDatabaseAccountID(t *testing.T) { + id := NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } +} + +func TestFormatDatabaseAccountID(t *testing.T) { + actual := NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDatabaseAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Expected: &DatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseAccountID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + } +} + +func TestParseDatabaseAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Expected: &DatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Expected: &DatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseAccountIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + } +} + +func TestSegmentsForDatabaseAccountId(t *testing.T) { + segments := DatabaseAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DatabaseAccountId 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/cosmosdb/2024-11-15/cosmosdb/id_databaseaccountname.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_databaseaccountname.go new file mode 100644 index 00000000000..46c015d7769 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_databaseaccountname.go @@ -0,0 +1,112 @@ +package cosmosdb + +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(&DatabaseAccountNameId{}) +} + +var _ resourceids.ResourceId = &DatabaseAccountNameId{} + +// DatabaseAccountNameId is a struct representing the Resource ID for a Database Account Name +type DatabaseAccountNameId struct { + DatabaseAccountName string +} + +// NewDatabaseAccountNameID returns a new DatabaseAccountNameId struct +func NewDatabaseAccountNameID(databaseAccountName string) DatabaseAccountNameId { + return DatabaseAccountNameId{ + DatabaseAccountName: databaseAccountName, + } +} + +// ParseDatabaseAccountNameID parses 'input' into a DatabaseAccountNameId +func ParseDatabaseAccountNameID(input string) (*DatabaseAccountNameId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseAccountNameId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseAccountNameId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDatabaseAccountNameIDInsensitively parses 'input' case-insensitively into a DatabaseAccountNameId +// note: this method should only be used for API response data and not user input +func ParseDatabaseAccountNameIDInsensitively(input string) (*DatabaseAccountNameId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseAccountNameId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseAccountNameId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DatabaseAccountNameId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + return nil +} + +// ValidateDatabaseAccountNameID checks that 'input' can be parsed as a Database Account Name ID +func ValidateDatabaseAccountNameID(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 := ParseDatabaseAccountNameID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Database Account Name ID +func (id DatabaseAccountNameId) ID() string { + fmtString := "/providers/Microsoft.DocumentDB/databaseAccountNames/%s" + return fmt.Sprintf(fmtString, id.DatabaseAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Database Account Name ID +func (id DatabaseAccountNameId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccountNames", "databaseAccountNames", "databaseAccountNames"), + resourceids.UserSpecifiedSegment("databaseAccountName", "accountName"), + } +} + +// String returns a human-readable description of this Database Account Name ID +func (id DatabaseAccountNameId) String() string { + components := []string{ + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + } + return fmt.Sprintf("Database Account Name (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_databaseaccountname_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_databaseaccountname_test.go new file mode 100644 index 00000000000..28d7390e914 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_databaseaccountname_test.go @@ -0,0 +1,192 @@ +package cosmosdb + +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 = &DatabaseAccountNameId{} + +func TestNewDatabaseAccountNameID(t *testing.T) { + id := NewDatabaseAccountNameID("accountName") + + if id.DatabaseAccountName != "accountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "accountName") + } +} + +func TestFormatDatabaseAccountNameID(t *testing.T) { + actual := NewDatabaseAccountNameID("accountName").ID() + expected := "/providers/Microsoft.DocumentDB/databaseAccountNames/accountName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDatabaseAccountNameID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseAccountNameId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.DocumentDB/databaseAccountNames", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.DocumentDB/databaseAccountNames/accountName", + Expected: &DatabaseAccountNameId{ + DatabaseAccountName: "accountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.DocumentDB/databaseAccountNames/accountName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseAccountNameID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + } +} + +func TestParseDatabaseAccountNameIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseAccountNameId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.DocumentDB/databaseAccountNames", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtNaMeS", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.DocumentDB/databaseAccountNames/accountName", + Expected: &DatabaseAccountNameId{ + DatabaseAccountName: "accountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.DocumentDB/databaseAccountNames/accountName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtNaMeS/aCcOuNtNaMe", + Expected: &DatabaseAccountNameId{ + DatabaseAccountName: "aCcOuNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtNaMeS/aCcOuNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseAccountNameIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + } +} + +func TestSegmentsForDatabaseAccountNameId(t *testing.T) { + segments := DatabaseAccountNameId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DatabaseAccountNameId 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/cosmosdb/2024-11-15/cosmosdb/id_databasecollection.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_databasecollection.go new file mode 100644 index 00000000000..81c3be1f181 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_databasecollection.go @@ -0,0 +1,157 @@ +package cosmosdb + +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(&DatabaseCollectionId{}) +} + +var _ resourceids.ResourceId = &DatabaseCollectionId{} + +// DatabaseCollectionId is a struct representing the Resource ID for a Database Collection +type DatabaseCollectionId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + RegionName string + DatabaseName string + CollectionName string +} + +// NewDatabaseCollectionID returns a new DatabaseCollectionId struct +func NewDatabaseCollectionID(subscriptionId string, resourceGroupName string, databaseAccountName string, regionName string, databaseName string, collectionName string) DatabaseCollectionId { + return DatabaseCollectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + RegionName: regionName, + DatabaseName: databaseName, + CollectionName: collectionName, + } +} + +// ParseDatabaseCollectionID parses 'input' into a DatabaseCollectionId +func ParseDatabaseCollectionID(input string) (*DatabaseCollectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseCollectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseCollectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDatabaseCollectionIDInsensitively parses 'input' case-insensitively into a DatabaseCollectionId +// note: this method should only be used for API response data and not user input +func ParseDatabaseCollectionIDInsensitively(input string) (*DatabaseCollectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseCollectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseCollectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DatabaseCollectionId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.RegionName, ok = input.Parsed["regionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "regionName", input) + } + + if id.DatabaseName, ok = input.Parsed["databaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseName", input) + } + + if id.CollectionName, ok = input.Parsed["collectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "collectionName", input) + } + + return nil +} + +// ValidateDatabaseCollectionID checks that 'input' can be parsed as a Database Collection ID +func ValidateDatabaseCollectionID(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 := ParseDatabaseCollectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Database Collection ID +func (id DatabaseCollectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/region/%s/databases/%s/collections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.RegionName, id.DatabaseName, id.CollectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Database Collection ID +func (id DatabaseCollectionId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticRegion", "region", "region"), + resourceids.UserSpecifiedSegment("regionName", "regionName"), + resourceids.StaticSegment("staticDatabases", "databases", "databases"), + resourceids.UserSpecifiedSegment("databaseName", "databaseName"), + resourceids.StaticSegment("staticCollections", "collections", "collections"), + resourceids.UserSpecifiedSegment("collectionName", "collectionName"), + } +} + +// String returns a human-readable description of this Database Collection ID +func (id DatabaseCollectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Region Name: %q", id.RegionName), + fmt.Sprintf("Database Name: %q", id.DatabaseName), + fmt.Sprintf("Collection Name: %q", id.CollectionName), + } + return fmt.Sprintf("Database Collection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_databasecollection_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_databasecollection_test.go new file mode 100644 index 00000000000..8d0ed01afa3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_databasecollection_test.go @@ -0,0 +1,417 @@ +package cosmosdb + +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 = &DatabaseCollectionId{} + +func TestNewDatabaseCollectionID(t *testing.T) { + id := NewDatabaseCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "regionName", "databaseName", "collectionName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.RegionName != "regionName" { + t.Fatalf("Expected %q but got %q for Segment 'RegionName'", id.RegionName, "regionName") + } + + if id.DatabaseName != "databaseName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseName'", id.DatabaseName, "databaseName") + } + + if id.CollectionName != "collectionName" { + t.Fatalf("Expected %q but got %q for Segment 'CollectionName'", id.CollectionName, "collectionName") + } +} + +func TestFormatDatabaseCollectionID(t *testing.T) { + actual := NewDatabaseCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "regionName", "databaseName", "collectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases/databaseName/collections/collectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDatabaseCollectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseCollectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases/databaseName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases/databaseName/collections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases/databaseName/collections/collectionName", + Expected: &DatabaseCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + RegionName: "regionName", + DatabaseName: "databaseName", + CollectionName: "collectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases/databaseName/collections/collectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseCollectionID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.RegionName != v.Expected.RegionName { + t.Fatalf("Expected %q but got %q for RegionName", v.Expected.RegionName, actual.RegionName) + } + + if actual.DatabaseName != v.Expected.DatabaseName { + t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) + } + + if actual.CollectionName != v.Expected.CollectionName { + t.Fatalf("Expected %q but got %q for CollectionName", v.Expected.CollectionName, actual.CollectionName) + } + + } +} + +func TestParseDatabaseCollectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseCollectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/rEgIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/rEgIoN/rEgIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/rEgIoN/rEgIoNnAmE/dAtAbAsEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases/databaseName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/rEgIoN/rEgIoNnAmE/dAtAbAsEs/dAtAbAsEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases/databaseName/collections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/rEgIoN/rEgIoNnAmE/dAtAbAsEs/dAtAbAsEnAmE/cOlLeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases/databaseName/collections/collectionName", + Expected: &DatabaseCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + RegionName: "regionName", + DatabaseName: "databaseName", + CollectionName: "collectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/databases/databaseName/collections/collectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/rEgIoN/rEgIoNnAmE/dAtAbAsEs/dAtAbAsEnAmE/cOlLeCtIoNs/cOlLeCtIoNnAmE", + Expected: &DatabaseCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + RegionName: "rEgIoNnAmE", + DatabaseName: "dAtAbAsEnAmE", + CollectionName: "cOlLeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/rEgIoN/rEgIoNnAmE/dAtAbAsEs/dAtAbAsEnAmE/cOlLeCtIoNs/cOlLeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseCollectionIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.RegionName != v.Expected.RegionName { + t.Fatalf("Expected %q but got %q for RegionName", v.Expected.RegionName, actual.RegionName) + } + + if actual.DatabaseName != v.Expected.DatabaseName { + t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) + } + + if actual.CollectionName != v.Expected.CollectionName { + t.Fatalf("Expected %q but got %q for CollectionName", v.Expected.CollectionName, actual.CollectionName) + } + + } +} + +func TestSegmentsForDatabaseCollectionId(t *testing.T) { + segments := DatabaseCollectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DatabaseCollectionId 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/cosmosdb/2024-11-15/cosmosdb/id_graph.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_graph.go new file mode 100644 index 00000000000..e520754fd71 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_graph.go @@ -0,0 +1,148 @@ +package cosmosdb + +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(&GraphId{}) +} + +var _ resourceids.ResourceId = &GraphId{} + +// GraphId is a struct representing the Resource ID for a Graph +type GraphId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + GremlinDatabaseName string + GraphName string +} + +// NewGraphID returns a new GraphId struct +func NewGraphID(subscriptionId string, resourceGroupName string, databaseAccountName string, gremlinDatabaseName string, graphName string) GraphId { + return GraphId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + GremlinDatabaseName: gremlinDatabaseName, + GraphName: graphName, + } +} + +// ParseGraphID parses 'input' into a GraphId +func ParseGraphID(input string) (*GraphId, error) { + parser := resourceids.NewParserFromResourceIdType(&GraphId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GraphId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseGraphIDInsensitively parses 'input' case-insensitively into a GraphId +// note: this method should only be used for API response data and not user input +func ParseGraphIDInsensitively(input string) (*GraphId, error) { + parser := resourceids.NewParserFromResourceIdType(&GraphId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GraphId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *GraphId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.GremlinDatabaseName, ok = input.Parsed["gremlinDatabaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "gremlinDatabaseName", input) + } + + if id.GraphName, ok = input.Parsed["graphName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "graphName", input) + } + + return nil +} + +// ValidateGraphID checks that 'input' can be parsed as a Graph ID +func ValidateGraphID(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 := ParseGraphID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Graph ID +func (id GraphId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/gremlinDatabases/%s/graphs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.GremlinDatabaseName, id.GraphName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Graph ID +func (id GraphId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticGremlinDatabases", "gremlinDatabases", "gremlinDatabases"), + resourceids.UserSpecifiedSegment("gremlinDatabaseName", "gremlinDatabaseName"), + resourceids.StaticSegment("staticGraphs", "graphs", "graphs"), + resourceids.UserSpecifiedSegment("graphName", "graphName"), + } +} + +// String returns a human-readable description of this Graph ID +func (id GraphId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Gremlin Database Name: %q", id.GremlinDatabaseName), + fmt.Sprintf("Graph Name: %q", id.GraphName), + } + return fmt.Sprintf("Graph (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_graph_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_graph_test.go new file mode 100644 index 00000000000..1f089c40924 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_graph_test.go @@ -0,0 +1,372 @@ +package cosmosdb + +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 = &GraphId{} + +func TestNewGraphID(t *testing.T) { + id := NewGraphID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "gremlinDatabaseName", "graphName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.GremlinDatabaseName != "gremlinDatabaseName" { + t.Fatalf("Expected %q but got %q for Segment 'GremlinDatabaseName'", id.GremlinDatabaseName, "gremlinDatabaseName") + } + + if id.GraphName != "graphName" { + t.Fatalf("Expected %q but got %q for Segment 'GraphName'", id.GraphName, "graphName") + } +} + +func TestFormatGraphID(t *testing.T) { + actual := NewGraphID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "gremlinDatabaseName", "graphName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases/gremlinDatabaseName/graphs/graphName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseGraphID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GraphId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases/gremlinDatabaseName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases/gremlinDatabaseName/graphs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases/gremlinDatabaseName/graphs/graphName", + Expected: &GraphId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + GremlinDatabaseName: "gremlinDatabaseName", + GraphName: "graphName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases/gremlinDatabaseName/graphs/graphName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGraphID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.GremlinDatabaseName != v.Expected.GremlinDatabaseName { + t.Fatalf("Expected %q but got %q for GremlinDatabaseName", v.Expected.GremlinDatabaseName, actual.GremlinDatabaseName) + } + + if actual.GraphName != v.Expected.GraphName { + t.Fatalf("Expected %q but got %q for GraphName", v.Expected.GraphName, actual.GraphName) + } + + } +} + +func TestParseGraphIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GraphId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/gReMlInDaTaBaSeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases/gremlinDatabaseName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/gReMlInDaTaBaSeS/gReMlInDaTaBaSeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases/gremlinDatabaseName/graphs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/gReMlInDaTaBaSeS/gReMlInDaTaBaSeNaMe/gRaPhS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases/gremlinDatabaseName/graphs/graphName", + Expected: &GraphId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + GremlinDatabaseName: "gremlinDatabaseName", + GraphName: "graphName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases/gremlinDatabaseName/graphs/graphName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/gReMlInDaTaBaSeS/gReMlInDaTaBaSeNaMe/gRaPhS/gRaPhNaMe", + Expected: &GraphId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + GremlinDatabaseName: "gReMlInDaTaBaSeNaMe", + GraphName: "gRaPhNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/gReMlInDaTaBaSeS/gReMlInDaTaBaSeNaMe/gRaPhS/gRaPhNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGraphIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.GremlinDatabaseName != v.Expected.GremlinDatabaseName { + t.Fatalf("Expected %q but got %q for GremlinDatabaseName", v.Expected.GremlinDatabaseName, actual.GremlinDatabaseName) + } + + if actual.GraphName != v.Expected.GraphName { + t.Fatalf("Expected %q but got %q for GraphName", v.Expected.GraphName, actual.GraphName) + } + + } +} + +func TestSegmentsForGraphId(t *testing.T) { + segments := GraphId{}.Segments() + if len(segments) == 0 { + t.Fatalf("GraphId 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/cosmosdb/2024-11-15/cosmosdb/id_gremlindatabase.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_gremlindatabase.go new file mode 100644 index 00000000000..5ef8dfa4e09 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_gremlindatabase.go @@ -0,0 +1,139 @@ +package cosmosdb + +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(&GremlinDatabaseId{}) +} + +var _ resourceids.ResourceId = &GremlinDatabaseId{} + +// GremlinDatabaseId is a struct representing the Resource ID for a Gremlin Database +type GremlinDatabaseId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + GremlinDatabaseName string +} + +// NewGremlinDatabaseID returns a new GremlinDatabaseId struct +func NewGremlinDatabaseID(subscriptionId string, resourceGroupName string, databaseAccountName string, gremlinDatabaseName string) GremlinDatabaseId { + return GremlinDatabaseId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + GremlinDatabaseName: gremlinDatabaseName, + } +} + +// ParseGremlinDatabaseID parses 'input' into a GremlinDatabaseId +func ParseGremlinDatabaseID(input string) (*GremlinDatabaseId, error) { + parser := resourceids.NewParserFromResourceIdType(&GremlinDatabaseId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GremlinDatabaseId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseGremlinDatabaseIDInsensitively parses 'input' case-insensitively into a GremlinDatabaseId +// note: this method should only be used for API response data and not user input +func ParseGremlinDatabaseIDInsensitively(input string) (*GremlinDatabaseId, error) { + parser := resourceids.NewParserFromResourceIdType(&GremlinDatabaseId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GremlinDatabaseId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *GremlinDatabaseId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.GremlinDatabaseName, ok = input.Parsed["gremlinDatabaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "gremlinDatabaseName", input) + } + + return nil +} + +// ValidateGremlinDatabaseID checks that 'input' can be parsed as a Gremlin Database ID +func ValidateGremlinDatabaseID(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 := ParseGremlinDatabaseID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Gremlin Database ID +func (id GremlinDatabaseId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/gremlinDatabases/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.GremlinDatabaseName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Gremlin Database ID +func (id GremlinDatabaseId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticGremlinDatabases", "gremlinDatabases", "gremlinDatabases"), + resourceids.UserSpecifiedSegment("gremlinDatabaseName", "gremlinDatabaseName"), + } +} + +// String returns a human-readable description of this Gremlin Database ID +func (id GremlinDatabaseId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Gremlin Database Name: %q", id.GremlinDatabaseName), + } + return fmt.Sprintf("Gremlin Database (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_gremlindatabase_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_gremlindatabase_test.go new file mode 100644 index 00000000000..a988d8e29ed --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_gremlindatabase_test.go @@ -0,0 +1,327 @@ +package cosmosdb + +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 = &GremlinDatabaseId{} + +func TestNewGremlinDatabaseID(t *testing.T) { + id := NewGremlinDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "gremlinDatabaseName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.GremlinDatabaseName != "gremlinDatabaseName" { + t.Fatalf("Expected %q but got %q for Segment 'GremlinDatabaseName'", id.GremlinDatabaseName, "gremlinDatabaseName") + } +} + +func TestFormatGremlinDatabaseID(t *testing.T) { + actual := NewGremlinDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "gremlinDatabaseName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases/gremlinDatabaseName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseGremlinDatabaseID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GremlinDatabaseId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases/gremlinDatabaseName", + Expected: &GremlinDatabaseId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + GremlinDatabaseName: "gremlinDatabaseName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases/gremlinDatabaseName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGremlinDatabaseID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.GremlinDatabaseName != v.Expected.GremlinDatabaseName { + t.Fatalf("Expected %q but got %q for GremlinDatabaseName", v.Expected.GremlinDatabaseName, actual.GremlinDatabaseName) + } + + } +} + +func TestParseGremlinDatabaseIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GremlinDatabaseId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/gReMlInDaTaBaSeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases/gremlinDatabaseName", + Expected: &GremlinDatabaseId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + GremlinDatabaseName: "gremlinDatabaseName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases/gremlinDatabaseName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/gReMlInDaTaBaSeS/gReMlInDaTaBaSeNaMe", + Expected: &GremlinDatabaseId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + GremlinDatabaseName: "gReMlInDaTaBaSeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/gReMlInDaTaBaSeS/gReMlInDaTaBaSeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGremlinDatabaseIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.GremlinDatabaseName != v.Expected.GremlinDatabaseName { + t.Fatalf("Expected %q but got %q for GremlinDatabaseName", v.Expected.GremlinDatabaseName, actual.GremlinDatabaseName) + } + + } +} + +func TestSegmentsForGremlinDatabaseId(t *testing.T) { + segments := GremlinDatabaseId{}.Segments() + if len(segments) == 0 { + t.Fatalf("GremlinDatabaseId 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/cosmosdb/2024-11-15/cosmosdb/id_location.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_location.go new file mode 100644 index 00000000000..483a412e5c7 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_location.go @@ -0,0 +1,121 @@ +package cosmosdb + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.DocumentDB/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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// 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/cosmosdb/2024-11-15/cosmosdb/id_location_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_location_test.go new file mode 100644 index 00000000000..803c3f2c435 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_location_test.go @@ -0,0 +1,237 @@ +package cosmosdb + +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", "locationName") + + 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 != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/lOcAtIoNs/lOcAtIoNnAmE/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/cosmosdb/2024-11-15/cosmosdb/id_mongodbdatabase.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_mongodbdatabase.go new file mode 100644 index 00000000000..93bc507bbf9 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_mongodbdatabase.go @@ -0,0 +1,139 @@ +package cosmosdb + +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(&MongodbDatabaseId{}) +} + +var _ resourceids.ResourceId = &MongodbDatabaseId{} + +// MongodbDatabaseId is a struct representing the Resource ID for a Mongodb Database +type MongodbDatabaseId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + MongodbDatabaseName string +} + +// NewMongodbDatabaseID returns a new MongodbDatabaseId struct +func NewMongodbDatabaseID(subscriptionId string, resourceGroupName string, databaseAccountName string, mongodbDatabaseName string) MongodbDatabaseId { + return MongodbDatabaseId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + MongodbDatabaseName: mongodbDatabaseName, + } +} + +// ParseMongodbDatabaseID parses 'input' into a MongodbDatabaseId +func ParseMongodbDatabaseID(input string) (*MongodbDatabaseId, error) { + parser := resourceids.NewParserFromResourceIdType(&MongodbDatabaseId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MongodbDatabaseId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMongodbDatabaseIDInsensitively parses 'input' case-insensitively into a MongodbDatabaseId +// note: this method should only be used for API response data and not user input +func ParseMongodbDatabaseIDInsensitively(input string) (*MongodbDatabaseId, error) { + parser := resourceids.NewParserFromResourceIdType(&MongodbDatabaseId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MongodbDatabaseId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MongodbDatabaseId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.MongodbDatabaseName, ok = input.Parsed["mongodbDatabaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "mongodbDatabaseName", input) + } + + return nil +} + +// ValidateMongodbDatabaseID checks that 'input' can be parsed as a Mongodb Database ID +func ValidateMongodbDatabaseID(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 := ParseMongodbDatabaseID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Mongodb Database ID +func (id MongodbDatabaseId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/mongodbDatabases/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.MongodbDatabaseName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Mongodb Database ID +func (id MongodbDatabaseId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticMongodbDatabases", "mongodbDatabases", "mongodbDatabases"), + resourceids.UserSpecifiedSegment("mongodbDatabaseName", "mongodbDatabaseName"), + } +} + +// String returns a human-readable description of this Mongodb Database ID +func (id MongodbDatabaseId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Mongodb Database Name: %q", id.MongodbDatabaseName), + } + return fmt.Sprintf("Mongodb Database (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_mongodbdatabase_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_mongodbdatabase_test.go new file mode 100644 index 00000000000..fbe5814e30c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_mongodbdatabase_test.go @@ -0,0 +1,327 @@ +package cosmosdb + +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 = &MongodbDatabaseId{} + +func TestNewMongodbDatabaseID(t *testing.T) { + id := NewMongodbDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongodbDatabaseName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.MongodbDatabaseName != "mongodbDatabaseName" { + t.Fatalf("Expected %q but got %q for Segment 'MongodbDatabaseName'", id.MongodbDatabaseName, "mongodbDatabaseName") + } +} + +func TestFormatMongodbDatabaseID(t *testing.T) { + actual := NewMongodbDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongodbDatabaseName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases/mongodbDatabaseName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMongodbDatabaseID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MongodbDatabaseId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases/mongodbDatabaseName", + Expected: &MongodbDatabaseId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + MongodbDatabaseName: "mongodbDatabaseName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases/mongodbDatabaseName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMongodbDatabaseID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.MongodbDatabaseName != v.Expected.MongodbDatabaseName { + t.Fatalf("Expected %q but got %q for MongodbDatabaseName", v.Expected.MongodbDatabaseName, actual.MongodbDatabaseName) + } + + } +} + +func TestParseMongodbDatabaseIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MongodbDatabaseId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/mOnGoDbDaTaBaSeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases/mongodbDatabaseName", + Expected: &MongodbDatabaseId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + MongodbDatabaseName: "mongodbDatabaseName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases/mongodbDatabaseName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/mOnGoDbDaTaBaSeS/mOnGoDbDaTaBaSeNaMe", + Expected: &MongodbDatabaseId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + MongodbDatabaseName: "mOnGoDbDaTaBaSeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/mOnGoDbDaTaBaSeS/mOnGoDbDaTaBaSeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMongodbDatabaseIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.MongodbDatabaseName != v.Expected.MongodbDatabaseName { + t.Fatalf("Expected %q but got %q for MongodbDatabaseName", v.Expected.MongodbDatabaseName, actual.MongodbDatabaseName) + } + + } +} + +func TestSegmentsForMongodbDatabaseId(t *testing.T) { + segments := MongodbDatabaseId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MongodbDatabaseId 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/cosmosdb/2024-11-15/cosmosdb/id_mongodbdatabasecollection.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_mongodbdatabasecollection.go new file mode 100644 index 00000000000..8b233638340 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_mongodbdatabasecollection.go @@ -0,0 +1,148 @@ +package cosmosdb + +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(&MongodbDatabaseCollectionId{}) +} + +var _ resourceids.ResourceId = &MongodbDatabaseCollectionId{} + +// MongodbDatabaseCollectionId is a struct representing the Resource ID for a Mongodb Database Collection +type MongodbDatabaseCollectionId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + MongodbDatabaseName string + CollectionName string +} + +// NewMongodbDatabaseCollectionID returns a new MongodbDatabaseCollectionId struct +func NewMongodbDatabaseCollectionID(subscriptionId string, resourceGroupName string, databaseAccountName string, mongodbDatabaseName string, collectionName string) MongodbDatabaseCollectionId { + return MongodbDatabaseCollectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + MongodbDatabaseName: mongodbDatabaseName, + CollectionName: collectionName, + } +} + +// ParseMongodbDatabaseCollectionID parses 'input' into a MongodbDatabaseCollectionId +func ParseMongodbDatabaseCollectionID(input string) (*MongodbDatabaseCollectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&MongodbDatabaseCollectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MongodbDatabaseCollectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMongodbDatabaseCollectionIDInsensitively parses 'input' case-insensitively into a MongodbDatabaseCollectionId +// note: this method should only be used for API response data and not user input +func ParseMongodbDatabaseCollectionIDInsensitively(input string) (*MongodbDatabaseCollectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&MongodbDatabaseCollectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MongodbDatabaseCollectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MongodbDatabaseCollectionId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.MongodbDatabaseName, ok = input.Parsed["mongodbDatabaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "mongodbDatabaseName", input) + } + + if id.CollectionName, ok = input.Parsed["collectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "collectionName", input) + } + + return nil +} + +// ValidateMongodbDatabaseCollectionID checks that 'input' can be parsed as a Mongodb Database Collection ID +func ValidateMongodbDatabaseCollectionID(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 := ParseMongodbDatabaseCollectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Mongodb Database Collection ID +func (id MongodbDatabaseCollectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/mongodbDatabases/%s/collections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.MongodbDatabaseName, id.CollectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Mongodb Database Collection ID +func (id MongodbDatabaseCollectionId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticMongodbDatabases", "mongodbDatabases", "mongodbDatabases"), + resourceids.UserSpecifiedSegment("mongodbDatabaseName", "mongodbDatabaseName"), + resourceids.StaticSegment("staticCollections", "collections", "collections"), + resourceids.UserSpecifiedSegment("collectionName", "collectionName"), + } +} + +// String returns a human-readable description of this Mongodb Database Collection ID +func (id MongodbDatabaseCollectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Mongodb Database Name: %q", id.MongodbDatabaseName), + fmt.Sprintf("Collection Name: %q", id.CollectionName), + } + return fmt.Sprintf("Mongodb Database Collection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_mongodbdatabasecollection_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_mongodbdatabasecollection_test.go new file mode 100644 index 00000000000..96fb623f632 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_mongodbdatabasecollection_test.go @@ -0,0 +1,372 @@ +package cosmosdb + +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 = &MongodbDatabaseCollectionId{} + +func TestNewMongodbDatabaseCollectionID(t *testing.T) { + id := NewMongodbDatabaseCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongodbDatabaseName", "collectionName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.MongodbDatabaseName != "mongodbDatabaseName" { + t.Fatalf("Expected %q but got %q for Segment 'MongodbDatabaseName'", id.MongodbDatabaseName, "mongodbDatabaseName") + } + + if id.CollectionName != "collectionName" { + t.Fatalf("Expected %q but got %q for Segment 'CollectionName'", id.CollectionName, "collectionName") + } +} + +func TestFormatMongodbDatabaseCollectionID(t *testing.T) { + actual := NewMongodbDatabaseCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongodbDatabaseName", "collectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases/mongodbDatabaseName/collections/collectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMongodbDatabaseCollectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MongodbDatabaseCollectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases/mongodbDatabaseName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases/mongodbDatabaseName/collections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases/mongodbDatabaseName/collections/collectionName", + Expected: &MongodbDatabaseCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + MongodbDatabaseName: "mongodbDatabaseName", + CollectionName: "collectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases/mongodbDatabaseName/collections/collectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMongodbDatabaseCollectionID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.MongodbDatabaseName != v.Expected.MongodbDatabaseName { + t.Fatalf("Expected %q but got %q for MongodbDatabaseName", v.Expected.MongodbDatabaseName, actual.MongodbDatabaseName) + } + + if actual.CollectionName != v.Expected.CollectionName { + t.Fatalf("Expected %q but got %q for CollectionName", v.Expected.CollectionName, actual.CollectionName) + } + + } +} + +func TestParseMongodbDatabaseCollectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MongodbDatabaseCollectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/mOnGoDbDaTaBaSeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases/mongodbDatabaseName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/mOnGoDbDaTaBaSeS/mOnGoDbDaTaBaSeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases/mongodbDatabaseName/collections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/mOnGoDbDaTaBaSeS/mOnGoDbDaTaBaSeNaMe/cOlLeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases/mongodbDatabaseName/collections/collectionName", + Expected: &MongodbDatabaseCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + MongodbDatabaseName: "mongodbDatabaseName", + CollectionName: "collectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases/mongodbDatabaseName/collections/collectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/mOnGoDbDaTaBaSeS/mOnGoDbDaTaBaSeNaMe/cOlLeCtIoNs/cOlLeCtIoNnAmE", + Expected: &MongodbDatabaseCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + MongodbDatabaseName: "mOnGoDbDaTaBaSeNaMe", + CollectionName: "cOlLeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/mOnGoDbDaTaBaSeS/mOnGoDbDaTaBaSeNaMe/cOlLeCtIoNs/cOlLeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMongodbDatabaseCollectionIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.MongodbDatabaseName != v.Expected.MongodbDatabaseName { + t.Fatalf("Expected %q but got %q for MongodbDatabaseName", v.Expected.MongodbDatabaseName, actual.MongodbDatabaseName) + } + + if actual.CollectionName != v.Expected.CollectionName { + t.Fatalf("Expected %q but got %q for CollectionName", v.Expected.CollectionName, actual.CollectionName) + } + + } +} + +func TestSegmentsForMongodbDatabaseCollectionId(t *testing.T) { + segments := MongodbDatabaseCollectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MongodbDatabaseCollectionId 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/cosmosdb/2024-11-15/cosmosdb/id_partitionkeyrangeid.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_partitionkeyrangeid.go new file mode 100644 index 00000000000..0f54ae80af9 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_partitionkeyrangeid.go @@ -0,0 +1,157 @@ +package cosmosdb + +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(&PartitionKeyRangeIdId{}) +} + +var _ resourceids.ResourceId = &PartitionKeyRangeIdId{} + +// PartitionKeyRangeIdId is a struct representing the Resource ID for a Partition Key Range Id +type PartitionKeyRangeIdId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + DatabaseName string + CollectionName string + PartitionKeyRangeId string +} + +// NewPartitionKeyRangeIdID returns a new PartitionKeyRangeIdId struct +func NewPartitionKeyRangeIdID(subscriptionId string, resourceGroupName string, databaseAccountName string, databaseName string, collectionName string, partitionKeyRangeId string) PartitionKeyRangeIdId { + return PartitionKeyRangeIdId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + DatabaseName: databaseName, + CollectionName: collectionName, + PartitionKeyRangeId: partitionKeyRangeId, + } +} + +// ParsePartitionKeyRangeIdID parses 'input' into a PartitionKeyRangeIdId +func ParsePartitionKeyRangeIdID(input string) (*PartitionKeyRangeIdId, error) { + parser := resourceids.NewParserFromResourceIdType(&PartitionKeyRangeIdId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PartitionKeyRangeIdId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePartitionKeyRangeIdIDInsensitively parses 'input' case-insensitively into a PartitionKeyRangeIdId +// note: this method should only be used for API response data and not user input +func ParsePartitionKeyRangeIdIDInsensitively(input string) (*PartitionKeyRangeIdId, error) { + parser := resourceids.NewParserFromResourceIdType(&PartitionKeyRangeIdId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PartitionKeyRangeIdId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PartitionKeyRangeIdId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.DatabaseName, ok = input.Parsed["databaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseName", input) + } + + if id.CollectionName, ok = input.Parsed["collectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "collectionName", input) + } + + if id.PartitionKeyRangeId, ok = input.Parsed["partitionKeyRangeId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "partitionKeyRangeId", input) + } + + return nil +} + +// ValidatePartitionKeyRangeIdID checks that 'input' can be parsed as a Partition Key Range Id ID +func ValidatePartitionKeyRangeIdID(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 := ParsePartitionKeyRangeIdID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Partition Key Range Id ID +func (id PartitionKeyRangeIdId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/databases/%s/collections/%s/partitionKeyRangeId/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.DatabaseName, id.CollectionName, id.PartitionKeyRangeId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Partition Key Range Id ID +func (id PartitionKeyRangeIdId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticDatabases", "databases", "databases"), + resourceids.UserSpecifiedSegment("databaseName", "databaseName"), + resourceids.StaticSegment("staticCollections", "collections", "collections"), + resourceids.UserSpecifiedSegment("collectionName", "collectionName"), + resourceids.StaticSegment("staticPartitionKeyRangeId", "partitionKeyRangeId", "partitionKeyRangeId"), + resourceids.UserSpecifiedSegment("partitionKeyRangeId", "partitionKeyRangeId"), + } +} + +// String returns a human-readable description of this Partition Key Range Id ID +func (id PartitionKeyRangeIdId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Database Name: %q", id.DatabaseName), + fmt.Sprintf("Collection Name: %q", id.CollectionName), + fmt.Sprintf("Partition Key Range: %q", id.PartitionKeyRangeId), + } + return fmt.Sprintf("Partition Key Range Id (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_partitionkeyrangeid_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_partitionkeyrangeid_test.go new file mode 100644 index 00000000000..d06f8a1ceda --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_partitionkeyrangeid_test.go @@ -0,0 +1,417 @@ +package cosmosdb + +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 = &PartitionKeyRangeIdId{} + +func TestNewPartitionKeyRangeIdID(t *testing.T) { + id := NewPartitionKeyRangeIdID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "databaseName", "collectionName", "partitionKeyRangeId") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.DatabaseName != "databaseName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseName'", id.DatabaseName, "databaseName") + } + + if id.CollectionName != "collectionName" { + t.Fatalf("Expected %q but got %q for Segment 'CollectionName'", id.CollectionName, "collectionName") + } + + if id.PartitionKeyRangeId != "partitionKeyRangeId" { + t.Fatalf("Expected %q but got %q for Segment 'PartitionKeyRangeId'", id.PartitionKeyRangeId, "partitionKeyRangeId") + } +} + +func TestFormatPartitionKeyRangeIdID(t *testing.T) { + actual := NewPartitionKeyRangeIdID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "databaseName", "collectionName", "partitionKeyRangeId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName/collections/collectionName/partitionKeyRangeId/partitionKeyRangeId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePartitionKeyRangeIdID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PartitionKeyRangeIdId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName/collections", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName/collections/collectionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName/collections/collectionName/partitionKeyRangeId", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName/collections/collectionName/partitionKeyRangeId/partitionKeyRangeId", + Expected: &PartitionKeyRangeIdId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + DatabaseName: "databaseName", + CollectionName: "collectionName", + PartitionKeyRangeId: "partitionKeyRangeId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName/collections/collectionName/partitionKeyRangeId/partitionKeyRangeId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePartitionKeyRangeIdID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.DatabaseName != v.Expected.DatabaseName { + t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) + } + + if actual.CollectionName != v.Expected.CollectionName { + t.Fatalf("Expected %q but got %q for CollectionName", v.Expected.CollectionName, actual.CollectionName) + } + + if actual.PartitionKeyRangeId != v.Expected.PartitionKeyRangeId { + t.Fatalf("Expected %q but got %q for PartitionKeyRangeId", v.Expected.PartitionKeyRangeId, actual.PartitionKeyRangeId) + } + + } +} + +func TestParsePartitionKeyRangeIdIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PartitionKeyRangeIdId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/dAtAbAsEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/dAtAbAsEs/dAtAbAsEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName/collections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/dAtAbAsEs/dAtAbAsEnAmE/cOlLeCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName/collections/collectionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/dAtAbAsEs/dAtAbAsEnAmE/cOlLeCtIoNs/cOlLeCtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName/collections/collectionName/partitionKeyRangeId", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/dAtAbAsEs/dAtAbAsEnAmE/cOlLeCtIoNs/cOlLeCtIoNnAmE/pArTiTiOnKeYrAnGeId", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName/collections/collectionName/partitionKeyRangeId/partitionKeyRangeId", + Expected: &PartitionKeyRangeIdId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + DatabaseName: "databaseName", + CollectionName: "collectionName", + PartitionKeyRangeId: "partitionKeyRangeId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/databases/databaseName/collections/collectionName/partitionKeyRangeId/partitionKeyRangeId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/dAtAbAsEs/dAtAbAsEnAmE/cOlLeCtIoNs/cOlLeCtIoNnAmE/pArTiTiOnKeYrAnGeId/pArTiTiOnKeYrAnGeId", + Expected: &PartitionKeyRangeIdId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + DatabaseName: "dAtAbAsEnAmE", + CollectionName: "cOlLeCtIoNnAmE", + PartitionKeyRangeId: "pArTiTiOnKeYrAnGeId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/dAtAbAsEs/dAtAbAsEnAmE/cOlLeCtIoNs/cOlLeCtIoNnAmE/pArTiTiOnKeYrAnGeId/pArTiTiOnKeYrAnGeId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePartitionKeyRangeIdIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.DatabaseName != v.Expected.DatabaseName { + t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) + } + + if actual.CollectionName != v.Expected.CollectionName { + t.Fatalf("Expected %q but got %q for CollectionName", v.Expected.CollectionName, actual.CollectionName) + } + + if actual.PartitionKeyRangeId != v.Expected.PartitionKeyRangeId { + t.Fatalf("Expected %q but got %q for PartitionKeyRangeId", v.Expected.PartitionKeyRangeId, actual.PartitionKeyRangeId) + } + + } +} + +func TestSegmentsForPartitionKeyRangeIdId(t *testing.T) { + segments := PartitionKeyRangeIdId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PartitionKeyRangeIdId 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/cosmosdb/2024-11-15/cosmosdb/id_region.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_region.go new file mode 100644 index 00000000000..36fb36b86d2 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_region.go @@ -0,0 +1,139 @@ +package cosmosdb + +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(&RegionId{}) +} + +var _ resourceids.ResourceId = &RegionId{} + +// RegionId is a struct representing the Resource ID for a Region +type RegionId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + RegionName string +} + +// NewRegionID returns a new RegionId struct +func NewRegionID(subscriptionId string, resourceGroupName string, databaseAccountName string, regionName string) RegionId { + return RegionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + RegionName: regionName, + } +} + +// ParseRegionID parses 'input' into a RegionId +func ParseRegionID(input string) (*RegionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRegionIDInsensitively parses 'input' case-insensitively into a RegionId +// note: this method should only be used for API response data and not user input +func ParseRegionIDInsensitively(input string) (*RegionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RegionId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.RegionName, ok = input.Parsed["regionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "regionName", input) + } + + return nil +} + +// ValidateRegionID checks that 'input' can be parsed as a Region ID +func ValidateRegionID(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 := ParseRegionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Region ID +func (id RegionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/region/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.RegionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Region ID +func (id RegionId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticRegion", "region", "region"), + resourceids.UserSpecifiedSegment("regionName", "regionName"), + } +} + +// String returns a human-readable description of this Region ID +func (id RegionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Region Name: %q", id.RegionName), + } + return fmt.Sprintf("Region (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_region_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_region_test.go new file mode 100644 index 00000000000..45452117088 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_region_test.go @@ -0,0 +1,327 @@ +package cosmosdb + +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 = &RegionId{} + +func TestNewRegionID(t *testing.T) { + id := NewRegionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "regionName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.RegionName != "regionName" { + t.Fatalf("Expected %q but got %q for Segment 'RegionName'", id.RegionName, "regionName") + } +} + +func TestFormatRegionID(t *testing.T) { + actual := NewRegionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "regionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRegionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName", + Expected: &RegionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + RegionName: "regionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegionID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.RegionName != v.Expected.RegionName { + t.Fatalf("Expected %q but got %q for RegionName", v.Expected.RegionName, actual.RegionName) + } + + } +} + +func TestParseRegionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/rEgIoN", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName", + Expected: &RegionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + RegionName: "regionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/region/regionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/rEgIoN/rEgIoNnAmE", + Expected: &RegionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + RegionName: "rEgIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/rEgIoN/rEgIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegionIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.RegionName != v.Expected.RegionName { + t.Fatalf("Expected %q but got %q for RegionName", v.Expected.RegionName, actual.RegionName) + } + + } +} + +func TestSegmentsForRegionId(t *testing.T) { + segments := RegionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RegionId 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/cosmosdb/2024-11-15/cosmosdb/id_sourceregiontargetregion.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_sourceregiontargetregion.go new file mode 100644 index 00000000000..2112d234a8e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_sourceregiontargetregion.go @@ -0,0 +1,148 @@ +package cosmosdb + +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(&SourceRegionTargetRegionId{}) +} + +var _ resourceids.ResourceId = &SourceRegionTargetRegionId{} + +// SourceRegionTargetRegionId is a struct representing the Resource ID for a Source Region Target Region +type SourceRegionTargetRegionId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + SourceRegionName string + TargetRegionName string +} + +// NewSourceRegionTargetRegionID returns a new SourceRegionTargetRegionId struct +func NewSourceRegionTargetRegionID(subscriptionId string, resourceGroupName string, databaseAccountName string, sourceRegionName string, targetRegionName string) SourceRegionTargetRegionId { + return SourceRegionTargetRegionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + SourceRegionName: sourceRegionName, + TargetRegionName: targetRegionName, + } +} + +// ParseSourceRegionTargetRegionID parses 'input' into a SourceRegionTargetRegionId +func ParseSourceRegionTargetRegionID(input string) (*SourceRegionTargetRegionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SourceRegionTargetRegionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SourceRegionTargetRegionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSourceRegionTargetRegionIDInsensitively parses 'input' case-insensitively into a SourceRegionTargetRegionId +// note: this method should only be used for API response data and not user input +func ParseSourceRegionTargetRegionIDInsensitively(input string) (*SourceRegionTargetRegionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SourceRegionTargetRegionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SourceRegionTargetRegionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SourceRegionTargetRegionId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.SourceRegionName, ok = input.Parsed["sourceRegionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sourceRegionName", input) + } + + if id.TargetRegionName, ok = input.Parsed["targetRegionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "targetRegionName", input) + } + + return nil +} + +// ValidateSourceRegionTargetRegionID checks that 'input' can be parsed as a Source Region Target Region ID +func ValidateSourceRegionTargetRegionID(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 := ParseSourceRegionTargetRegionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Source Region Target Region ID +func (id SourceRegionTargetRegionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/sourceRegion/%s/targetRegion/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.SourceRegionName, id.TargetRegionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Source Region Target Region ID +func (id SourceRegionTargetRegionId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticSourceRegion", "sourceRegion", "sourceRegion"), + resourceids.UserSpecifiedSegment("sourceRegionName", "sourceRegionName"), + resourceids.StaticSegment("staticTargetRegion", "targetRegion", "targetRegion"), + resourceids.UserSpecifiedSegment("targetRegionName", "targetRegionName"), + } +} + +// String returns a human-readable description of this Source Region Target Region ID +func (id SourceRegionTargetRegionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Source Region Name: %q", id.SourceRegionName), + fmt.Sprintf("Target Region Name: %q", id.TargetRegionName), + } + return fmt.Sprintf("Source Region Target Region (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_sourceregiontargetregion_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_sourceregiontargetregion_test.go new file mode 100644 index 00000000000..9acfe7a194e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_sourceregiontargetregion_test.go @@ -0,0 +1,372 @@ +package cosmosdb + +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 = &SourceRegionTargetRegionId{} + +func TestNewSourceRegionTargetRegionID(t *testing.T) { + id := NewSourceRegionTargetRegionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sourceRegionName", "targetRegionName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.SourceRegionName != "sourceRegionName" { + t.Fatalf("Expected %q but got %q for Segment 'SourceRegionName'", id.SourceRegionName, "sourceRegionName") + } + + if id.TargetRegionName != "targetRegionName" { + t.Fatalf("Expected %q but got %q for Segment 'TargetRegionName'", id.TargetRegionName, "targetRegionName") + } +} + +func TestFormatSourceRegionTargetRegionID(t *testing.T) { + actual := NewSourceRegionTargetRegionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sourceRegionName", "targetRegionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sourceRegion/sourceRegionName/targetRegion/targetRegionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSourceRegionTargetRegionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SourceRegionTargetRegionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sourceRegion", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sourceRegion/sourceRegionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sourceRegion/sourceRegionName/targetRegion", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sourceRegion/sourceRegionName/targetRegion/targetRegionName", + Expected: &SourceRegionTargetRegionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + SourceRegionName: "sourceRegionName", + TargetRegionName: "targetRegionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sourceRegion/sourceRegionName/targetRegion/targetRegionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSourceRegionTargetRegionID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.SourceRegionName != v.Expected.SourceRegionName { + t.Fatalf("Expected %q but got %q for SourceRegionName", v.Expected.SourceRegionName, actual.SourceRegionName) + } + + if actual.TargetRegionName != v.Expected.TargetRegionName { + t.Fatalf("Expected %q but got %q for TargetRegionName", v.Expected.TargetRegionName, actual.TargetRegionName) + } + + } +} + +func TestParseSourceRegionTargetRegionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SourceRegionTargetRegionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sourceRegion", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sOuRcErEgIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sourceRegion/sourceRegionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sOuRcErEgIoN/sOuRcErEgIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sourceRegion/sourceRegionName/targetRegion", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sOuRcErEgIoN/sOuRcErEgIoNnAmE/tArGeTrEgIoN", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sourceRegion/sourceRegionName/targetRegion/targetRegionName", + Expected: &SourceRegionTargetRegionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + SourceRegionName: "sourceRegionName", + TargetRegionName: "targetRegionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sourceRegion/sourceRegionName/targetRegion/targetRegionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sOuRcErEgIoN/sOuRcErEgIoNnAmE/tArGeTrEgIoN/tArGeTrEgIoNnAmE", + Expected: &SourceRegionTargetRegionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + SourceRegionName: "sOuRcErEgIoNnAmE", + TargetRegionName: "tArGeTrEgIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sOuRcErEgIoN/sOuRcErEgIoNnAmE/tArGeTrEgIoN/tArGeTrEgIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSourceRegionTargetRegionIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.SourceRegionName != v.Expected.SourceRegionName { + t.Fatalf("Expected %q but got %q for SourceRegionName", v.Expected.SourceRegionName, actual.SourceRegionName) + } + + if actual.TargetRegionName != v.Expected.TargetRegionName { + t.Fatalf("Expected %q but got %q for TargetRegionName", v.Expected.TargetRegionName, actual.TargetRegionName) + } + + } +} + +func TestSegmentsForSourceRegionTargetRegionId(t *testing.T) { + segments := SourceRegionTargetRegionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SourceRegionTargetRegionId 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/cosmosdb/2024-11-15/cosmosdb/id_sqldatabase.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_sqldatabase.go new file mode 100644 index 00000000000..21d4f894dd5 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_sqldatabase.go @@ -0,0 +1,139 @@ +package cosmosdb + +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(&SqlDatabaseId{}) +} + +var _ resourceids.ResourceId = &SqlDatabaseId{} + +// SqlDatabaseId is a struct representing the Resource ID for a Sql Database +type SqlDatabaseId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + SqlDatabaseName string +} + +// NewSqlDatabaseID returns a new SqlDatabaseId struct +func NewSqlDatabaseID(subscriptionId string, resourceGroupName string, databaseAccountName string, sqlDatabaseName string) SqlDatabaseId { + return SqlDatabaseId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + SqlDatabaseName: sqlDatabaseName, + } +} + +// ParseSqlDatabaseID parses 'input' into a SqlDatabaseId +func ParseSqlDatabaseID(input string) (*SqlDatabaseId, error) { + parser := resourceids.NewParserFromResourceIdType(&SqlDatabaseId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SqlDatabaseId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSqlDatabaseIDInsensitively parses 'input' case-insensitively into a SqlDatabaseId +// note: this method should only be used for API response data and not user input +func ParseSqlDatabaseIDInsensitively(input string) (*SqlDatabaseId, error) { + parser := resourceids.NewParserFromResourceIdType(&SqlDatabaseId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SqlDatabaseId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SqlDatabaseId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.SqlDatabaseName, ok = input.Parsed["sqlDatabaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sqlDatabaseName", input) + } + + return nil +} + +// ValidateSqlDatabaseID checks that 'input' can be parsed as a Sql Database ID +func ValidateSqlDatabaseID(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 := ParseSqlDatabaseID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sql Database ID +func (id SqlDatabaseId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/sqlDatabases/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.SqlDatabaseName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sql Database ID +func (id SqlDatabaseId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticSqlDatabases", "sqlDatabases", "sqlDatabases"), + resourceids.UserSpecifiedSegment("sqlDatabaseName", "sqlDatabaseName"), + } +} + +// String returns a human-readable description of this Sql Database ID +func (id SqlDatabaseId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Sql Database Name: %q", id.SqlDatabaseName), + } + return fmt.Sprintf("Sql Database (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_sqldatabase_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_sqldatabase_test.go new file mode 100644 index 00000000000..5751b55efa6 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_sqldatabase_test.go @@ -0,0 +1,327 @@ +package cosmosdb + +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 = &SqlDatabaseId{} + +func TestNewSqlDatabaseID(t *testing.T) { + id := NewSqlDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.SqlDatabaseName != "sqlDatabaseName" { + t.Fatalf("Expected %q but got %q for Segment 'SqlDatabaseName'", id.SqlDatabaseName, "sqlDatabaseName") + } +} + +func TestFormatSqlDatabaseID(t *testing.T) { + actual := NewSqlDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSqlDatabaseID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SqlDatabaseId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName", + Expected: &SqlDatabaseId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + SqlDatabaseName: "sqlDatabaseName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSqlDatabaseID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.SqlDatabaseName != v.Expected.SqlDatabaseName { + t.Fatalf("Expected %q but got %q for SqlDatabaseName", v.Expected.SqlDatabaseName, actual.SqlDatabaseName) + } + + } +} + +func TestParseSqlDatabaseIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SqlDatabaseId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName", + Expected: &SqlDatabaseId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + SqlDatabaseName: "sqlDatabaseName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe", + Expected: &SqlDatabaseId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + SqlDatabaseName: "sQlDaTaBaSeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSqlDatabaseIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.SqlDatabaseName != v.Expected.SqlDatabaseName { + t.Fatalf("Expected %q but got %q for SqlDatabaseName", v.Expected.SqlDatabaseName, actual.SqlDatabaseName) + } + + } +} + +func TestSegmentsForSqlDatabaseId(t *testing.T) { + segments := SqlDatabaseId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SqlDatabaseId 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/cosmosdb/2024-11-15/cosmosdb/id_storedprocedure.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_storedprocedure.go new file mode 100644 index 00000000000..31dd78cfcba --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_storedprocedure.go @@ -0,0 +1,157 @@ +package cosmosdb + +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(&StoredProcedureId{}) +} + +var _ resourceids.ResourceId = &StoredProcedureId{} + +// StoredProcedureId is a struct representing the Resource ID for a Stored Procedure +type StoredProcedureId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + SqlDatabaseName string + ContainerName string + StoredProcedureName string +} + +// NewStoredProcedureID returns a new StoredProcedureId struct +func NewStoredProcedureID(subscriptionId string, resourceGroupName string, databaseAccountName string, sqlDatabaseName string, containerName string, storedProcedureName string) StoredProcedureId { + return StoredProcedureId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + SqlDatabaseName: sqlDatabaseName, + ContainerName: containerName, + StoredProcedureName: storedProcedureName, + } +} + +// ParseStoredProcedureID parses 'input' into a StoredProcedureId +func ParseStoredProcedureID(input string) (*StoredProcedureId, error) { + parser := resourceids.NewParserFromResourceIdType(&StoredProcedureId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StoredProcedureId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseStoredProcedureIDInsensitively parses 'input' case-insensitively into a StoredProcedureId +// note: this method should only be used for API response data and not user input +func ParseStoredProcedureIDInsensitively(input string) (*StoredProcedureId, error) { + parser := resourceids.NewParserFromResourceIdType(&StoredProcedureId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StoredProcedureId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *StoredProcedureId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.SqlDatabaseName, ok = input.Parsed["sqlDatabaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sqlDatabaseName", input) + } + + if id.ContainerName, ok = input.Parsed["containerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerName", input) + } + + if id.StoredProcedureName, ok = input.Parsed["storedProcedureName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "storedProcedureName", input) + } + + return nil +} + +// ValidateStoredProcedureID checks that 'input' can be parsed as a Stored Procedure ID +func ValidateStoredProcedureID(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 := ParseStoredProcedureID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Stored Procedure ID +func (id StoredProcedureId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/sqlDatabases/%s/containers/%s/storedProcedures/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName, id.StoredProcedureName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Stored Procedure ID +func (id StoredProcedureId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticSqlDatabases", "sqlDatabases", "sqlDatabases"), + resourceids.UserSpecifiedSegment("sqlDatabaseName", "sqlDatabaseName"), + resourceids.StaticSegment("staticContainers", "containers", "containers"), + resourceids.UserSpecifiedSegment("containerName", "containerName"), + resourceids.StaticSegment("staticStoredProcedures", "storedProcedures", "storedProcedures"), + resourceids.UserSpecifiedSegment("storedProcedureName", "storedProcedureName"), + } +} + +// String returns a human-readable description of this Stored Procedure ID +func (id StoredProcedureId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Sql Database Name: %q", id.SqlDatabaseName), + fmt.Sprintf("Container Name: %q", id.ContainerName), + fmt.Sprintf("Stored Procedure Name: %q", id.StoredProcedureName), + } + return fmt.Sprintf("Stored Procedure (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_storedprocedure_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_storedprocedure_test.go new file mode 100644 index 00000000000..602b81d744b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_storedprocedure_test.go @@ -0,0 +1,417 @@ +package cosmosdb + +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 = &StoredProcedureId{} + +func TestNewStoredProcedureID(t *testing.T) { + id := NewStoredProcedureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName", "storedProcedureName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.SqlDatabaseName != "sqlDatabaseName" { + t.Fatalf("Expected %q but got %q for Segment 'SqlDatabaseName'", id.SqlDatabaseName, "sqlDatabaseName") + } + + if id.ContainerName != "containerName" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerName'", id.ContainerName, "containerName") + } + + if id.StoredProcedureName != "storedProcedureName" { + t.Fatalf("Expected %q but got %q for Segment 'StoredProcedureName'", id.StoredProcedureName, "storedProcedureName") + } +} + +func TestFormatStoredProcedureID(t *testing.T) { + actual := NewStoredProcedureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName", "storedProcedureName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/storedProcedures/storedProcedureName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseStoredProcedureID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StoredProcedureId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/storedProcedures", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/storedProcedures/storedProcedureName", + Expected: &StoredProcedureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + SqlDatabaseName: "sqlDatabaseName", + ContainerName: "containerName", + StoredProcedureName: "storedProcedureName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/storedProcedures/storedProcedureName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStoredProcedureID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.SqlDatabaseName != v.Expected.SqlDatabaseName { + t.Fatalf("Expected %q but got %q for SqlDatabaseName", v.Expected.SqlDatabaseName, actual.SqlDatabaseName) + } + + if actual.ContainerName != v.Expected.ContainerName { + t.Fatalf("Expected %q but got %q for ContainerName", v.Expected.ContainerName, actual.ContainerName) + } + + if actual.StoredProcedureName != v.Expected.StoredProcedureName { + t.Fatalf("Expected %q but got %q for StoredProcedureName", v.Expected.StoredProcedureName, actual.StoredProcedureName) + } + + } +} + +func TestParseStoredProcedureIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StoredProcedureId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cOnTaInErS/cOnTaInErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/storedProcedures", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cOnTaInErS/cOnTaInErNaMe/sToReDpRoCeDuReS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/storedProcedures/storedProcedureName", + Expected: &StoredProcedureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + SqlDatabaseName: "sqlDatabaseName", + ContainerName: "containerName", + StoredProcedureName: "storedProcedureName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/storedProcedures/storedProcedureName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cOnTaInErS/cOnTaInErNaMe/sToReDpRoCeDuReS/sToReDpRoCeDuReNaMe", + Expected: &StoredProcedureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + SqlDatabaseName: "sQlDaTaBaSeNaMe", + ContainerName: "cOnTaInErNaMe", + StoredProcedureName: "sToReDpRoCeDuReNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cOnTaInErS/cOnTaInErNaMe/sToReDpRoCeDuReS/sToReDpRoCeDuReNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStoredProcedureIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.SqlDatabaseName != v.Expected.SqlDatabaseName { + t.Fatalf("Expected %q but got %q for SqlDatabaseName", v.Expected.SqlDatabaseName, actual.SqlDatabaseName) + } + + if actual.ContainerName != v.Expected.ContainerName { + t.Fatalf("Expected %q but got %q for ContainerName", v.Expected.ContainerName, actual.ContainerName) + } + + if actual.StoredProcedureName != v.Expected.StoredProcedureName { + t.Fatalf("Expected %q but got %q for StoredProcedureName", v.Expected.StoredProcedureName, actual.StoredProcedureName) + } + + } +} + +func TestSegmentsForStoredProcedureId(t *testing.T) { + segments := StoredProcedureId{}.Segments() + if len(segments) == 0 { + t.Fatalf("StoredProcedureId 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/cosmosdb/2024-11-15/cosmosdb/id_table.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_table.go new file mode 100644 index 00000000000..db828313697 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_table.go @@ -0,0 +1,139 @@ +package cosmosdb + +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(&TableId{}) +} + +var _ resourceids.ResourceId = &TableId{} + +// TableId is a struct representing the Resource ID for a Table +type TableId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + TableName string +} + +// NewTableID returns a new TableId struct +func NewTableID(subscriptionId string, resourceGroupName string, databaseAccountName string, tableName string) TableId { + return TableId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + TableName: tableName, + } +} + +// ParseTableID parses 'input' into a TableId +func ParseTableID(input string) (*TableId, error) { + parser := resourceids.NewParserFromResourceIdType(&TableId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTableIDInsensitively parses 'input' case-insensitively into a TableId +// note: this method should only be used for API response data and not user input +func ParseTableIDInsensitively(input string) (*TableId, error) { + parser := resourceids.NewParserFromResourceIdType(&TableId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TableId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.TableName, ok = input.Parsed["tableName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "tableName", input) + } + + return nil +} + +// ValidateTableID checks that 'input' can be parsed as a Table ID +func ValidateTableID(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 := ParseTableID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Table ID +func (id TableId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/tables/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.TableName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Table ID +func (id TableId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticTables", "tables", "tables"), + resourceids.UserSpecifiedSegment("tableName", "tableName"), + } +} + +// String returns a human-readable description of this Table ID +func (id TableId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Table Name: %q", id.TableName), + } + return fmt.Sprintf("Table (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_table_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_table_test.go new file mode 100644 index 00000000000..861ecae041b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_table_test.go @@ -0,0 +1,327 @@ +package cosmosdb + +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 = &TableId{} + +func TestNewTableID(t *testing.T) { + id := NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "tableName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.TableName != "tableName" { + t.Fatalf("Expected %q but got %q for Segment 'TableName'", id.TableName, "tableName") + } +} + +func TestFormatTableID(t *testing.T) { + actual := NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "tableName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/tables/tableName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTableID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/tables", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/tables/tableName", + Expected: &TableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + TableName: "tableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/tables/tableName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTableID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.TableName != v.Expected.TableName { + t.Fatalf("Expected %q but got %q for TableName", v.Expected.TableName, actual.TableName) + } + + } +} + +func TestParseTableIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/tables", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/tAbLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/tables/tableName", + Expected: &TableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + TableName: "tableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/tables/tableName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/tAbLeS/tAbLeNaMe", + Expected: &TableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + TableName: "tAbLeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/tAbLeS/tAbLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTableIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.TableName != v.Expected.TableName { + t.Fatalf("Expected %q but got %q for TableName", v.Expected.TableName, actual.TableName) + } + + } +} + +func TestSegmentsForTableId(t *testing.T) { + segments := TableId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TableId 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/cosmosdb/2024-11-15/cosmosdb/id_targetregion.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_targetregion.go new file mode 100644 index 00000000000..c07e6abe2a3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_targetregion.go @@ -0,0 +1,139 @@ +package cosmosdb + +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(&TargetRegionId{}) +} + +var _ resourceids.ResourceId = &TargetRegionId{} + +// TargetRegionId is a struct representing the Resource ID for a Target Region +type TargetRegionId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + TargetRegionName string +} + +// NewTargetRegionID returns a new TargetRegionId struct +func NewTargetRegionID(subscriptionId string, resourceGroupName string, databaseAccountName string, targetRegionName string) TargetRegionId { + return TargetRegionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + TargetRegionName: targetRegionName, + } +} + +// ParseTargetRegionID parses 'input' into a TargetRegionId +func ParseTargetRegionID(input string) (*TargetRegionId, error) { + parser := resourceids.NewParserFromResourceIdType(&TargetRegionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TargetRegionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTargetRegionIDInsensitively parses 'input' case-insensitively into a TargetRegionId +// note: this method should only be used for API response data and not user input +func ParseTargetRegionIDInsensitively(input string) (*TargetRegionId, error) { + parser := resourceids.NewParserFromResourceIdType(&TargetRegionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TargetRegionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TargetRegionId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.TargetRegionName, ok = input.Parsed["targetRegionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "targetRegionName", input) + } + + return nil +} + +// ValidateTargetRegionID checks that 'input' can be parsed as a Target Region ID +func ValidateTargetRegionID(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 := ParseTargetRegionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Target Region ID +func (id TargetRegionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/targetRegion/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.TargetRegionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Target Region ID +func (id TargetRegionId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticTargetRegion", "targetRegion", "targetRegion"), + resourceids.UserSpecifiedSegment("targetRegionName", "targetRegionName"), + } +} + +// String returns a human-readable description of this Target Region ID +func (id TargetRegionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Target Region Name: %q", id.TargetRegionName), + } + return fmt.Sprintf("Target Region (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_targetregion_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_targetregion_test.go new file mode 100644 index 00000000000..636fb4b33f6 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_targetregion_test.go @@ -0,0 +1,327 @@ +package cosmosdb + +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 = &TargetRegionId{} + +func TestNewTargetRegionID(t *testing.T) { + id := NewTargetRegionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "targetRegionName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.TargetRegionName != "targetRegionName" { + t.Fatalf("Expected %q but got %q for Segment 'TargetRegionName'", id.TargetRegionName, "targetRegionName") + } +} + +func TestFormatTargetRegionID(t *testing.T) { + actual := NewTargetRegionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "targetRegionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/targetRegion/targetRegionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTargetRegionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TargetRegionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/targetRegion", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/targetRegion/targetRegionName", + Expected: &TargetRegionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + TargetRegionName: "targetRegionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/targetRegion/targetRegionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTargetRegionID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.TargetRegionName != v.Expected.TargetRegionName { + t.Fatalf("Expected %q but got %q for TargetRegionName", v.Expected.TargetRegionName, actual.TargetRegionName) + } + + } +} + +func TestParseTargetRegionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TargetRegionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/targetRegion", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/tArGeTrEgIoN", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/targetRegion/targetRegionName", + Expected: &TargetRegionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + TargetRegionName: "targetRegionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/targetRegion/targetRegionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/tArGeTrEgIoN/tArGeTrEgIoNnAmE", + Expected: &TargetRegionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + TargetRegionName: "tArGeTrEgIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/tArGeTrEgIoN/tArGeTrEgIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTargetRegionIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.TargetRegionName != v.Expected.TargetRegionName { + t.Fatalf("Expected %q but got %q for TargetRegionName", v.Expected.TargetRegionName, actual.TargetRegionName) + } + + } +} + +func TestSegmentsForTargetRegionId(t *testing.T) { + segments := TargetRegionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TargetRegionId 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/cosmosdb/2024-11-15/cosmosdb/id_trigger.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_trigger.go new file mode 100644 index 00000000000..79ef1f4abbf --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_trigger.go @@ -0,0 +1,157 @@ +package cosmosdb + +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(&TriggerId{}) +} + +var _ resourceids.ResourceId = &TriggerId{} + +// TriggerId is a struct representing the Resource ID for a Trigger +type TriggerId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + SqlDatabaseName string + ContainerName string + TriggerName string +} + +// NewTriggerID returns a new TriggerId struct +func NewTriggerID(subscriptionId string, resourceGroupName string, databaseAccountName string, sqlDatabaseName string, containerName string, triggerName string) TriggerId { + return TriggerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + SqlDatabaseName: sqlDatabaseName, + ContainerName: containerName, + TriggerName: triggerName, + } +} + +// ParseTriggerID parses 'input' into a TriggerId +func ParseTriggerID(input string) (*TriggerId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTriggerIDInsensitively parses 'input' case-insensitively into a TriggerId +// note: this method should only be used for API response data and not user input +func ParseTriggerIDInsensitively(input string) (*TriggerId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TriggerId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.SqlDatabaseName, ok = input.Parsed["sqlDatabaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sqlDatabaseName", input) + } + + if id.ContainerName, ok = input.Parsed["containerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerName", input) + } + + if id.TriggerName, ok = input.Parsed["triggerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "triggerName", input) + } + + return nil +} + +// ValidateTriggerID checks that 'input' can be parsed as a Trigger ID +func ValidateTriggerID(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 := ParseTriggerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Trigger ID +func (id TriggerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/sqlDatabases/%s/containers/%s/triggers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName, id.TriggerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Trigger ID +func (id TriggerId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticSqlDatabases", "sqlDatabases", "sqlDatabases"), + resourceids.UserSpecifiedSegment("sqlDatabaseName", "sqlDatabaseName"), + resourceids.StaticSegment("staticContainers", "containers", "containers"), + resourceids.UserSpecifiedSegment("containerName", "containerName"), + resourceids.StaticSegment("staticTriggers", "triggers", "triggers"), + resourceids.UserSpecifiedSegment("triggerName", "triggerName"), + } +} + +// String returns a human-readable description of this Trigger ID +func (id TriggerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Sql Database Name: %q", id.SqlDatabaseName), + fmt.Sprintf("Container Name: %q", id.ContainerName), + fmt.Sprintf("Trigger Name: %q", id.TriggerName), + } + return fmt.Sprintf("Trigger (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_trigger_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_trigger_test.go new file mode 100644 index 00000000000..42683f03ca2 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_trigger_test.go @@ -0,0 +1,417 @@ +package cosmosdb + +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 = &TriggerId{} + +func TestNewTriggerID(t *testing.T) { + id := NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName", "triggerName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.SqlDatabaseName != "sqlDatabaseName" { + t.Fatalf("Expected %q but got %q for Segment 'SqlDatabaseName'", id.SqlDatabaseName, "sqlDatabaseName") + } + + if id.ContainerName != "containerName" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerName'", id.ContainerName, "containerName") + } + + if id.TriggerName != "triggerName" { + t.Fatalf("Expected %q but got %q for Segment 'TriggerName'", id.TriggerName, "triggerName") + } +} + +func TestFormatTriggerID(t *testing.T) { + actual := NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName", "triggerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/triggers/triggerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTriggerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/triggers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/triggers/triggerName", + Expected: &TriggerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + SqlDatabaseName: "sqlDatabaseName", + ContainerName: "containerName", + TriggerName: "triggerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/triggers/triggerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggerID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.SqlDatabaseName != v.Expected.SqlDatabaseName { + t.Fatalf("Expected %q but got %q for SqlDatabaseName", v.Expected.SqlDatabaseName, actual.SqlDatabaseName) + } + + if actual.ContainerName != v.Expected.ContainerName { + t.Fatalf("Expected %q but got %q for ContainerName", v.Expected.ContainerName, actual.ContainerName) + } + + if actual.TriggerName != v.Expected.TriggerName { + t.Fatalf("Expected %q but got %q for TriggerName", v.Expected.TriggerName, actual.TriggerName) + } + + } +} + +func TestParseTriggerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cOnTaInErS/cOnTaInErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/triggers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cOnTaInErS/cOnTaInErNaMe/tRiGgErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/triggers/triggerName", + Expected: &TriggerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + SqlDatabaseName: "sqlDatabaseName", + ContainerName: "containerName", + TriggerName: "triggerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/triggers/triggerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cOnTaInErS/cOnTaInErNaMe/tRiGgErS/tRiGgErNaMe", + Expected: &TriggerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + SqlDatabaseName: "sQlDaTaBaSeNaMe", + ContainerName: "cOnTaInErNaMe", + TriggerName: "tRiGgErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cOnTaInErS/cOnTaInErNaMe/tRiGgErS/tRiGgErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggerIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.SqlDatabaseName != v.Expected.SqlDatabaseName { + t.Fatalf("Expected %q but got %q for SqlDatabaseName", v.Expected.SqlDatabaseName, actual.SqlDatabaseName) + } + + if actual.ContainerName != v.Expected.ContainerName { + t.Fatalf("Expected %q but got %q for ContainerName", v.Expected.ContainerName, actual.ContainerName) + } + + if actual.TriggerName != v.Expected.TriggerName { + t.Fatalf("Expected %q but got %q for TriggerName", v.Expected.TriggerName, actual.TriggerName) + } + + } +} + +func TestSegmentsForTriggerId(t *testing.T) { + segments := TriggerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TriggerId 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/cosmosdb/2024-11-15/cosmosdb/id_userdefinedfunction.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_userdefinedfunction.go new file mode 100644 index 00000000000..eb5d1f446fd --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_userdefinedfunction.go @@ -0,0 +1,157 @@ +package cosmosdb + +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(&UserDefinedFunctionId{}) +} + +var _ resourceids.ResourceId = &UserDefinedFunctionId{} + +// UserDefinedFunctionId is a struct representing the Resource ID for a User Defined Function +type UserDefinedFunctionId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + SqlDatabaseName string + ContainerName string + UserDefinedFunctionName string +} + +// NewUserDefinedFunctionID returns a new UserDefinedFunctionId struct +func NewUserDefinedFunctionID(subscriptionId string, resourceGroupName string, databaseAccountName string, sqlDatabaseName string, containerName string, userDefinedFunctionName string) UserDefinedFunctionId { + return UserDefinedFunctionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + SqlDatabaseName: sqlDatabaseName, + ContainerName: containerName, + UserDefinedFunctionName: userDefinedFunctionName, + } +} + +// ParseUserDefinedFunctionID parses 'input' into a UserDefinedFunctionId +func ParseUserDefinedFunctionID(input string) (*UserDefinedFunctionId, error) { + parser := resourceids.NewParserFromResourceIdType(&UserDefinedFunctionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UserDefinedFunctionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseUserDefinedFunctionIDInsensitively parses 'input' case-insensitively into a UserDefinedFunctionId +// note: this method should only be used for API response data and not user input +func ParseUserDefinedFunctionIDInsensitively(input string) (*UserDefinedFunctionId, error) { + parser := resourceids.NewParserFromResourceIdType(&UserDefinedFunctionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UserDefinedFunctionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *UserDefinedFunctionId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.SqlDatabaseName, ok = input.Parsed["sqlDatabaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sqlDatabaseName", input) + } + + if id.ContainerName, ok = input.Parsed["containerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerName", input) + } + + if id.UserDefinedFunctionName, ok = input.Parsed["userDefinedFunctionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "userDefinedFunctionName", input) + } + + return nil +} + +// ValidateUserDefinedFunctionID checks that 'input' can be parsed as a User Defined Function ID +func ValidateUserDefinedFunctionID(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 := ParseUserDefinedFunctionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted User Defined Function ID +func (id UserDefinedFunctionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/sqlDatabases/%s/containers/%s/userDefinedFunctions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName, id.UserDefinedFunctionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this User Defined Function ID +func (id UserDefinedFunctionId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticSqlDatabases", "sqlDatabases", "sqlDatabases"), + resourceids.UserSpecifiedSegment("sqlDatabaseName", "sqlDatabaseName"), + resourceids.StaticSegment("staticContainers", "containers", "containers"), + resourceids.UserSpecifiedSegment("containerName", "containerName"), + resourceids.StaticSegment("staticUserDefinedFunctions", "userDefinedFunctions", "userDefinedFunctions"), + resourceids.UserSpecifiedSegment("userDefinedFunctionName", "userDefinedFunctionName"), + } +} + +// String returns a human-readable description of this User Defined Function ID +func (id UserDefinedFunctionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Sql Database Name: %q", id.SqlDatabaseName), + fmt.Sprintf("Container Name: %q", id.ContainerName), + fmt.Sprintf("User Defined Function Name: %q", id.UserDefinedFunctionName), + } + return fmt.Sprintf("User Defined Function (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_userdefinedfunction_test.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_userdefinedfunction_test.go new file mode 100644 index 00000000000..ca957175cbc --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/id_userdefinedfunction_test.go @@ -0,0 +1,417 @@ +package cosmosdb + +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 = &UserDefinedFunctionId{} + +func TestNewUserDefinedFunctionID(t *testing.T) { + id := NewUserDefinedFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName", "userDefinedFunctionName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.SqlDatabaseName != "sqlDatabaseName" { + t.Fatalf("Expected %q but got %q for Segment 'SqlDatabaseName'", id.SqlDatabaseName, "sqlDatabaseName") + } + + if id.ContainerName != "containerName" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerName'", id.ContainerName, "containerName") + } + + if id.UserDefinedFunctionName != "userDefinedFunctionName" { + t.Fatalf("Expected %q but got %q for Segment 'UserDefinedFunctionName'", id.UserDefinedFunctionName, "userDefinedFunctionName") + } +} + +func TestFormatUserDefinedFunctionID(t *testing.T) { + actual := NewUserDefinedFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName", "userDefinedFunctionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/userDefinedFunctions/userDefinedFunctionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseUserDefinedFunctionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UserDefinedFunctionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/userDefinedFunctions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/userDefinedFunctions/userDefinedFunctionName", + Expected: &UserDefinedFunctionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + SqlDatabaseName: "sqlDatabaseName", + ContainerName: "containerName", + UserDefinedFunctionName: "userDefinedFunctionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/userDefinedFunctions/userDefinedFunctionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUserDefinedFunctionID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.SqlDatabaseName != v.Expected.SqlDatabaseName { + t.Fatalf("Expected %q but got %q for SqlDatabaseName", v.Expected.SqlDatabaseName, actual.SqlDatabaseName) + } + + if actual.ContainerName != v.Expected.ContainerName { + t.Fatalf("Expected %q but got %q for ContainerName", v.Expected.ContainerName, actual.ContainerName) + } + + if actual.UserDefinedFunctionName != v.Expected.UserDefinedFunctionName { + t.Fatalf("Expected %q but got %q for UserDefinedFunctionName", v.Expected.UserDefinedFunctionName, actual.UserDefinedFunctionName) + } + + } +} + +func TestParseUserDefinedFunctionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UserDefinedFunctionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cOnTaInErS/cOnTaInErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/userDefinedFunctions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cOnTaInErS/cOnTaInErNaMe/uSeRdEfInEdFuNcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/userDefinedFunctions/userDefinedFunctionName", + Expected: &UserDefinedFunctionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + SqlDatabaseName: "sqlDatabaseName", + ContainerName: "containerName", + UserDefinedFunctionName: "userDefinedFunctionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/userDefinedFunctions/userDefinedFunctionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cOnTaInErS/cOnTaInErNaMe/uSeRdEfInEdFuNcTiOnS/uSeRdEfInEdFuNcTiOnNaMe", + Expected: &UserDefinedFunctionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + SqlDatabaseName: "sQlDaTaBaSeNaMe", + ContainerName: "cOnTaInErNaMe", + UserDefinedFunctionName: "uSeRdEfInEdFuNcTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cOnTaInErS/cOnTaInErNaMe/uSeRdEfInEdFuNcTiOnS/uSeRdEfInEdFuNcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUserDefinedFunctionIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.SqlDatabaseName != v.Expected.SqlDatabaseName { + t.Fatalf("Expected %q but got %q for SqlDatabaseName", v.Expected.SqlDatabaseName, actual.SqlDatabaseName) + } + + if actual.ContainerName != v.Expected.ContainerName { + t.Fatalf("Expected %q but got %q for ContainerName", v.Expected.ContainerName, actual.ContainerName) + } + + if actual.UserDefinedFunctionName != v.Expected.UserDefinedFunctionName { + t.Fatalf("Expected %q but got %q for UserDefinedFunctionName", v.Expected.UserDefinedFunctionName, actual.UserDefinedFunctionName) + } + + } +} + +func TestSegmentsForUserDefinedFunctionId(t *testing.T) { + segments := UserDefinedFunctionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("UserDefinedFunctionId 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/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcescreateupdatecassandrakeyspace.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcescreateupdatecassandrakeyspace.go new file mode 100644 index 00000000000..05bbfaadb3d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcescreateupdatecassandrakeyspace.go @@ -0,0 +1,75 @@ +package cosmosdb + +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 CassandraResourcesCreateUpdateCassandraKeyspaceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CassandraKeyspaceGetResults +} + +// CassandraResourcesCreateUpdateCassandraKeyspace ... +func (c CosmosDBClient) CassandraResourcesCreateUpdateCassandraKeyspace(ctx context.Context, id CassandraKeyspaceId, input CassandraKeyspaceCreateUpdateParameters) (result CassandraResourcesCreateUpdateCassandraKeyspaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CassandraResourcesCreateUpdateCassandraKeyspaceThenPoll performs CassandraResourcesCreateUpdateCassandraKeyspace then polls until it's completed +func (c CosmosDBClient) CassandraResourcesCreateUpdateCassandraKeyspaceThenPoll(ctx context.Context, id CassandraKeyspaceId, input CassandraKeyspaceCreateUpdateParameters) error { + result, err := c.CassandraResourcesCreateUpdateCassandraKeyspace(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CassandraResourcesCreateUpdateCassandraKeyspace: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CassandraResourcesCreateUpdateCassandraKeyspace: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcescreateupdatecassandratable.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcescreateupdatecassandratable.go new file mode 100644 index 00000000000..c5ccd6c7cbb --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcescreateupdatecassandratable.go @@ -0,0 +1,75 @@ +package cosmosdb + +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 CassandraResourcesCreateUpdateCassandraTableOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CassandraTableGetResults +} + +// CassandraResourcesCreateUpdateCassandraTable ... +func (c CosmosDBClient) CassandraResourcesCreateUpdateCassandraTable(ctx context.Context, id CassandraKeyspaceTableId, input CassandraTableCreateUpdateParameters) (result CassandraResourcesCreateUpdateCassandraTableOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CassandraResourcesCreateUpdateCassandraTableThenPoll performs CassandraResourcesCreateUpdateCassandraTable then polls until it's completed +func (c CosmosDBClient) CassandraResourcesCreateUpdateCassandraTableThenPoll(ctx context.Context, id CassandraKeyspaceTableId, input CassandraTableCreateUpdateParameters) error { + result, err := c.CassandraResourcesCreateUpdateCassandraTable(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CassandraResourcesCreateUpdateCassandraTable: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CassandraResourcesCreateUpdateCassandraTable: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesdeletecassandrakeyspace.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesdeletecassandrakeyspace.go new file mode 100644 index 00000000000..d8b5f84b641 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesdeletecassandrakeyspace.go @@ -0,0 +1,70 @@ +package cosmosdb + +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 CassandraResourcesDeleteCassandraKeyspaceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CassandraResourcesDeleteCassandraKeyspace ... +func (c CosmosDBClient) CassandraResourcesDeleteCassandraKeyspace(ctx context.Context, id CassandraKeyspaceId) (result CassandraResourcesDeleteCassandraKeyspaceOperationResponse, 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 +} + +// CassandraResourcesDeleteCassandraKeyspaceThenPoll performs CassandraResourcesDeleteCassandraKeyspace then polls until it's completed +func (c CosmosDBClient) CassandraResourcesDeleteCassandraKeyspaceThenPoll(ctx context.Context, id CassandraKeyspaceId) error { + result, err := c.CassandraResourcesDeleteCassandraKeyspace(ctx, id) + if err != nil { + return fmt.Errorf("performing CassandraResourcesDeleteCassandraKeyspace: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CassandraResourcesDeleteCassandraKeyspace: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesdeletecassandratable.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesdeletecassandratable.go new file mode 100644 index 00000000000..59358d26feb --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesdeletecassandratable.go @@ -0,0 +1,70 @@ +package cosmosdb + +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 CassandraResourcesDeleteCassandraTableOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CassandraResourcesDeleteCassandraTable ... +func (c CosmosDBClient) CassandraResourcesDeleteCassandraTable(ctx context.Context, id CassandraKeyspaceTableId) (result CassandraResourcesDeleteCassandraTableOperationResponse, 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 +} + +// CassandraResourcesDeleteCassandraTableThenPoll performs CassandraResourcesDeleteCassandraTable then polls until it's completed +func (c CosmosDBClient) CassandraResourcesDeleteCassandraTableThenPoll(ctx context.Context, id CassandraKeyspaceTableId) error { + result, err := c.CassandraResourcesDeleteCassandraTable(ctx, id) + if err != nil { + return fmt.Errorf("performing CassandraResourcesDeleteCassandraTable: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CassandraResourcesDeleteCassandraTable: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesgetcassandrakeyspace.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesgetcassandrakeyspace.go new file mode 100644 index 00000000000..de461e25dc1 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesgetcassandrakeyspace.go @@ -0,0 +1,53 @@ +package cosmosdb + +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 CassandraResourcesGetCassandraKeyspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CassandraKeyspaceGetResults +} + +// CassandraResourcesGetCassandraKeyspace ... +func (c CosmosDBClient) CassandraResourcesGetCassandraKeyspace(ctx context.Context, id CassandraKeyspaceId) (result CassandraResourcesGetCassandraKeyspaceOperationResponse, 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 CassandraKeyspaceGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesgetcassandrakeyspacethroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesgetcassandrakeyspacethroughput.go new file mode 100644 index 00000000000..89e084cef74 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesgetcassandrakeyspacethroughput.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 CassandraResourcesGetCassandraKeyspaceThroughputOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// CassandraResourcesGetCassandraKeyspaceThroughput ... +func (c CosmosDBClient) CassandraResourcesGetCassandraKeyspaceThroughput(ctx context.Context, id CassandraKeyspaceId) (result CassandraResourcesGetCassandraKeyspaceThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/throughputSettings/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 ThroughputSettingsGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesgetcassandratable.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesgetcassandratable.go new file mode 100644 index 00000000000..41dc5195f74 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesgetcassandratable.go @@ -0,0 +1,53 @@ +package cosmosdb + +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 CassandraResourcesGetCassandraTableOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CassandraTableGetResults +} + +// CassandraResourcesGetCassandraTable ... +func (c CosmosDBClient) CassandraResourcesGetCassandraTable(ctx context.Context, id CassandraKeyspaceTableId) (result CassandraResourcesGetCassandraTableOperationResponse, 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 CassandraTableGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesgetcassandratablethroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesgetcassandratablethroughput.go new file mode 100644 index 00000000000..c328ab67406 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesgetcassandratablethroughput.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 CassandraResourcesGetCassandraTableThroughputOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// CassandraResourcesGetCassandraTableThroughput ... +func (c CosmosDBClient) CassandraResourcesGetCassandraTableThroughput(ctx context.Context, id CassandraKeyspaceTableId) (result CassandraResourcesGetCassandraTableThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/throughputSettings/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 ThroughputSettingsGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourceslistcassandrakeyspaces.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourceslistcassandrakeyspaces.go new file mode 100644 index 00000000000..8fd6832e589 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourceslistcassandrakeyspaces.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 CassandraResourcesListCassandraKeyspacesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CassandraKeyspaceListResult +} + +// CassandraResourcesListCassandraKeyspaces ... +func (c CosmosDBClient) CassandraResourcesListCassandraKeyspaces(ctx context.Context, id DatabaseAccountId) (result CassandraResourcesListCassandraKeyspacesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/cassandraKeyspaces", 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 CassandraKeyspaceListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourceslistcassandratables.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourceslistcassandratables.go new file mode 100644 index 00000000000..2c2d361034f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourceslistcassandratables.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 CassandraResourcesListCassandraTablesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CassandraTableListResult +} + +// CassandraResourcesListCassandraTables ... +func (c CosmosDBClient) CassandraResourcesListCassandraTables(ctx context.Context, id CassandraKeyspaceId) (result CassandraResourcesListCassandraTablesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/tables", 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 CassandraTableListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesmigratecassandrakeyspacetoautoscale.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesmigratecassandrakeyspacetoautoscale.go new file mode 100644 index 00000000000..3e40a0640eb --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesmigratecassandrakeyspacetoautoscale.go @@ -0,0 +1,71 @@ +package cosmosdb + +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 CassandraResourcesMigrateCassandraKeyspaceToAutoscaleOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// CassandraResourcesMigrateCassandraKeyspaceToAutoscale ... +func (c CosmosDBClient) CassandraResourcesMigrateCassandraKeyspaceToAutoscale(ctx context.Context, id CassandraKeyspaceId) (result CassandraResourcesMigrateCassandraKeyspaceToAutoscaleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/throughputSettings/default/migrateToAutoscale", 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 +} + +// CassandraResourcesMigrateCassandraKeyspaceToAutoscaleThenPoll performs CassandraResourcesMigrateCassandraKeyspaceToAutoscale then polls until it's completed +func (c CosmosDBClient) CassandraResourcesMigrateCassandraKeyspaceToAutoscaleThenPoll(ctx context.Context, id CassandraKeyspaceId) error { + result, err := c.CassandraResourcesMigrateCassandraKeyspaceToAutoscale(ctx, id) + if err != nil { + return fmt.Errorf("performing CassandraResourcesMigrateCassandraKeyspaceToAutoscale: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CassandraResourcesMigrateCassandraKeyspaceToAutoscale: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesmigratecassandrakeyspacetomanualthroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesmigratecassandrakeyspacetomanualthroughput.go new file mode 100644 index 00000000000..62256492c4c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesmigratecassandrakeyspacetomanualthroughput.go @@ -0,0 +1,71 @@ +package cosmosdb + +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 CassandraResourcesMigrateCassandraKeyspaceToManualThroughputOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// CassandraResourcesMigrateCassandraKeyspaceToManualThroughput ... +func (c CosmosDBClient) CassandraResourcesMigrateCassandraKeyspaceToManualThroughput(ctx context.Context, id CassandraKeyspaceId) (result CassandraResourcesMigrateCassandraKeyspaceToManualThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/throughputSettings/default/migrateToManualThroughput", 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 +} + +// CassandraResourcesMigrateCassandraKeyspaceToManualThroughputThenPoll performs CassandraResourcesMigrateCassandraKeyspaceToManualThroughput then polls until it's completed +func (c CosmosDBClient) CassandraResourcesMigrateCassandraKeyspaceToManualThroughputThenPoll(ctx context.Context, id CassandraKeyspaceId) error { + result, err := c.CassandraResourcesMigrateCassandraKeyspaceToManualThroughput(ctx, id) + if err != nil { + return fmt.Errorf("performing CassandraResourcesMigrateCassandraKeyspaceToManualThroughput: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CassandraResourcesMigrateCassandraKeyspaceToManualThroughput: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesmigratecassandratabletoautoscale.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesmigratecassandratabletoautoscale.go new file mode 100644 index 00000000000..d777a2d4ae9 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesmigratecassandratabletoautoscale.go @@ -0,0 +1,71 @@ +package cosmosdb + +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 CassandraResourcesMigrateCassandraTableToAutoscaleOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// CassandraResourcesMigrateCassandraTableToAutoscale ... +func (c CosmosDBClient) CassandraResourcesMigrateCassandraTableToAutoscale(ctx context.Context, id CassandraKeyspaceTableId) (result CassandraResourcesMigrateCassandraTableToAutoscaleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/throughputSettings/default/migrateToAutoscale", 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 +} + +// CassandraResourcesMigrateCassandraTableToAutoscaleThenPoll performs CassandraResourcesMigrateCassandraTableToAutoscale then polls until it's completed +func (c CosmosDBClient) CassandraResourcesMigrateCassandraTableToAutoscaleThenPoll(ctx context.Context, id CassandraKeyspaceTableId) error { + result, err := c.CassandraResourcesMigrateCassandraTableToAutoscale(ctx, id) + if err != nil { + return fmt.Errorf("performing CassandraResourcesMigrateCassandraTableToAutoscale: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CassandraResourcesMigrateCassandraTableToAutoscale: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesmigratecassandratabletomanualthroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesmigratecassandratabletomanualthroughput.go new file mode 100644 index 00000000000..66b54e3c570 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesmigratecassandratabletomanualthroughput.go @@ -0,0 +1,71 @@ +package cosmosdb + +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 CassandraResourcesMigrateCassandraTableToManualThroughputOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// CassandraResourcesMigrateCassandraTableToManualThroughput ... +func (c CosmosDBClient) CassandraResourcesMigrateCassandraTableToManualThroughput(ctx context.Context, id CassandraKeyspaceTableId) (result CassandraResourcesMigrateCassandraTableToManualThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/throughputSettings/default/migrateToManualThroughput", 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 +} + +// CassandraResourcesMigrateCassandraTableToManualThroughputThenPoll performs CassandraResourcesMigrateCassandraTableToManualThroughput then polls until it's completed +func (c CosmosDBClient) CassandraResourcesMigrateCassandraTableToManualThroughputThenPoll(ctx context.Context, id CassandraKeyspaceTableId) error { + result, err := c.CassandraResourcesMigrateCassandraTableToManualThroughput(ctx, id) + if err != nil { + return fmt.Errorf("performing CassandraResourcesMigrateCassandraTableToManualThroughput: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CassandraResourcesMigrateCassandraTableToManualThroughput: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesupdatecassandrakeyspacethroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesupdatecassandrakeyspacethroughput.go new file mode 100644 index 00000000000..aa9b57d4c13 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesupdatecassandrakeyspacethroughput.go @@ -0,0 +1,75 @@ +package cosmosdb + +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 CassandraResourcesUpdateCassandraKeyspaceThroughputOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// CassandraResourcesUpdateCassandraKeyspaceThroughput ... +func (c CosmosDBClient) CassandraResourcesUpdateCassandraKeyspaceThroughput(ctx context.Context, id CassandraKeyspaceId, input ThroughputSettingsUpdateParameters) (result CassandraResourcesUpdateCassandraKeyspaceThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/throughputSettings/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 +} + +// CassandraResourcesUpdateCassandraKeyspaceThroughputThenPoll performs CassandraResourcesUpdateCassandraKeyspaceThroughput then polls until it's completed +func (c CosmosDBClient) CassandraResourcesUpdateCassandraKeyspaceThroughputThenPoll(ctx context.Context, id CassandraKeyspaceId, input ThroughputSettingsUpdateParameters) error { + result, err := c.CassandraResourcesUpdateCassandraKeyspaceThroughput(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CassandraResourcesUpdateCassandraKeyspaceThroughput: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CassandraResourcesUpdateCassandraKeyspaceThroughput: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesupdatecassandratablethroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesupdatecassandratablethroughput.go new file mode 100644 index 00000000000..b714ca26940 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_cassandraresourcesupdatecassandratablethroughput.go @@ -0,0 +1,75 @@ +package cosmosdb + +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 CassandraResourcesUpdateCassandraTableThroughputOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// CassandraResourcesUpdateCassandraTableThroughput ... +func (c CosmosDBClient) CassandraResourcesUpdateCassandraTableThroughput(ctx context.Context, id CassandraKeyspaceTableId, input ThroughputSettingsUpdateParameters) (result CassandraResourcesUpdateCassandraTableThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/throughputSettings/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 +} + +// CassandraResourcesUpdateCassandraTableThroughputThenPoll performs CassandraResourcesUpdateCassandraTableThroughput then polls until it's completed +func (c CosmosDBClient) CassandraResourcesUpdateCassandraTableThroughputThenPoll(ctx context.Context, id CassandraKeyspaceTableId, input ThroughputSettingsUpdateParameters) error { + result, err := c.CassandraResourcesUpdateCassandraTableThroughput(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CassandraResourcesUpdateCassandraTableThroughput: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CassandraResourcesUpdateCassandraTableThroughput: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_collectionlistmetricdefinitions.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_collectionlistmetricdefinitions.go new file mode 100644 index 00000000000..759da61266f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_collectionlistmetricdefinitions.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 CollectionListMetricDefinitionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MetricDefinitionsListResult +} + +// CollectionListMetricDefinitions ... +func (c CosmosDBClient) CollectionListMetricDefinitions(ctx context.Context, id CollectionId) (result CollectionListMetricDefinitionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/metricDefinitions", 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 MetricDefinitionsListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_collectionlistmetrics.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_collectionlistmetrics.go new file mode 100644 index 00000000000..cf0c2018682 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_collectionlistmetrics.go @@ -0,0 +1,83 @@ +package cosmosdb + +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 CollectionListMetricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MetricListResult +} + +type CollectionListMetricsOperationOptions struct { + Filter *string +} + +func DefaultCollectionListMetricsOperationOptions() CollectionListMetricsOperationOptions { + return CollectionListMetricsOperationOptions{} +} + +func (o CollectionListMetricsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o CollectionListMetricsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CollectionListMetricsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// CollectionListMetrics ... +func (c CosmosDBClient) CollectionListMetrics(ctx context.Context, id CollectionId, options CollectionListMetricsOperationOptions) (result CollectionListMetricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/metrics", 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 MetricListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_collectionlistusages.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_collectionlistusages.go new file mode 100644 index 00000000000..114d55e873d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_collectionlistusages.go @@ -0,0 +1,83 @@ +package cosmosdb + +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 CollectionListUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *UsagesResult +} + +type CollectionListUsagesOperationOptions struct { + Filter *string +} + +func DefaultCollectionListUsagesOperationOptions() CollectionListUsagesOperationOptions { + return CollectionListUsagesOperationOptions{} +} + +func (o CollectionListUsagesOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o CollectionListUsagesOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CollectionListUsagesOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// CollectionListUsages ... +func (c CosmosDBClient) CollectionListUsages(ctx context.Context, id CollectionId, options CollectionListUsagesOperationOptions) (result CollectionListUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/usages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model UsagesResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_collectionpartitionlistmetrics.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_collectionpartitionlistmetrics.go new file mode 100644 index 00000000000..e4738325382 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_collectionpartitionlistmetrics.go @@ -0,0 +1,83 @@ +package cosmosdb + +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 CollectionPartitionListMetricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PartitionMetricListResult +} + +type CollectionPartitionListMetricsOperationOptions struct { + Filter *string +} + +func DefaultCollectionPartitionListMetricsOperationOptions() CollectionPartitionListMetricsOperationOptions { + return CollectionPartitionListMetricsOperationOptions{} +} + +func (o CollectionPartitionListMetricsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o CollectionPartitionListMetricsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CollectionPartitionListMetricsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// CollectionPartitionListMetrics ... +func (c CosmosDBClient) CollectionPartitionListMetrics(ctx context.Context, id CollectionId, options CollectionPartitionListMetricsOperationOptions) (result CollectionPartitionListMetricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/partitions/metrics", 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 PartitionMetricListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_collectionpartitionlistusages.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_collectionpartitionlistusages.go new file mode 100644 index 00000000000..11b7cd3bb49 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_collectionpartitionlistusages.go @@ -0,0 +1,83 @@ +package cosmosdb + +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 CollectionPartitionListUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PartitionUsagesResult +} + +type CollectionPartitionListUsagesOperationOptions struct { + Filter *string +} + +func DefaultCollectionPartitionListUsagesOperationOptions() CollectionPartitionListUsagesOperationOptions { + return CollectionPartitionListUsagesOperationOptions{} +} + +func (o CollectionPartitionListUsagesOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o CollectionPartitionListUsagesOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CollectionPartitionListUsagesOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// CollectionPartitionListUsages ... +func (c CosmosDBClient) CollectionPartitionListUsages(ctx context.Context, id CollectionId, options CollectionPartitionListUsagesOperationOptions) (result CollectionPartitionListUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/partitions/usages", 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 PartitionUsagesResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_collectionpartitionregionlistmetrics.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_collectionpartitionregionlistmetrics.go new file mode 100644 index 00000000000..4c36c242ff3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_collectionpartitionregionlistmetrics.go @@ -0,0 +1,83 @@ +package cosmosdb + +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 CollectionPartitionRegionListMetricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PartitionMetricListResult +} + +type CollectionPartitionRegionListMetricsOperationOptions struct { + Filter *string +} + +func DefaultCollectionPartitionRegionListMetricsOperationOptions() CollectionPartitionRegionListMetricsOperationOptions { + return CollectionPartitionRegionListMetricsOperationOptions{} +} + +func (o CollectionPartitionRegionListMetricsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o CollectionPartitionRegionListMetricsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CollectionPartitionRegionListMetricsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// CollectionPartitionRegionListMetrics ... +func (c CosmosDBClient) CollectionPartitionRegionListMetrics(ctx context.Context, id DatabaseCollectionId, options CollectionPartitionRegionListMetricsOperationOptions) (result CollectionPartitionRegionListMetricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/partitions/metrics", 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 PartitionMetricListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_collectionregionlistmetrics.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_collectionregionlistmetrics.go new file mode 100644 index 00000000000..af8051f65e0 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_collectionregionlistmetrics.go @@ -0,0 +1,83 @@ +package cosmosdb + +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 CollectionRegionListMetricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MetricListResult +} + +type CollectionRegionListMetricsOperationOptions struct { + Filter *string +} + +func DefaultCollectionRegionListMetricsOperationOptions() CollectionRegionListMetricsOperationOptions { + return CollectionRegionListMetricsOperationOptions{} +} + +func (o CollectionRegionListMetricsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o CollectionRegionListMetricsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CollectionRegionListMetricsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// CollectionRegionListMetrics ... +func (c CosmosDBClient) CollectionRegionListMetrics(ctx context.Context, id DatabaseCollectionId, options CollectionRegionListMetricsOperationOptions) (result CollectionRegionListMetricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/metrics", 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 MetricListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountregionlistmetrics.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountregionlistmetrics.go new file mode 100644 index 00000000000..f8be1c1d41f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountregionlistmetrics.go @@ -0,0 +1,83 @@ +package cosmosdb + +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 DatabaseAccountRegionListMetricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MetricListResult +} + +type DatabaseAccountRegionListMetricsOperationOptions struct { + Filter *string +} + +func DefaultDatabaseAccountRegionListMetricsOperationOptions() DatabaseAccountRegionListMetricsOperationOptions { + return DatabaseAccountRegionListMetricsOperationOptions{} +} + +func (o DatabaseAccountRegionListMetricsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DatabaseAccountRegionListMetricsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DatabaseAccountRegionListMetricsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// DatabaseAccountRegionListMetrics ... +func (c CosmosDBClient) DatabaseAccountRegionListMetrics(ctx context.Context, id RegionId, options DatabaseAccountRegionListMetricsOperationOptions) (result DatabaseAccountRegionListMetricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/metrics", 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 MetricListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountschecknameexists.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountschecknameexists.go new file mode 100644 index 00000000000..0ee8025c66e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountschecknameexists.go @@ -0,0 +1,46 @@ +package cosmosdb + +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 DatabaseAccountsCheckNameExistsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DatabaseAccountsCheckNameExists ... +func (c CosmosDBClient) DatabaseAccountsCheckNameExists(ctx context.Context, id DatabaseAccountNameId) (result DatabaseAccountsCheckNameExistsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + 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 + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountscreateorupdate.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountscreateorupdate.go new file mode 100644 index 00000000000..8546df9bcc6 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountscreateorupdate.go @@ -0,0 +1,74 @@ +package cosmosdb + +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 DatabaseAccountsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseAccountGetResults +} + +// DatabaseAccountsCreateOrUpdate ... +func (c CosmosDBClient) DatabaseAccountsCreateOrUpdate(ctx context.Context, id DatabaseAccountId, input DatabaseAccountCreateUpdateParameters) (result DatabaseAccountsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 +} + +// DatabaseAccountsCreateOrUpdateThenPoll performs DatabaseAccountsCreateOrUpdate then polls until it's completed +func (c CosmosDBClient) DatabaseAccountsCreateOrUpdateThenPoll(ctx context.Context, id DatabaseAccountId, input DatabaseAccountCreateUpdateParameters) error { + result, err := c.DatabaseAccountsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DatabaseAccountsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DatabaseAccountsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsdelete.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsdelete.go new file mode 100644 index 00000000000..31e9c2edc59 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsdelete.go @@ -0,0 +1,70 @@ +package cosmosdb + +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 DatabaseAccountsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DatabaseAccountsDelete ... +func (c CosmosDBClient) DatabaseAccountsDelete(ctx context.Context, id DatabaseAccountId) (result DatabaseAccountsDeleteOperationResponse, 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 +} + +// DatabaseAccountsDeleteThenPoll performs DatabaseAccountsDelete then polls until it's completed +func (c CosmosDBClient) DatabaseAccountsDeleteThenPoll(ctx context.Context, id DatabaseAccountId) error { + result, err := c.DatabaseAccountsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing DatabaseAccountsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DatabaseAccountsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsfailoverprioritychange.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsfailoverprioritychange.go new file mode 100644 index 00000000000..1d3831d1310 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsfailoverprioritychange.go @@ -0,0 +1,74 @@ +package cosmosdb + +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 DatabaseAccountsFailoverPriorityChangeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DatabaseAccountsFailoverPriorityChange ... +func (c CosmosDBClient) DatabaseAccountsFailoverPriorityChange(ctx context.Context, id DatabaseAccountId, input FailoverPolicies) (result DatabaseAccountsFailoverPriorityChangeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/failoverPriorityChange", 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 +} + +// DatabaseAccountsFailoverPriorityChangeThenPoll performs DatabaseAccountsFailoverPriorityChange then polls until it's completed +func (c CosmosDBClient) DatabaseAccountsFailoverPriorityChangeThenPoll(ctx context.Context, id DatabaseAccountId, input FailoverPolicies) error { + result, err := c.DatabaseAccountsFailoverPriorityChange(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DatabaseAccountsFailoverPriorityChange: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DatabaseAccountsFailoverPriorityChange: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsget.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsget.go new file mode 100644 index 00000000000..062b96a49c5 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsget.go @@ -0,0 +1,53 @@ +package cosmosdb + +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 DatabaseAccountsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseAccountGetResults +} + +// DatabaseAccountsGet ... +func (c CosmosDBClient) DatabaseAccountsGet(ctx context.Context, id DatabaseAccountId) (result DatabaseAccountsGetOperationResponse, 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 DatabaseAccountGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsgetreadonlykeys.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsgetreadonlykeys.go new file mode 100644 index 00000000000..72046c42d04 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsgetreadonlykeys.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 DatabaseAccountsGetReadOnlyKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseAccountListReadOnlyKeysResult +} + +// DatabaseAccountsGetReadOnlyKeys ... +func (c CosmosDBClient) DatabaseAccountsGetReadOnlyKeys(ctx context.Context, id DatabaseAccountId) (result DatabaseAccountsGetReadOnlyKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/readonlykeys", 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 DatabaseAccountListReadOnlyKeysResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslist.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslist.go new file mode 100644 index 00000000000..05f6c342ff5 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslist.go @@ -0,0 +1,55 @@ +package cosmosdb + +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 DatabaseAccountsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseAccountsListResult +} + +// DatabaseAccountsList ... +func (c CosmosDBClient) DatabaseAccountsList(ctx context.Context, id commonids.SubscriptionId) (result DatabaseAccountsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DocumentDB/databaseAccounts", 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 DatabaseAccountsListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslistbyresourcegroup.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslistbyresourcegroup.go new file mode 100644 index 00000000000..df3eeb3dd38 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslistbyresourcegroup.go @@ -0,0 +1,55 @@ +package cosmosdb + +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 DatabaseAccountsListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseAccountsListResult +} + +// DatabaseAccountsListByResourceGroup ... +func (c CosmosDBClient) DatabaseAccountsListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result DatabaseAccountsListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DocumentDB/databaseAccounts", 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 DatabaseAccountsListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslistconnectionstrings.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslistconnectionstrings.go new file mode 100644 index 00000000000..73fc75aa1ad --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslistconnectionstrings.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 DatabaseAccountsListConnectionStringsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseAccountListConnectionStringsResult +} + +// DatabaseAccountsListConnectionStrings ... +func (c CosmosDBClient) DatabaseAccountsListConnectionStrings(ctx context.Context, id DatabaseAccountId) (result DatabaseAccountsListConnectionStringsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listConnectionStrings", 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 DatabaseAccountListConnectionStringsResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslistkeys.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslistkeys.go new file mode 100644 index 00000000000..d47fc347572 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslistkeys.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 DatabaseAccountsListKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseAccountListKeysResult +} + +// DatabaseAccountsListKeys ... +func (c CosmosDBClient) DatabaseAccountsListKeys(ctx context.Context, id DatabaseAccountId) (result DatabaseAccountsListKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", 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 DatabaseAccountListKeysResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslistmetricdefinitions.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslistmetricdefinitions.go new file mode 100644 index 00000000000..4357cd02e66 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslistmetricdefinitions.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 DatabaseAccountsListMetricDefinitionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MetricDefinitionsListResult +} + +// DatabaseAccountsListMetricDefinitions ... +func (c CosmosDBClient) DatabaseAccountsListMetricDefinitions(ctx context.Context, id DatabaseAccountId) (result DatabaseAccountsListMetricDefinitionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/metricDefinitions", 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 MetricDefinitionsListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslistmetrics.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslistmetrics.go new file mode 100644 index 00000000000..d0ba70fcbad --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslistmetrics.go @@ -0,0 +1,83 @@ +package cosmosdb + +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 DatabaseAccountsListMetricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MetricListResult +} + +type DatabaseAccountsListMetricsOperationOptions struct { + Filter *string +} + +func DefaultDatabaseAccountsListMetricsOperationOptions() DatabaseAccountsListMetricsOperationOptions { + return DatabaseAccountsListMetricsOperationOptions{} +} + +func (o DatabaseAccountsListMetricsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DatabaseAccountsListMetricsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DatabaseAccountsListMetricsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// DatabaseAccountsListMetrics ... +func (c CosmosDBClient) DatabaseAccountsListMetrics(ctx context.Context, id DatabaseAccountId, options DatabaseAccountsListMetricsOperationOptions) (result DatabaseAccountsListMetricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/metrics", 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 MetricListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslistreadonlykeys.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslistreadonlykeys.go new file mode 100644 index 00000000000..d8667228ecc --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslistreadonlykeys.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 DatabaseAccountsListReadOnlyKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseAccountListReadOnlyKeysResult +} + +// DatabaseAccountsListReadOnlyKeys ... +func (c CosmosDBClient) DatabaseAccountsListReadOnlyKeys(ctx context.Context, id DatabaseAccountId) (result DatabaseAccountsListReadOnlyKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/readonlykeys", 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 DatabaseAccountListReadOnlyKeysResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslistusages.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslistusages.go new file mode 100644 index 00000000000..6409fa4aa88 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountslistusages.go @@ -0,0 +1,83 @@ +package cosmosdb + +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 DatabaseAccountsListUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *UsagesResult +} + +type DatabaseAccountsListUsagesOperationOptions struct { + Filter *string +} + +func DefaultDatabaseAccountsListUsagesOperationOptions() DatabaseAccountsListUsagesOperationOptions { + return DatabaseAccountsListUsagesOperationOptions{} +} + +func (o DatabaseAccountsListUsagesOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DatabaseAccountsListUsagesOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DatabaseAccountsListUsagesOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// DatabaseAccountsListUsages ... +func (c CosmosDBClient) DatabaseAccountsListUsages(ctx context.Context, id DatabaseAccountId, options DatabaseAccountsListUsagesOperationOptions) (result DatabaseAccountsListUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/usages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model UsagesResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsofflineregion.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsofflineregion.go new file mode 100644 index 00000000000..fa0eaf62b44 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsofflineregion.go @@ -0,0 +1,74 @@ +package cosmosdb + +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 DatabaseAccountsOfflineRegionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DatabaseAccountsOfflineRegion ... +func (c CosmosDBClient) DatabaseAccountsOfflineRegion(ctx context.Context, id DatabaseAccountId, input RegionForOnlineOffline) (result DatabaseAccountsOfflineRegionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/offlineRegion", 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 +} + +// DatabaseAccountsOfflineRegionThenPoll performs DatabaseAccountsOfflineRegion then polls until it's completed +func (c CosmosDBClient) DatabaseAccountsOfflineRegionThenPoll(ctx context.Context, id DatabaseAccountId, input RegionForOnlineOffline) error { + result, err := c.DatabaseAccountsOfflineRegion(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DatabaseAccountsOfflineRegion: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DatabaseAccountsOfflineRegion: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsonlineregion.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsonlineregion.go new file mode 100644 index 00000000000..0874dfc4649 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsonlineregion.go @@ -0,0 +1,74 @@ +package cosmosdb + +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 DatabaseAccountsOnlineRegionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DatabaseAccountsOnlineRegion ... +func (c CosmosDBClient) DatabaseAccountsOnlineRegion(ctx context.Context, id DatabaseAccountId, input RegionForOnlineOffline) (result DatabaseAccountsOnlineRegionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/onlineRegion", 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 +} + +// DatabaseAccountsOnlineRegionThenPoll performs DatabaseAccountsOnlineRegion then polls until it's completed +func (c CosmosDBClient) DatabaseAccountsOnlineRegionThenPoll(ctx context.Context, id DatabaseAccountId, input RegionForOnlineOffline) error { + result, err := c.DatabaseAccountsOnlineRegion(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DatabaseAccountsOnlineRegion: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DatabaseAccountsOnlineRegion: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsregeneratekey.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsregeneratekey.go new file mode 100644 index 00000000000..939a13c6693 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsregeneratekey.go @@ -0,0 +1,74 @@ +package cosmosdb + +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 DatabaseAccountsRegenerateKeyOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DatabaseAccountsRegenerateKey ... +func (c CosmosDBClient) DatabaseAccountsRegenerateKey(ctx context.Context, id DatabaseAccountId, input DatabaseAccountRegenerateKeyParameters) (result DatabaseAccountsRegenerateKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateKey", 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 +} + +// DatabaseAccountsRegenerateKeyThenPoll performs DatabaseAccountsRegenerateKey then polls until it's completed +func (c CosmosDBClient) DatabaseAccountsRegenerateKeyThenPoll(ctx context.Context, id DatabaseAccountId, input DatabaseAccountRegenerateKeyParameters) error { + result, err := c.DatabaseAccountsRegenerateKey(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DatabaseAccountsRegenerateKey: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DatabaseAccountsRegenerateKey: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsupdate.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsupdate.go new file mode 100644 index 00000000000..eac2c7d4ee4 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaseaccountsupdate.go @@ -0,0 +1,74 @@ +package cosmosdb + +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 DatabaseAccountsUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseAccountGetResults +} + +// DatabaseAccountsUpdate ... +func (c CosmosDBClient) DatabaseAccountsUpdate(ctx context.Context, id DatabaseAccountId, input DatabaseAccountUpdateParameters) (result DatabaseAccountsUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 +} + +// DatabaseAccountsUpdateThenPoll performs DatabaseAccountsUpdate then polls until it's completed +func (c CosmosDBClient) DatabaseAccountsUpdateThenPoll(ctx context.Context, id DatabaseAccountId, input DatabaseAccountUpdateParameters) error { + result, err := c.DatabaseAccountsUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DatabaseAccountsUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DatabaseAccountsUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaselistmetricdefinitions.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaselistmetricdefinitions.go new file mode 100644 index 00000000000..60cd6e072bc --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaselistmetricdefinitions.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 DatabaseListMetricDefinitionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MetricDefinitionsListResult +} + +// DatabaseListMetricDefinitions ... +func (c CosmosDBClient) DatabaseListMetricDefinitions(ctx context.Context, id DatabaseId) (result DatabaseListMetricDefinitionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/metricDefinitions", 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 MetricDefinitionsListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaselistmetrics.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaselistmetrics.go new file mode 100644 index 00000000000..77dc7d128cc --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaselistmetrics.go @@ -0,0 +1,83 @@ +package cosmosdb + +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 DatabaseListMetricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MetricListResult +} + +type DatabaseListMetricsOperationOptions struct { + Filter *string +} + +func DefaultDatabaseListMetricsOperationOptions() DatabaseListMetricsOperationOptions { + return DatabaseListMetricsOperationOptions{} +} + +func (o DatabaseListMetricsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DatabaseListMetricsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DatabaseListMetricsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// DatabaseListMetrics ... +func (c CosmosDBClient) DatabaseListMetrics(ctx context.Context, id DatabaseId, options DatabaseListMetricsOperationOptions) (result DatabaseListMetricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/metrics", 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 MetricListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaselistusages.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaselistusages.go new file mode 100644 index 00000000000..2d5907aa068 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_databaselistusages.go @@ -0,0 +1,83 @@ +package cosmosdb + +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 DatabaseListUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *UsagesResult +} + +type DatabaseListUsagesOperationOptions struct { + Filter *string +} + +func DefaultDatabaseListUsagesOperationOptions() DatabaseListUsagesOperationOptions { + return DatabaseListUsagesOperationOptions{} +} + +func (o DatabaseListUsagesOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DatabaseListUsagesOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DatabaseListUsagesOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// DatabaseListUsages ... +func (c CosmosDBClient) DatabaseListUsages(ctx context.Context, id DatabaseId, options DatabaseListUsagesOperationOptions) (result DatabaseListUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/usages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model UsagesResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcescreateupdategremlindatabase.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcescreateupdategremlindatabase.go new file mode 100644 index 00000000000..d476b5588ac --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcescreateupdategremlindatabase.go @@ -0,0 +1,75 @@ +package cosmosdb + +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 GremlinResourcesCreateUpdateGremlinDatabaseOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *GremlinDatabaseGetResults +} + +// GremlinResourcesCreateUpdateGremlinDatabase ... +func (c CosmosDBClient) GremlinResourcesCreateUpdateGremlinDatabase(ctx context.Context, id GremlinDatabaseId, input GremlinDatabaseCreateUpdateParameters) (result GremlinResourcesCreateUpdateGremlinDatabaseOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// GremlinResourcesCreateUpdateGremlinDatabaseThenPoll performs GremlinResourcesCreateUpdateGremlinDatabase then polls until it's completed +func (c CosmosDBClient) GremlinResourcesCreateUpdateGremlinDatabaseThenPoll(ctx context.Context, id GremlinDatabaseId, input GremlinDatabaseCreateUpdateParameters) error { + result, err := c.GremlinResourcesCreateUpdateGremlinDatabase(ctx, id, input) + if err != nil { + return fmt.Errorf("performing GremlinResourcesCreateUpdateGremlinDatabase: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GremlinResourcesCreateUpdateGremlinDatabase: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcescreateupdategremlingraph.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcescreateupdategremlingraph.go new file mode 100644 index 00000000000..382719da96d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcescreateupdategremlingraph.go @@ -0,0 +1,75 @@ +package cosmosdb + +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 GremlinResourcesCreateUpdateGremlinGraphOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *GremlinGraphGetResults +} + +// GremlinResourcesCreateUpdateGremlinGraph ... +func (c CosmosDBClient) GremlinResourcesCreateUpdateGremlinGraph(ctx context.Context, id GraphId, input GremlinGraphCreateUpdateParameters) (result GremlinResourcesCreateUpdateGremlinGraphOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// GremlinResourcesCreateUpdateGremlinGraphThenPoll performs GremlinResourcesCreateUpdateGremlinGraph then polls until it's completed +func (c CosmosDBClient) GremlinResourcesCreateUpdateGremlinGraphThenPoll(ctx context.Context, id GraphId, input GremlinGraphCreateUpdateParameters) error { + result, err := c.GremlinResourcesCreateUpdateGremlinGraph(ctx, id, input) + if err != nil { + return fmt.Errorf("performing GremlinResourcesCreateUpdateGremlinGraph: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GremlinResourcesCreateUpdateGremlinGraph: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesdeletegremlindatabase.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesdeletegremlindatabase.go new file mode 100644 index 00000000000..6980ce92dd2 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesdeletegremlindatabase.go @@ -0,0 +1,70 @@ +package cosmosdb + +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 GremlinResourcesDeleteGremlinDatabaseOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// GremlinResourcesDeleteGremlinDatabase ... +func (c CosmosDBClient) GremlinResourcesDeleteGremlinDatabase(ctx context.Context, id GremlinDatabaseId) (result GremlinResourcesDeleteGremlinDatabaseOperationResponse, 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 +} + +// GremlinResourcesDeleteGremlinDatabaseThenPoll performs GremlinResourcesDeleteGremlinDatabase then polls until it's completed +func (c CosmosDBClient) GremlinResourcesDeleteGremlinDatabaseThenPoll(ctx context.Context, id GremlinDatabaseId) error { + result, err := c.GremlinResourcesDeleteGremlinDatabase(ctx, id) + if err != nil { + return fmt.Errorf("performing GremlinResourcesDeleteGremlinDatabase: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GremlinResourcesDeleteGremlinDatabase: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesdeletegremlingraph.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesdeletegremlingraph.go new file mode 100644 index 00000000000..579e12a2a88 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesdeletegremlingraph.go @@ -0,0 +1,70 @@ +package cosmosdb + +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 GremlinResourcesDeleteGremlinGraphOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// GremlinResourcesDeleteGremlinGraph ... +func (c CosmosDBClient) GremlinResourcesDeleteGremlinGraph(ctx context.Context, id GraphId) (result GremlinResourcesDeleteGremlinGraphOperationResponse, 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 +} + +// GremlinResourcesDeleteGremlinGraphThenPoll performs GremlinResourcesDeleteGremlinGraph then polls until it's completed +func (c CosmosDBClient) GremlinResourcesDeleteGremlinGraphThenPoll(ctx context.Context, id GraphId) error { + result, err := c.GremlinResourcesDeleteGremlinGraph(ctx, id) + if err != nil { + return fmt.Errorf("performing GremlinResourcesDeleteGremlinGraph: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GremlinResourcesDeleteGremlinGraph: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesgetgremlindatabase.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesgetgremlindatabase.go new file mode 100644 index 00000000000..2be37b7e65e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesgetgremlindatabase.go @@ -0,0 +1,53 @@ +package cosmosdb + +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 GremlinResourcesGetGremlinDatabaseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GremlinDatabaseGetResults +} + +// GremlinResourcesGetGremlinDatabase ... +func (c CosmosDBClient) GremlinResourcesGetGremlinDatabase(ctx context.Context, id GremlinDatabaseId) (result GremlinResourcesGetGremlinDatabaseOperationResponse, 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 GremlinDatabaseGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesgetgremlindatabasethroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesgetgremlindatabasethroughput.go new file mode 100644 index 00000000000..497eb988e79 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesgetgremlindatabasethroughput.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 GremlinResourcesGetGremlinDatabaseThroughputOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// GremlinResourcesGetGremlinDatabaseThroughput ... +func (c CosmosDBClient) GremlinResourcesGetGremlinDatabaseThroughput(ctx context.Context, id GremlinDatabaseId) (result GremlinResourcesGetGremlinDatabaseThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/throughputSettings/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 ThroughputSettingsGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesgetgremlingraph.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesgetgremlingraph.go new file mode 100644 index 00000000000..3a72459fd70 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesgetgremlingraph.go @@ -0,0 +1,53 @@ +package cosmosdb + +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 GremlinResourcesGetGremlinGraphOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GremlinGraphGetResults +} + +// GremlinResourcesGetGremlinGraph ... +func (c CosmosDBClient) GremlinResourcesGetGremlinGraph(ctx context.Context, id GraphId) (result GremlinResourcesGetGremlinGraphOperationResponse, 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 GremlinGraphGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesgetgremlingraphthroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesgetgremlingraphthroughput.go new file mode 100644 index 00000000000..29469526c52 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesgetgremlingraphthroughput.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 GremlinResourcesGetGremlinGraphThroughputOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// GremlinResourcesGetGremlinGraphThroughput ... +func (c CosmosDBClient) GremlinResourcesGetGremlinGraphThroughput(ctx context.Context, id GraphId) (result GremlinResourcesGetGremlinGraphThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/throughputSettings/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 ThroughputSettingsGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourceslistgremlindatabases.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourceslistgremlindatabases.go new file mode 100644 index 00000000000..48bf17fd940 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourceslistgremlindatabases.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 GremlinResourcesListGremlinDatabasesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GremlinDatabaseListResult +} + +// GremlinResourcesListGremlinDatabases ... +func (c CosmosDBClient) GremlinResourcesListGremlinDatabases(ctx context.Context, id DatabaseAccountId) (result GremlinResourcesListGremlinDatabasesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/gremlinDatabases", 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 GremlinDatabaseListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourceslistgremlingraphs.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourceslistgremlingraphs.go new file mode 100644 index 00000000000..97e332b3d32 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourceslistgremlingraphs.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 GremlinResourcesListGremlinGraphsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GremlinGraphListResult +} + +// GremlinResourcesListGremlinGraphs ... +func (c CosmosDBClient) GremlinResourcesListGremlinGraphs(ctx context.Context, id GremlinDatabaseId) (result GremlinResourcesListGremlinGraphsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/graphs", 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 GremlinGraphListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesmigrategremlindatabasetoautoscale.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesmigrategremlindatabasetoautoscale.go new file mode 100644 index 00000000000..3c088dc9b32 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesmigrategremlindatabasetoautoscale.go @@ -0,0 +1,71 @@ +package cosmosdb + +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 GremlinResourcesMigrateGremlinDatabaseToAutoscaleOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// GremlinResourcesMigrateGremlinDatabaseToAutoscale ... +func (c CosmosDBClient) GremlinResourcesMigrateGremlinDatabaseToAutoscale(ctx context.Context, id GremlinDatabaseId) (result GremlinResourcesMigrateGremlinDatabaseToAutoscaleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/throughputSettings/default/migrateToAutoscale", 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 +} + +// GremlinResourcesMigrateGremlinDatabaseToAutoscaleThenPoll performs GremlinResourcesMigrateGremlinDatabaseToAutoscale then polls until it's completed +func (c CosmosDBClient) GremlinResourcesMigrateGremlinDatabaseToAutoscaleThenPoll(ctx context.Context, id GremlinDatabaseId) error { + result, err := c.GremlinResourcesMigrateGremlinDatabaseToAutoscale(ctx, id) + if err != nil { + return fmt.Errorf("performing GremlinResourcesMigrateGremlinDatabaseToAutoscale: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GremlinResourcesMigrateGremlinDatabaseToAutoscale: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesmigrategremlindatabasetomanualthroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesmigrategremlindatabasetomanualthroughput.go new file mode 100644 index 00000000000..ac02e95a8bc --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesmigrategremlindatabasetomanualthroughput.go @@ -0,0 +1,71 @@ +package cosmosdb + +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 GremlinResourcesMigrateGremlinDatabaseToManualThroughputOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// GremlinResourcesMigrateGremlinDatabaseToManualThroughput ... +func (c CosmosDBClient) GremlinResourcesMigrateGremlinDatabaseToManualThroughput(ctx context.Context, id GremlinDatabaseId) (result GremlinResourcesMigrateGremlinDatabaseToManualThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/throughputSettings/default/migrateToManualThroughput", 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 +} + +// GremlinResourcesMigrateGremlinDatabaseToManualThroughputThenPoll performs GremlinResourcesMigrateGremlinDatabaseToManualThroughput then polls until it's completed +func (c CosmosDBClient) GremlinResourcesMigrateGremlinDatabaseToManualThroughputThenPoll(ctx context.Context, id GremlinDatabaseId) error { + result, err := c.GremlinResourcesMigrateGremlinDatabaseToManualThroughput(ctx, id) + if err != nil { + return fmt.Errorf("performing GremlinResourcesMigrateGremlinDatabaseToManualThroughput: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GremlinResourcesMigrateGremlinDatabaseToManualThroughput: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesmigrategremlingraphtoautoscale.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesmigrategremlingraphtoautoscale.go new file mode 100644 index 00000000000..0503f9d5352 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesmigrategremlingraphtoautoscale.go @@ -0,0 +1,71 @@ +package cosmosdb + +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 GremlinResourcesMigrateGremlinGraphToAutoscaleOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// GremlinResourcesMigrateGremlinGraphToAutoscale ... +func (c CosmosDBClient) GremlinResourcesMigrateGremlinGraphToAutoscale(ctx context.Context, id GraphId) (result GremlinResourcesMigrateGremlinGraphToAutoscaleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/throughputSettings/default/migrateToAutoscale", 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 +} + +// GremlinResourcesMigrateGremlinGraphToAutoscaleThenPoll performs GremlinResourcesMigrateGremlinGraphToAutoscale then polls until it's completed +func (c CosmosDBClient) GremlinResourcesMigrateGremlinGraphToAutoscaleThenPoll(ctx context.Context, id GraphId) error { + result, err := c.GremlinResourcesMigrateGremlinGraphToAutoscale(ctx, id) + if err != nil { + return fmt.Errorf("performing GremlinResourcesMigrateGremlinGraphToAutoscale: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GremlinResourcesMigrateGremlinGraphToAutoscale: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesmigrategremlingraphtomanualthroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesmigrategremlingraphtomanualthroughput.go new file mode 100644 index 00000000000..17e1c2903f6 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesmigrategremlingraphtomanualthroughput.go @@ -0,0 +1,71 @@ +package cosmosdb + +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 GremlinResourcesMigrateGremlinGraphToManualThroughputOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// GremlinResourcesMigrateGremlinGraphToManualThroughput ... +func (c CosmosDBClient) GremlinResourcesMigrateGremlinGraphToManualThroughput(ctx context.Context, id GraphId) (result GremlinResourcesMigrateGremlinGraphToManualThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/throughputSettings/default/migrateToManualThroughput", 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 +} + +// GremlinResourcesMigrateGremlinGraphToManualThroughputThenPoll performs GremlinResourcesMigrateGremlinGraphToManualThroughput then polls until it's completed +func (c CosmosDBClient) GremlinResourcesMigrateGremlinGraphToManualThroughputThenPoll(ctx context.Context, id GraphId) error { + result, err := c.GremlinResourcesMigrateGremlinGraphToManualThroughput(ctx, id) + if err != nil { + return fmt.Errorf("performing GremlinResourcesMigrateGremlinGraphToManualThroughput: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GremlinResourcesMigrateGremlinGraphToManualThroughput: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesupdategremlindatabasethroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesupdategremlindatabasethroughput.go new file mode 100644 index 00000000000..f0245f84c69 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesupdategremlindatabasethroughput.go @@ -0,0 +1,75 @@ +package cosmosdb + +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 GremlinResourcesUpdateGremlinDatabaseThroughputOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// GremlinResourcesUpdateGremlinDatabaseThroughput ... +func (c CosmosDBClient) GremlinResourcesUpdateGremlinDatabaseThroughput(ctx context.Context, id GremlinDatabaseId, input ThroughputSettingsUpdateParameters) (result GremlinResourcesUpdateGremlinDatabaseThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/throughputSettings/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 +} + +// GremlinResourcesUpdateGremlinDatabaseThroughputThenPoll performs GremlinResourcesUpdateGremlinDatabaseThroughput then polls until it's completed +func (c CosmosDBClient) GremlinResourcesUpdateGremlinDatabaseThroughputThenPoll(ctx context.Context, id GremlinDatabaseId, input ThroughputSettingsUpdateParameters) error { + result, err := c.GremlinResourcesUpdateGremlinDatabaseThroughput(ctx, id, input) + if err != nil { + return fmt.Errorf("performing GremlinResourcesUpdateGremlinDatabaseThroughput: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GremlinResourcesUpdateGremlinDatabaseThroughput: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesupdategremlingraphthroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesupdategremlingraphthroughput.go new file mode 100644 index 00000000000..24088fcdd36 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_gremlinresourcesupdategremlingraphthroughput.go @@ -0,0 +1,75 @@ +package cosmosdb + +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 GremlinResourcesUpdateGremlinGraphThroughputOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// GremlinResourcesUpdateGremlinGraphThroughput ... +func (c CosmosDBClient) GremlinResourcesUpdateGremlinGraphThroughput(ctx context.Context, id GraphId, input ThroughputSettingsUpdateParameters) (result GremlinResourcesUpdateGremlinGraphThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/throughputSettings/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 +} + +// GremlinResourcesUpdateGremlinGraphThroughputThenPoll performs GremlinResourcesUpdateGremlinGraphThroughput then polls until it's completed +func (c CosmosDBClient) GremlinResourcesUpdateGremlinGraphThroughputThenPoll(ctx context.Context, id GraphId, input ThroughputSettingsUpdateParameters) error { + result, err := c.GremlinResourcesUpdateGremlinGraphThroughput(ctx, id, input) + if err != nil { + return fmt.Errorf("performing GremlinResourcesUpdateGremlinGraphThroughput: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GremlinResourcesUpdateGremlinGraphThroughput: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_locationsget.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_locationsget.go new file mode 100644 index 00000000000..1bcf857f623 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_locationsget.go @@ -0,0 +1,53 @@ +package cosmosdb + +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 LocationsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LocationGetResult +} + +// LocationsGet ... +func (c CosmosDBClient) LocationsGet(ctx context.Context, id LocationId) (result LocationsGetOperationResponse, 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 LocationGetResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_locationslist.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_locationslist.go new file mode 100644 index 00000000000..3d3b8a3c99e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_locationslist.go @@ -0,0 +1,55 @@ +package cosmosdb + +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 LocationsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LocationListResult +} + +// LocationsList ... +func (c CosmosDBClient) LocationsList(ctx context.Context, id commonids.SubscriptionId) (result LocationsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DocumentDB/locations", 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 LocationListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcescreateupdatemongodbcollection.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcescreateupdatemongodbcollection.go new file mode 100644 index 00000000000..cf9e0087685 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcescreateupdatemongodbcollection.go @@ -0,0 +1,75 @@ +package cosmosdb + +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 MongoDBResourcesCreateUpdateMongoDBCollectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MongoDBCollectionGetResults +} + +// MongoDBResourcesCreateUpdateMongoDBCollection ... +func (c CosmosDBClient) MongoDBResourcesCreateUpdateMongoDBCollection(ctx context.Context, id MongodbDatabaseCollectionId, input MongoDBCollectionCreateUpdateParameters) (result MongoDBResourcesCreateUpdateMongoDBCollectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// MongoDBResourcesCreateUpdateMongoDBCollectionThenPoll performs MongoDBResourcesCreateUpdateMongoDBCollection then polls until it's completed +func (c CosmosDBClient) MongoDBResourcesCreateUpdateMongoDBCollectionThenPoll(ctx context.Context, id MongodbDatabaseCollectionId, input MongoDBCollectionCreateUpdateParameters) error { + result, err := c.MongoDBResourcesCreateUpdateMongoDBCollection(ctx, id, input) + if err != nil { + return fmt.Errorf("performing MongoDBResourcesCreateUpdateMongoDBCollection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MongoDBResourcesCreateUpdateMongoDBCollection: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcescreateupdatemongodbdatabase.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcescreateupdatemongodbdatabase.go new file mode 100644 index 00000000000..027a5f8ac38 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcescreateupdatemongodbdatabase.go @@ -0,0 +1,75 @@ +package cosmosdb + +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 MongoDBResourcesCreateUpdateMongoDBDatabaseOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MongoDBDatabaseGetResults +} + +// MongoDBResourcesCreateUpdateMongoDBDatabase ... +func (c CosmosDBClient) MongoDBResourcesCreateUpdateMongoDBDatabase(ctx context.Context, id MongodbDatabaseId, input MongoDBDatabaseCreateUpdateParameters) (result MongoDBResourcesCreateUpdateMongoDBDatabaseOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// MongoDBResourcesCreateUpdateMongoDBDatabaseThenPoll performs MongoDBResourcesCreateUpdateMongoDBDatabase then polls until it's completed +func (c CosmosDBClient) MongoDBResourcesCreateUpdateMongoDBDatabaseThenPoll(ctx context.Context, id MongodbDatabaseId, input MongoDBDatabaseCreateUpdateParameters) error { + result, err := c.MongoDBResourcesCreateUpdateMongoDBDatabase(ctx, id, input) + if err != nil { + return fmt.Errorf("performing MongoDBResourcesCreateUpdateMongoDBDatabase: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MongoDBResourcesCreateUpdateMongoDBDatabase: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesdeletemongodbcollection.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesdeletemongodbcollection.go new file mode 100644 index 00000000000..b209f12b15b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesdeletemongodbcollection.go @@ -0,0 +1,70 @@ +package cosmosdb + +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 MongoDBResourcesDeleteMongoDBCollectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// MongoDBResourcesDeleteMongoDBCollection ... +func (c CosmosDBClient) MongoDBResourcesDeleteMongoDBCollection(ctx context.Context, id MongodbDatabaseCollectionId) (result MongoDBResourcesDeleteMongoDBCollectionOperationResponse, 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 +} + +// MongoDBResourcesDeleteMongoDBCollectionThenPoll performs MongoDBResourcesDeleteMongoDBCollection then polls until it's completed +func (c CosmosDBClient) MongoDBResourcesDeleteMongoDBCollectionThenPoll(ctx context.Context, id MongodbDatabaseCollectionId) error { + result, err := c.MongoDBResourcesDeleteMongoDBCollection(ctx, id) + if err != nil { + return fmt.Errorf("performing MongoDBResourcesDeleteMongoDBCollection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MongoDBResourcesDeleteMongoDBCollection: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesdeletemongodbdatabase.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesdeletemongodbdatabase.go new file mode 100644 index 00000000000..bbd6677b208 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesdeletemongodbdatabase.go @@ -0,0 +1,70 @@ +package cosmosdb + +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 MongoDBResourcesDeleteMongoDBDatabaseOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// MongoDBResourcesDeleteMongoDBDatabase ... +func (c CosmosDBClient) MongoDBResourcesDeleteMongoDBDatabase(ctx context.Context, id MongodbDatabaseId) (result MongoDBResourcesDeleteMongoDBDatabaseOperationResponse, 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 +} + +// MongoDBResourcesDeleteMongoDBDatabaseThenPoll performs MongoDBResourcesDeleteMongoDBDatabase then polls until it's completed +func (c CosmosDBClient) MongoDBResourcesDeleteMongoDBDatabaseThenPoll(ctx context.Context, id MongodbDatabaseId) error { + result, err := c.MongoDBResourcesDeleteMongoDBDatabase(ctx, id) + if err != nil { + return fmt.Errorf("performing MongoDBResourcesDeleteMongoDBDatabase: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MongoDBResourcesDeleteMongoDBDatabase: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesgetmongodbcollection.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesgetmongodbcollection.go new file mode 100644 index 00000000000..9296bf8ab51 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesgetmongodbcollection.go @@ -0,0 +1,53 @@ +package cosmosdb + +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 MongoDBResourcesGetMongoDBCollectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MongoDBCollectionGetResults +} + +// MongoDBResourcesGetMongoDBCollection ... +func (c CosmosDBClient) MongoDBResourcesGetMongoDBCollection(ctx context.Context, id MongodbDatabaseCollectionId) (result MongoDBResourcesGetMongoDBCollectionOperationResponse, 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 MongoDBCollectionGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesgetmongodbcollectionthroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesgetmongodbcollectionthroughput.go new file mode 100644 index 00000000000..ef4212d2237 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesgetmongodbcollectionthroughput.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 MongoDBResourcesGetMongoDBCollectionThroughputOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// MongoDBResourcesGetMongoDBCollectionThroughput ... +func (c CosmosDBClient) MongoDBResourcesGetMongoDBCollectionThroughput(ctx context.Context, id MongodbDatabaseCollectionId) (result MongoDBResourcesGetMongoDBCollectionThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/throughputSettings/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 ThroughputSettingsGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesgetmongodbdatabase.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesgetmongodbdatabase.go new file mode 100644 index 00000000000..af37b27fdc8 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesgetmongodbdatabase.go @@ -0,0 +1,53 @@ +package cosmosdb + +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 MongoDBResourcesGetMongoDBDatabaseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MongoDBDatabaseGetResults +} + +// MongoDBResourcesGetMongoDBDatabase ... +func (c CosmosDBClient) MongoDBResourcesGetMongoDBDatabase(ctx context.Context, id MongodbDatabaseId) (result MongoDBResourcesGetMongoDBDatabaseOperationResponse, 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 MongoDBDatabaseGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesgetmongodbdatabasethroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesgetmongodbdatabasethroughput.go new file mode 100644 index 00000000000..424444e72fc --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesgetmongodbdatabasethroughput.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 MongoDBResourcesGetMongoDBDatabaseThroughputOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// MongoDBResourcesGetMongoDBDatabaseThroughput ... +func (c CosmosDBClient) MongoDBResourcesGetMongoDBDatabaseThroughput(ctx context.Context, id MongodbDatabaseId) (result MongoDBResourcesGetMongoDBDatabaseThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/throughputSettings/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 ThroughputSettingsGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourceslistmongodbcollections.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourceslistmongodbcollections.go new file mode 100644 index 00000000000..b1404d5a8d1 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourceslistmongodbcollections.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 MongoDBResourcesListMongoDBCollectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MongoDBCollectionListResult +} + +// MongoDBResourcesListMongoDBCollections ... +func (c CosmosDBClient) MongoDBResourcesListMongoDBCollections(ctx context.Context, id MongodbDatabaseId) (result MongoDBResourcesListMongoDBCollectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/collections", 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 MongoDBCollectionListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourceslistmongodbdatabases.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourceslistmongodbdatabases.go new file mode 100644 index 00000000000..1144c74833b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourceslistmongodbdatabases.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 MongoDBResourcesListMongoDBDatabasesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MongoDBDatabaseListResult +} + +// MongoDBResourcesListMongoDBDatabases ... +func (c CosmosDBClient) MongoDBResourcesListMongoDBDatabases(ctx context.Context, id DatabaseAccountId) (result MongoDBResourcesListMongoDBDatabasesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/mongodbDatabases", 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 MongoDBDatabaseListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesmigratemongodbcollectiontoautoscale.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesmigratemongodbcollectiontoautoscale.go new file mode 100644 index 00000000000..a8f37152291 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesmigratemongodbcollectiontoautoscale.go @@ -0,0 +1,71 @@ +package cosmosdb + +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 MongoDBResourcesMigrateMongoDBCollectionToAutoscaleOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// MongoDBResourcesMigrateMongoDBCollectionToAutoscale ... +func (c CosmosDBClient) MongoDBResourcesMigrateMongoDBCollectionToAutoscale(ctx context.Context, id MongodbDatabaseCollectionId) (result MongoDBResourcesMigrateMongoDBCollectionToAutoscaleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/throughputSettings/default/migrateToAutoscale", 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 +} + +// MongoDBResourcesMigrateMongoDBCollectionToAutoscaleThenPoll performs MongoDBResourcesMigrateMongoDBCollectionToAutoscale then polls until it's completed +func (c CosmosDBClient) MongoDBResourcesMigrateMongoDBCollectionToAutoscaleThenPoll(ctx context.Context, id MongodbDatabaseCollectionId) error { + result, err := c.MongoDBResourcesMigrateMongoDBCollectionToAutoscale(ctx, id) + if err != nil { + return fmt.Errorf("performing MongoDBResourcesMigrateMongoDBCollectionToAutoscale: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MongoDBResourcesMigrateMongoDBCollectionToAutoscale: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesmigratemongodbcollectiontomanualthroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesmigratemongodbcollectiontomanualthroughput.go new file mode 100644 index 00000000000..4883b420a9b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesmigratemongodbcollectiontomanualthroughput.go @@ -0,0 +1,71 @@ +package cosmosdb + +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 MongoDBResourcesMigrateMongoDBCollectionToManualThroughputOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// MongoDBResourcesMigrateMongoDBCollectionToManualThroughput ... +func (c CosmosDBClient) MongoDBResourcesMigrateMongoDBCollectionToManualThroughput(ctx context.Context, id MongodbDatabaseCollectionId) (result MongoDBResourcesMigrateMongoDBCollectionToManualThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/throughputSettings/default/migrateToManualThroughput", 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 +} + +// MongoDBResourcesMigrateMongoDBCollectionToManualThroughputThenPoll performs MongoDBResourcesMigrateMongoDBCollectionToManualThroughput then polls until it's completed +func (c CosmosDBClient) MongoDBResourcesMigrateMongoDBCollectionToManualThroughputThenPoll(ctx context.Context, id MongodbDatabaseCollectionId) error { + result, err := c.MongoDBResourcesMigrateMongoDBCollectionToManualThroughput(ctx, id) + if err != nil { + return fmt.Errorf("performing MongoDBResourcesMigrateMongoDBCollectionToManualThroughput: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MongoDBResourcesMigrateMongoDBCollectionToManualThroughput: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesmigratemongodbdatabasetoautoscale.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesmigratemongodbdatabasetoautoscale.go new file mode 100644 index 00000000000..c3da7d65d8b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesmigratemongodbdatabasetoautoscale.go @@ -0,0 +1,71 @@ +package cosmosdb + +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 MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// MongoDBResourcesMigrateMongoDBDatabaseToAutoscale ... +func (c CosmosDBClient) MongoDBResourcesMigrateMongoDBDatabaseToAutoscale(ctx context.Context, id MongodbDatabaseId) (result MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/throughputSettings/default/migrateToAutoscale", 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 +} + +// MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleThenPoll performs MongoDBResourcesMigrateMongoDBDatabaseToAutoscale then polls until it's completed +func (c CosmosDBClient) MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleThenPoll(ctx context.Context, id MongodbDatabaseId) error { + result, err := c.MongoDBResourcesMigrateMongoDBDatabaseToAutoscale(ctx, id) + if err != nil { + return fmt.Errorf("performing MongoDBResourcesMigrateMongoDBDatabaseToAutoscale: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MongoDBResourcesMigrateMongoDBDatabaseToAutoscale: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesmigratemongodbdatabasetomanualthroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesmigratemongodbdatabasetomanualthroughput.go new file mode 100644 index 00000000000..3819aa5aad7 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesmigratemongodbdatabasetomanualthroughput.go @@ -0,0 +1,71 @@ +package cosmosdb + +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 MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// MongoDBResourcesMigrateMongoDBDatabaseToManualThroughput ... +func (c CosmosDBClient) MongoDBResourcesMigrateMongoDBDatabaseToManualThroughput(ctx context.Context, id MongodbDatabaseId) (result MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/throughputSettings/default/migrateToManualThroughput", 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 +} + +// MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputThenPoll performs MongoDBResourcesMigrateMongoDBDatabaseToManualThroughput then polls until it's completed +func (c CosmosDBClient) MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputThenPoll(ctx context.Context, id MongodbDatabaseId) error { + result, err := c.MongoDBResourcesMigrateMongoDBDatabaseToManualThroughput(ctx, id) + if err != nil { + return fmt.Errorf("performing MongoDBResourcesMigrateMongoDBDatabaseToManualThroughput: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MongoDBResourcesMigrateMongoDBDatabaseToManualThroughput: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesupdatemongodbcollectionthroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesupdatemongodbcollectionthroughput.go new file mode 100644 index 00000000000..1a1687d68c6 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesupdatemongodbcollectionthroughput.go @@ -0,0 +1,75 @@ +package cosmosdb + +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 MongoDBResourcesUpdateMongoDBCollectionThroughputOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// MongoDBResourcesUpdateMongoDBCollectionThroughput ... +func (c CosmosDBClient) MongoDBResourcesUpdateMongoDBCollectionThroughput(ctx context.Context, id MongodbDatabaseCollectionId, input ThroughputSettingsUpdateParameters) (result MongoDBResourcesUpdateMongoDBCollectionThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/throughputSettings/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 +} + +// MongoDBResourcesUpdateMongoDBCollectionThroughputThenPoll performs MongoDBResourcesUpdateMongoDBCollectionThroughput then polls until it's completed +func (c CosmosDBClient) MongoDBResourcesUpdateMongoDBCollectionThroughputThenPoll(ctx context.Context, id MongodbDatabaseCollectionId, input ThroughputSettingsUpdateParameters) error { + result, err := c.MongoDBResourcesUpdateMongoDBCollectionThroughput(ctx, id, input) + if err != nil { + return fmt.Errorf("performing MongoDBResourcesUpdateMongoDBCollectionThroughput: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MongoDBResourcesUpdateMongoDBCollectionThroughput: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesupdatemongodbdatabasethroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesupdatemongodbdatabasethroughput.go new file mode 100644 index 00000000000..5c26d9f4023 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_mongodbresourcesupdatemongodbdatabasethroughput.go @@ -0,0 +1,75 @@ +package cosmosdb + +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 MongoDBResourcesUpdateMongoDBDatabaseThroughputOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// MongoDBResourcesUpdateMongoDBDatabaseThroughput ... +func (c CosmosDBClient) MongoDBResourcesUpdateMongoDBDatabaseThroughput(ctx context.Context, id MongodbDatabaseId, input ThroughputSettingsUpdateParameters) (result MongoDBResourcesUpdateMongoDBDatabaseThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/throughputSettings/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 +} + +// MongoDBResourcesUpdateMongoDBDatabaseThroughputThenPoll performs MongoDBResourcesUpdateMongoDBDatabaseThroughput then polls until it's completed +func (c CosmosDBClient) MongoDBResourcesUpdateMongoDBDatabaseThroughputThenPoll(ctx context.Context, id MongodbDatabaseId, input ThroughputSettingsUpdateParameters) error { + result, err := c.MongoDBResourcesUpdateMongoDBDatabaseThroughput(ctx, id, input) + if err != nil { + return fmt.Errorf("performing MongoDBResourcesUpdateMongoDBDatabaseThroughput: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MongoDBResourcesUpdateMongoDBDatabaseThroughput: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_partitionkeyrangeidlistmetrics.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_partitionkeyrangeidlistmetrics.go new file mode 100644 index 00000000000..dd48b8f3546 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_partitionkeyrangeidlistmetrics.go @@ -0,0 +1,83 @@ +package cosmosdb + +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 PartitionKeyRangeIdListMetricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PartitionMetricListResult +} + +type PartitionKeyRangeIdListMetricsOperationOptions struct { + Filter *string +} + +func DefaultPartitionKeyRangeIdListMetricsOperationOptions() PartitionKeyRangeIdListMetricsOperationOptions { + return PartitionKeyRangeIdListMetricsOperationOptions{} +} + +func (o PartitionKeyRangeIdListMetricsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o PartitionKeyRangeIdListMetricsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o PartitionKeyRangeIdListMetricsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// PartitionKeyRangeIdListMetrics ... +func (c CosmosDBClient) PartitionKeyRangeIdListMetrics(ctx context.Context, id PartitionKeyRangeIdId, options PartitionKeyRangeIdListMetricsOperationOptions) (result PartitionKeyRangeIdListMetricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/metrics", 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 PartitionMetricListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_partitionkeyrangeidregionlistmetrics.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_partitionkeyrangeidregionlistmetrics.go new file mode 100644 index 00000000000..4683537bc32 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_partitionkeyrangeidregionlistmetrics.go @@ -0,0 +1,83 @@ +package cosmosdb + +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 PartitionKeyRangeIdRegionListMetricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PartitionMetricListResult +} + +type PartitionKeyRangeIdRegionListMetricsOperationOptions struct { + Filter *string +} + +func DefaultPartitionKeyRangeIdRegionListMetricsOperationOptions() PartitionKeyRangeIdRegionListMetricsOperationOptions { + return PartitionKeyRangeIdRegionListMetricsOperationOptions{} +} + +func (o PartitionKeyRangeIdRegionListMetricsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o PartitionKeyRangeIdRegionListMetricsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o PartitionKeyRangeIdRegionListMetricsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// PartitionKeyRangeIdRegionListMetrics ... +func (c CosmosDBClient) PartitionKeyRangeIdRegionListMetrics(ctx context.Context, id CollectionPartitionKeyRangeIdId, options PartitionKeyRangeIdRegionListMetricsOperationOptions) (result PartitionKeyRangeIdRegionListMetricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/metrics", 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 PartitionMetricListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_percentilelistmetrics.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_percentilelistmetrics.go new file mode 100644 index 00000000000..e47c0b30189 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_percentilelistmetrics.go @@ -0,0 +1,83 @@ +package cosmosdb + +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 PercentileListMetricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PercentileMetricListResult +} + +type PercentileListMetricsOperationOptions struct { + Filter *string +} + +func DefaultPercentileListMetricsOperationOptions() PercentileListMetricsOperationOptions { + return PercentileListMetricsOperationOptions{} +} + +func (o PercentileListMetricsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o PercentileListMetricsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o PercentileListMetricsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// PercentileListMetrics ... +func (c CosmosDBClient) PercentileListMetrics(ctx context.Context, id DatabaseAccountId, options PercentileListMetricsOperationOptions) (result PercentileListMetricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/percentile/metrics", 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 PercentileMetricListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_percentilesourcetargetlistmetrics.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_percentilesourcetargetlistmetrics.go new file mode 100644 index 00000000000..0a8441c8ce3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_percentilesourcetargetlistmetrics.go @@ -0,0 +1,83 @@ +package cosmosdb + +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 PercentileSourceTargetListMetricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PercentileMetricListResult +} + +type PercentileSourceTargetListMetricsOperationOptions struct { + Filter *string +} + +func DefaultPercentileSourceTargetListMetricsOperationOptions() PercentileSourceTargetListMetricsOperationOptions { + return PercentileSourceTargetListMetricsOperationOptions{} +} + +func (o PercentileSourceTargetListMetricsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o PercentileSourceTargetListMetricsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o PercentileSourceTargetListMetricsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// PercentileSourceTargetListMetrics ... +func (c CosmosDBClient) PercentileSourceTargetListMetrics(ctx context.Context, id SourceRegionTargetRegionId, options PercentileSourceTargetListMetricsOperationOptions) (result PercentileSourceTargetListMetricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/percentile/metrics", 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 PercentileMetricListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_percentiletargetlistmetrics.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_percentiletargetlistmetrics.go new file mode 100644 index 00000000000..af6ff16b4e3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_percentiletargetlistmetrics.go @@ -0,0 +1,83 @@ +package cosmosdb + +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 PercentileTargetListMetricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PercentileMetricListResult +} + +type PercentileTargetListMetricsOperationOptions struct { + Filter *string +} + +func DefaultPercentileTargetListMetricsOperationOptions() PercentileTargetListMetricsOperationOptions { + return PercentileTargetListMetricsOperationOptions{} +} + +func (o PercentileTargetListMetricsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o PercentileTargetListMetricsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o PercentileTargetListMetricsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// PercentileTargetListMetrics ... +func (c CosmosDBClient) PercentileTargetListMetrics(ctx context.Context, id TargetRegionId, options PercentileTargetListMetricsOperationOptions) (result PercentileTargetListMetricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/percentile/metrics", 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 PercentileMetricListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcescreateupdateclientencryptionkey.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcescreateupdateclientencryptionkey.go new file mode 100644 index 00000000000..7c396f57ab1 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcescreateupdateclientencryptionkey.go @@ -0,0 +1,75 @@ +package cosmosdb + +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 SqlResourcesCreateUpdateClientEncryptionKeyOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ClientEncryptionKeyGetResults +} + +// SqlResourcesCreateUpdateClientEncryptionKey ... +func (c CosmosDBClient) SqlResourcesCreateUpdateClientEncryptionKey(ctx context.Context, id ClientEncryptionKeyId, input ClientEncryptionKeyCreateUpdateParameters) (result SqlResourcesCreateUpdateClientEncryptionKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// SqlResourcesCreateUpdateClientEncryptionKeyThenPoll performs SqlResourcesCreateUpdateClientEncryptionKey then polls until it's completed +func (c CosmosDBClient) SqlResourcesCreateUpdateClientEncryptionKeyThenPoll(ctx context.Context, id ClientEncryptionKeyId, input ClientEncryptionKeyCreateUpdateParameters) error { + result, err := c.SqlResourcesCreateUpdateClientEncryptionKey(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SqlResourcesCreateUpdateClientEncryptionKey: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SqlResourcesCreateUpdateClientEncryptionKey: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcescreateupdatesqlcontainer.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcescreateupdatesqlcontainer.go new file mode 100644 index 00000000000..b227194c724 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcescreateupdatesqlcontainer.go @@ -0,0 +1,75 @@ +package cosmosdb + +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 SqlResourcesCreateUpdateSqlContainerOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SqlContainerGetResults +} + +// SqlResourcesCreateUpdateSqlContainer ... +func (c CosmosDBClient) SqlResourcesCreateUpdateSqlContainer(ctx context.Context, id ContainerId, input SqlContainerCreateUpdateParameters) (result SqlResourcesCreateUpdateSqlContainerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// SqlResourcesCreateUpdateSqlContainerThenPoll performs SqlResourcesCreateUpdateSqlContainer then polls until it's completed +func (c CosmosDBClient) SqlResourcesCreateUpdateSqlContainerThenPoll(ctx context.Context, id ContainerId, input SqlContainerCreateUpdateParameters) error { + result, err := c.SqlResourcesCreateUpdateSqlContainer(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SqlResourcesCreateUpdateSqlContainer: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SqlResourcesCreateUpdateSqlContainer: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcescreateupdatesqldatabase.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcescreateupdatesqldatabase.go new file mode 100644 index 00000000000..22b25710f9c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcescreateupdatesqldatabase.go @@ -0,0 +1,75 @@ +package cosmosdb + +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 SqlResourcesCreateUpdateSqlDatabaseOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SqlDatabaseGetResults +} + +// SqlResourcesCreateUpdateSqlDatabase ... +func (c CosmosDBClient) SqlResourcesCreateUpdateSqlDatabase(ctx context.Context, id SqlDatabaseId, input SqlDatabaseCreateUpdateParameters) (result SqlResourcesCreateUpdateSqlDatabaseOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// SqlResourcesCreateUpdateSqlDatabaseThenPoll performs SqlResourcesCreateUpdateSqlDatabase then polls until it's completed +func (c CosmosDBClient) SqlResourcesCreateUpdateSqlDatabaseThenPoll(ctx context.Context, id SqlDatabaseId, input SqlDatabaseCreateUpdateParameters) error { + result, err := c.SqlResourcesCreateUpdateSqlDatabase(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SqlResourcesCreateUpdateSqlDatabase: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SqlResourcesCreateUpdateSqlDatabase: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcescreateupdatesqlstoredprocedure.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcescreateupdatesqlstoredprocedure.go new file mode 100644 index 00000000000..d7d2216d392 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcescreateupdatesqlstoredprocedure.go @@ -0,0 +1,75 @@ +package cosmosdb + +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 SqlResourcesCreateUpdateSqlStoredProcedureOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SqlStoredProcedureGetResults +} + +// SqlResourcesCreateUpdateSqlStoredProcedure ... +func (c CosmosDBClient) SqlResourcesCreateUpdateSqlStoredProcedure(ctx context.Context, id StoredProcedureId, input SqlStoredProcedureCreateUpdateParameters) (result SqlResourcesCreateUpdateSqlStoredProcedureOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// SqlResourcesCreateUpdateSqlStoredProcedureThenPoll performs SqlResourcesCreateUpdateSqlStoredProcedure then polls until it's completed +func (c CosmosDBClient) SqlResourcesCreateUpdateSqlStoredProcedureThenPoll(ctx context.Context, id StoredProcedureId, input SqlStoredProcedureCreateUpdateParameters) error { + result, err := c.SqlResourcesCreateUpdateSqlStoredProcedure(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SqlResourcesCreateUpdateSqlStoredProcedure: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SqlResourcesCreateUpdateSqlStoredProcedure: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcescreateupdatesqltrigger.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcescreateupdatesqltrigger.go new file mode 100644 index 00000000000..cb99af11d3c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcescreateupdatesqltrigger.go @@ -0,0 +1,75 @@ +package cosmosdb + +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 SqlResourcesCreateUpdateSqlTriggerOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SqlTriggerGetResults +} + +// SqlResourcesCreateUpdateSqlTrigger ... +func (c CosmosDBClient) SqlResourcesCreateUpdateSqlTrigger(ctx context.Context, id TriggerId, input SqlTriggerCreateUpdateParameters) (result SqlResourcesCreateUpdateSqlTriggerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// SqlResourcesCreateUpdateSqlTriggerThenPoll performs SqlResourcesCreateUpdateSqlTrigger then polls until it's completed +func (c CosmosDBClient) SqlResourcesCreateUpdateSqlTriggerThenPoll(ctx context.Context, id TriggerId, input SqlTriggerCreateUpdateParameters) error { + result, err := c.SqlResourcesCreateUpdateSqlTrigger(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SqlResourcesCreateUpdateSqlTrigger: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SqlResourcesCreateUpdateSqlTrigger: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcescreateupdatesqluserdefinedfunction.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcescreateupdatesqluserdefinedfunction.go new file mode 100644 index 00000000000..446ed80c5de --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcescreateupdatesqluserdefinedfunction.go @@ -0,0 +1,75 @@ +package cosmosdb + +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 SqlResourcesCreateUpdateSqlUserDefinedFunctionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SqlUserDefinedFunctionGetResults +} + +// SqlResourcesCreateUpdateSqlUserDefinedFunction ... +func (c CosmosDBClient) SqlResourcesCreateUpdateSqlUserDefinedFunction(ctx context.Context, id UserDefinedFunctionId, input SqlUserDefinedFunctionCreateUpdateParameters) (result SqlResourcesCreateUpdateSqlUserDefinedFunctionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// SqlResourcesCreateUpdateSqlUserDefinedFunctionThenPoll performs SqlResourcesCreateUpdateSqlUserDefinedFunction then polls until it's completed +func (c CosmosDBClient) SqlResourcesCreateUpdateSqlUserDefinedFunctionThenPoll(ctx context.Context, id UserDefinedFunctionId, input SqlUserDefinedFunctionCreateUpdateParameters) error { + result, err := c.SqlResourcesCreateUpdateSqlUserDefinedFunction(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SqlResourcesCreateUpdateSqlUserDefinedFunction: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SqlResourcesCreateUpdateSqlUserDefinedFunction: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesdeletesqlcontainer.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesdeletesqlcontainer.go new file mode 100644 index 00000000000..38b7dc096cc --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesdeletesqlcontainer.go @@ -0,0 +1,70 @@ +package cosmosdb + +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 SqlResourcesDeleteSqlContainerOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SqlResourcesDeleteSqlContainer ... +func (c CosmosDBClient) SqlResourcesDeleteSqlContainer(ctx context.Context, id ContainerId) (result SqlResourcesDeleteSqlContainerOperationResponse, 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 +} + +// SqlResourcesDeleteSqlContainerThenPoll performs SqlResourcesDeleteSqlContainer then polls until it's completed +func (c CosmosDBClient) SqlResourcesDeleteSqlContainerThenPoll(ctx context.Context, id ContainerId) error { + result, err := c.SqlResourcesDeleteSqlContainer(ctx, id) + if err != nil { + return fmt.Errorf("performing SqlResourcesDeleteSqlContainer: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SqlResourcesDeleteSqlContainer: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesdeletesqldatabase.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesdeletesqldatabase.go new file mode 100644 index 00000000000..f7ad4ac0b12 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesdeletesqldatabase.go @@ -0,0 +1,70 @@ +package cosmosdb + +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 SqlResourcesDeleteSqlDatabaseOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SqlResourcesDeleteSqlDatabase ... +func (c CosmosDBClient) SqlResourcesDeleteSqlDatabase(ctx context.Context, id SqlDatabaseId) (result SqlResourcesDeleteSqlDatabaseOperationResponse, 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 +} + +// SqlResourcesDeleteSqlDatabaseThenPoll performs SqlResourcesDeleteSqlDatabase then polls until it's completed +func (c CosmosDBClient) SqlResourcesDeleteSqlDatabaseThenPoll(ctx context.Context, id SqlDatabaseId) error { + result, err := c.SqlResourcesDeleteSqlDatabase(ctx, id) + if err != nil { + return fmt.Errorf("performing SqlResourcesDeleteSqlDatabase: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SqlResourcesDeleteSqlDatabase: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesdeletesqlstoredprocedure.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesdeletesqlstoredprocedure.go new file mode 100644 index 00000000000..da660c7a14b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesdeletesqlstoredprocedure.go @@ -0,0 +1,70 @@ +package cosmosdb + +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 SqlResourcesDeleteSqlStoredProcedureOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SqlResourcesDeleteSqlStoredProcedure ... +func (c CosmosDBClient) SqlResourcesDeleteSqlStoredProcedure(ctx context.Context, id StoredProcedureId) (result SqlResourcesDeleteSqlStoredProcedureOperationResponse, 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 +} + +// SqlResourcesDeleteSqlStoredProcedureThenPoll performs SqlResourcesDeleteSqlStoredProcedure then polls until it's completed +func (c CosmosDBClient) SqlResourcesDeleteSqlStoredProcedureThenPoll(ctx context.Context, id StoredProcedureId) error { + result, err := c.SqlResourcesDeleteSqlStoredProcedure(ctx, id) + if err != nil { + return fmt.Errorf("performing SqlResourcesDeleteSqlStoredProcedure: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SqlResourcesDeleteSqlStoredProcedure: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesdeletesqltrigger.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesdeletesqltrigger.go new file mode 100644 index 00000000000..9c09dfa3aa2 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesdeletesqltrigger.go @@ -0,0 +1,70 @@ +package cosmosdb + +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 SqlResourcesDeleteSqlTriggerOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SqlResourcesDeleteSqlTrigger ... +func (c CosmosDBClient) SqlResourcesDeleteSqlTrigger(ctx context.Context, id TriggerId) (result SqlResourcesDeleteSqlTriggerOperationResponse, 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 +} + +// SqlResourcesDeleteSqlTriggerThenPoll performs SqlResourcesDeleteSqlTrigger then polls until it's completed +func (c CosmosDBClient) SqlResourcesDeleteSqlTriggerThenPoll(ctx context.Context, id TriggerId) error { + result, err := c.SqlResourcesDeleteSqlTrigger(ctx, id) + if err != nil { + return fmt.Errorf("performing SqlResourcesDeleteSqlTrigger: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SqlResourcesDeleteSqlTrigger: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesdeletesqluserdefinedfunction.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesdeletesqluserdefinedfunction.go new file mode 100644 index 00000000000..2d5bce428e0 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesdeletesqluserdefinedfunction.go @@ -0,0 +1,70 @@ +package cosmosdb + +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 SqlResourcesDeleteSqlUserDefinedFunctionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SqlResourcesDeleteSqlUserDefinedFunction ... +func (c CosmosDBClient) SqlResourcesDeleteSqlUserDefinedFunction(ctx context.Context, id UserDefinedFunctionId) (result SqlResourcesDeleteSqlUserDefinedFunctionOperationResponse, 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 +} + +// SqlResourcesDeleteSqlUserDefinedFunctionThenPoll performs SqlResourcesDeleteSqlUserDefinedFunction then polls until it's completed +func (c CosmosDBClient) SqlResourcesDeleteSqlUserDefinedFunctionThenPoll(ctx context.Context, id UserDefinedFunctionId) error { + result, err := c.SqlResourcesDeleteSqlUserDefinedFunction(ctx, id) + if err != nil { + return fmt.Errorf("performing SqlResourcesDeleteSqlUserDefinedFunction: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SqlResourcesDeleteSqlUserDefinedFunction: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetclientencryptionkey.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetclientencryptionkey.go new file mode 100644 index 00000000000..af241efa45e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetclientencryptionkey.go @@ -0,0 +1,53 @@ +package cosmosdb + +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 SqlResourcesGetClientEncryptionKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ClientEncryptionKeyGetResults +} + +// SqlResourcesGetClientEncryptionKey ... +func (c CosmosDBClient) SqlResourcesGetClientEncryptionKey(ctx context.Context, id ClientEncryptionKeyId) (result SqlResourcesGetClientEncryptionKeyOperationResponse, 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 ClientEncryptionKeyGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetsqlcontainer.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetsqlcontainer.go new file mode 100644 index 00000000000..5eb7bc222c3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetsqlcontainer.go @@ -0,0 +1,53 @@ +package cosmosdb + +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 SqlResourcesGetSqlContainerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SqlContainerGetResults +} + +// SqlResourcesGetSqlContainer ... +func (c CosmosDBClient) SqlResourcesGetSqlContainer(ctx context.Context, id ContainerId) (result SqlResourcesGetSqlContainerOperationResponse, 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 SqlContainerGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetsqlcontainerthroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetsqlcontainerthroughput.go new file mode 100644 index 00000000000..0a00c8a8bfe --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetsqlcontainerthroughput.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 SqlResourcesGetSqlContainerThroughputOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// SqlResourcesGetSqlContainerThroughput ... +func (c CosmosDBClient) SqlResourcesGetSqlContainerThroughput(ctx context.Context, id ContainerId) (result SqlResourcesGetSqlContainerThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/throughputSettings/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 ThroughputSettingsGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetsqldatabase.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetsqldatabase.go new file mode 100644 index 00000000000..fc043b7c3b0 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetsqldatabase.go @@ -0,0 +1,53 @@ +package cosmosdb + +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 SqlResourcesGetSqlDatabaseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SqlDatabaseGetResults +} + +// SqlResourcesGetSqlDatabase ... +func (c CosmosDBClient) SqlResourcesGetSqlDatabase(ctx context.Context, id SqlDatabaseId) (result SqlResourcesGetSqlDatabaseOperationResponse, 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 SqlDatabaseGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetsqldatabasethroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetsqldatabasethroughput.go new file mode 100644 index 00000000000..0293bba4a08 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetsqldatabasethroughput.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 SqlResourcesGetSqlDatabaseThroughputOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// SqlResourcesGetSqlDatabaseThroughput ... +func (c CosmosDBClient) SqlResourcesGetSqlDatabaseThroughput(ctx context.Context, id SqlDatabaseId) (result SqlResourcesGetSqlDatabaseThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/throughputSettings/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 ThroughputSettingsGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetsqlstoredprocedure.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetsqlstoredprocedure.go new file mode 100644 index 00000000000..553c530859b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetsqlstoredprocedure.go @@ -0,0 +1,53 @@ +package cosmosdb + +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 SqlResourcesGetSqlStoredProcedureOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SqlStoredProcedureGetResults +} + +// SqlResourcesGetSqlStoredProcedure ... +func (c CosmosDBClient) SqlResourcesGetSqlStoredProcedure(ctx context.Context, id StoredProcedureId) (result SqlResourcesGetSqlStoredProcedureOperationResponse, 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 SqlStoredProcedureGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetsqltrigger.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetsqltrigger.go new file mode 100644 index 00000000000..adc75a36c58 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetsqltrigger.go @@ -0,0 +1,53 @@ +package cosmosdb + +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 SqlResourcesGetSqlTriggerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SqlTriggerGetResults +} + +// SqlResourcesGetSqlTrigger ... +func (c CosmosDBClient) SqlResourcesGetSqlTrigger(ctx context.Context, id TriggerId) (result SqlResourcesGetSqlTriggerOperationResponse, 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 SqlTriggerGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetsqluserdefinedfunction.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetsqluserdefinedfunction.go new file mode 100644 index 00000000000..1d1ddce00d4 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesgetsqluserdefinedfunction.go @@ -0,0 +1,53 @@ +package cosmosdb + +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 SqlResourcesGetSqlUserDefinedFunctionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SqlUserDefinedFunctionGetResults +} + +// SqlResourcesGetSqlUserDefinedFunction ... +func (c CosmosDBClient) SqlResourcesGetSqlUserDefinedFunction(ctx context.Context, id UserDefinedFunctionId) (result SqlResourcesGetSqlUserDefinedFunctionOperationResponse, 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 SqlUserDefinedFunctionGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourceslistclientencryptionkeys.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourceslistclientencryptionkeys.go new file mode 100644 index 00000000000..0fbb76de445 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourceslistclientencryptionkeys.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 SqlResourcesListClientEncryptionKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ClientEncryptionKeysListResult +} + +// SqlResourcesListClientEncryptionKeys ... +func (c CosmosDBClient) SqlResourcesListClientEncryptionKeys(ctx context.Context, id SqlDatabaseId) (result SqlResourcesListClientEncryptionKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/clientEncryptionKeys", 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 ClientEncryptionKeysListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourceslistsqlcontainers.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourceslistsqlcontainers.go new file mode 100644 index 00000000000..932b86bd0dc --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourceslistsqlcontainers.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 SqlResourcesListSqlContainersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SqlContainerListResult +} + +// SqlResourcesListSqlContainers ... +func (c CosmosDBClient) SqlResourcesListSqlContainers(ctx context.Context, id SqlDatabaseId) (result SqlResourcesListSqlContainersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/containers", 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 SqlContainerListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourceslistsqldatabases.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourceslistsqldatabases.go new file mode 100644 index 00000000000..6f5fadd616d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourceslistsqldatabases.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 SqlResourcesListSqlDatabasesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SqlDatabaseListResult +} + +// SqlResourcesListSqlDatabases ... +func (c CosmosDBClient) SqlResourcesListSqlDatabases(ctx context.Context, id DatabaseAccountId) (result SqlResourcesListSqlDatabasesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sqlDatabases", 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 SqlDatabaseListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourceslistsqlstoredprocedures.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourceslistsqlstoredprocedures.go new file mode 100644 index 00000000000..0c5708f20a2 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourceslistsqlstoredprocedures.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 SqlResourcesListSqlStoredProceduresOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SqlStoredProcedureListResult +} + +// SqlResourcesListSqlStoredProcedures ... +func (c CosmosDBClient) SqlResourcesListSqlStoredProcedures(ctx context.Context, id ContainerId) (result SqlResourcesListSqlStoredProceduresOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/storedProcedures", 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 SqlStoredProcedureListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourceslistsqltriggers.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourceslistsqltriggers.go new file mode 100644 index 00000000000..87d5232c835 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourceslistsqltriggers.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 SqlResourcesListSqlTriggersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SqlTriggerListResult +} + +// SqlResourcesListSqlTriggers ... +func (c CosmosDBClient) SqlResourcesListSqlTriggers(ctx context.Context, id ContainerId) (result SqlResourcesListSqlTriggersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/triggers", 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 SqlTriggerListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourceslistsqluserdefinedfunctions.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourceslistsqluserdefinedfunctions.go new file mode 100644 index 00000000000..93ecc4e048c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourceslistsqluserdefinedfunctions.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 SqlResourcesListSqlUserDefinedFunctionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SqlUserDefinedFunctionListResult +} + +// SqlResourcesListSqlUserDefinedFunctions ... +func (c CosmosDBClient) SqlResourcesListSqlUserDefinedFunctions(ctx context.Context, id ContainerId) (result SqlResourcesListSqlUserDefinedFunctionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/userDefinedFunctions", 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 SqlUserDefinedFunctionListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesmigratesqlcontainertoautoscale.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesmigratesqlcontainertoautoscale.go new file mode 100644 index 00000000000..b9a6a4e613b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesmigratesqlcontainertoautoscale.go @@ -0,0 +1,71 @@ +package cosmosdb + +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 SqlResourcesMigrateSqlContainerToAutoscaleOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// SqlResourcesMigrateSqlContainerToAutoscale ... +func (c CosmosDBClient) SqlResourcesMigrateSqlContainerToAutoscale(ctx context.Context, id ContainerId) (result SqlResourcesMigrateSqlContainerToAutoscaleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/throughputSettings/default/migrateToAutoscale", 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 +} + +// SqlResourcesMigrateSqlContainerToAutoscaleThenPoll performs SqlResourcesMigrateSqlContainerToAutoscale then polls until it's completed +func (c CosmosDBClient) SqlResourcesMigrateSqlContainerToAutoscaleThenPoll(ctx context.Context, id ContainerId) error { + result, err := c.SqlResourcesMigrateSqlContainerToAutoscale(ctx, id) + if err != nil { + return fmt.Errorf("performing SqlResourcesMigrateSqlContainerToAutoscale: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SqlResourcesMigrateSqlContainerToAutoscale: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesmigratesqlcontainertomanualthroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesmigratesqlcontainertomanualthroughput.go new file mode 100644 index 00000000000..ba1510852c9 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesmigratesqlcontainertomanualthroughput.go @@ -0,0 +1,71 @@ +package cosmosdb + +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 SqlResourcesMigrateSqlContainerToManualThroughputOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// SqlResourcesMigrateSqlContainerToManualThroughput ... +func (c CosmosDBClient) SqlResourcesMigrateSqlContainerToManualThroughput(ctx context.Context, id ContainerId) (result SqlResourcesMigrateSqlContainerToManualThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/throughputSettings/default/migrateToManualThroughput", 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 +} + +// SqlResourcesMigrateSqlContainerToManualThroughputThenPoll performs SqlResourcesMigrateSqlContainerToManualThroughput then polls until it's completed +func (c CosmosDBClient) SqlResourcesMigrateSqlContainerToManualThroughputThenPoll(ctx context.Context, id ContainerId) error { + result, err := c.SqlResourcesMigrateSqlContainerToManualThroughput(ctx, id) + if err != nil { + return fmt.Errorf("performing SqlResourcesMigrateSqlContainerToManualThroughput: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SqlResourcesMigrateSqlContainerToManualThroughput: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesmigratesqldatabasetoautoscale.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesmigratesqldatabasetoautoscale.go new file mode 100644 index 00000000000..6e2ae01ca1d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesmigratesqldatabasetoautoscale.go @@ -0,0 +1,71 @@ +package cosmosdb + +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 SqlResourcesMigrateSqlDatabaseToAutoscaleOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// SqlResourcesMigrateSqlDatabaseToAutoscale ... +func (c CosmosDBClient) SqlResourcesMigrateSqlDatabaseToAutoscale(ctx context.Context, id SqlDatabaseId) (result SqlResourcesMigrateSqlDatabaseToAutoscaleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/throughputSettings/default/migrateToAutoscale", 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 +} + +// SqlResourcesMigrateSqlDatabaseToAutoscaleThenPoll performs SqlResourcesMigrateSqlDatabaseToAutoscale then polls until it's completed +func (c CosmosDBClient) SqlResourcesMigrateSqlDatabaseToAutoscaleThenPoll(ctx context.Context, id SqlDatabaseId) error { + result, err := c.SqlResourcesMigrateSqlDatabaseToAutoscale(ctx, id) + if err != nil { + return fmt.Errorf("performing SqlResourcesMigrateSqlDatabaseToAutoscale: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SqlResourcesMigrateSqlDatabaseToAutoscale: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesmigratesqldatabasetomanualthroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesmigratesqldatabasetomanualthroughput.go new file mode 100644 index 00000000000..e39f051ac52 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesmigratesqldatabasetomanualthroughput.go @@ -0,0 +1,71 @@ +package cosmosdb + +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 SqlResourcesMigrateSqlDatabaseToManualThroughputOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// SqlResourcesMigrateSqlDatabaseToManualThroughput ... +func (c CosmosDBClient) SqlResourcesMigrateSqlDatabaseToManualThroughput(ctx context.Context, id SqlDatabaseId) (result SqlResourcesMigrateSqlDatabaseToManualThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/throughputSettings/default/migrateToManualThroughput", 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 +} + +// SqlResourcesMigrateSqlDatabaseToManualThroughputThenPoll performs SqlResourcesMigrateSqlDatabaseToManualThroughput then polls until it's completed +func (c CosmosDBClient) SqlResourcesMigrateSqlDatabaseToManualThroughputThenPoll(ctx context.Context, id SqlDatabaseId) error { + result, err := c.SqlResourcesMigrateSqlDatabaseToManualThroughput(ctx, id) + if err != nil { + return fmt.Errorf("performing SqlResourcesMigrateSqlDatabaseToManualThroughput: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SqlResourcesMigrateSqlDatabaseToManualThroughput: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesupdatesqlcontainerthroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesupdatesqlcontainerthroughput.go new file mode 100644 index 00000000000..b1401d8b263 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesupdatesqlcontainerthroughput.go @@ -0,0 +1,75 @@ +package cosmosdb + +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 SqlResourcesUpdateSqlContainerThroughputOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// SqlResourcesUpdateSqlContainerThroughput ... +func (c CosmosDBClient) SqlResourcesUpdateSqlContainerThroughput(ctx context.Context, id ContainerId, input ThroughputSettingsUpdateParameters) (result SqlResourcesUpdateSqlContainerThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/throughputSettings/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 +} + +// SqlResourcesUpdateSqlContainerThroughputThenPoll performs SqlResourcesUpdateSqlContainerThroughput then polls until it's completed +func (c CosmosDBClient) SqlResourcesUpdateSqlContainerThroughputThenPoll(ctx context.Context, id ContainerId, input ThroughputSettingsUpdateParameters) error { + result, err := c.SqlResourcesUpdateSqlContainerThroughput(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SqlResourcesUpdateSqlContainerThroughput: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SqlResourcesUpdateSqlContainerThroughput: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesupdatesqldatabasethroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesupdatesqldatabasethroughput.go new file mode 100644 index 00000000000..380d9395f96 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_sqlresourcesupdatesqldatabasethroughput.go @@ -0,0 +1,75 @@ +package cosmosdb + +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 SqlResourcesUpdateSqlDatabaseThroughputOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// SqlResourcesUpdateSqlDatabaseThroughput ... +func (c CosmosDBClient) SqlResourcesUpdateSqlDatabaseThroughput(ctx context.Context, id SqlDatabaseId, input ThroughputSettingsUpdateParameters) (result SqlResourcesUpdateSqlDatabaseThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/throughputSettings/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 +} + +// SqlResourcesUpdateSqlDatabaseThroughputThenPoll performs SqlResourcesUpdateSqlDatabaseThroughput then polls until it's completed +func (c CosmosDBClient) SqlResourcesUpdateSqlDatabaseThroughputThenPoll(ctx context.Context, id SqlDatabaseId, input ThroughputSettingsUpdateParameters) error { + result, err := c.SqlResourcesUpdateSqlDatabaseThroughput(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SqlResourcesUpdateSqlDatabaseThroughput: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SqlResourcesUpdateSqlDatabaseThroughput: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourcescreateupdatetable.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourcescreateupdatetable.go new file mode 100644 index 00000000000..dd1767becce --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourcescreateupdatetable.go @@ -0,0 +1,75 @@ +package cosmosdb + +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 TableResourcesCreateUpdateTableOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *TableGetResults +} + +// TableResourcesCreateUpdateTable ... +func (c CosmosDBClient) TableResourcesCreateUpdateTable(ctx context.Context, id TableId, input TableCreateUpdateParameters) (result TableResourcesCreateUpdateTableOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// TableResourcesCreateUpdateTableThenPoll performs TableResourcesCreateUpdateTable then polls until it's completed +func (c CosmosDBClient) TableResourcesCreateUpdateTableThenPoll(ctx context.Context, id TableId, input TableCreateUpdateParameters) error { + result, err := c.TableResourcesCreateUpdateTable(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TableResourcesCreateUpdateTable: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TableResourcesCreateUpdateTable: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourcesdeletetable.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourcesdeletetable.go new file mode 100644 index 00000000000..b07c7524b78 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourcesdeletetable.go @@ -0,0 +1,70 @@ +package cosmosdb + +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 TableResourcesDeleteTableOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// TableResourcesDeleteTable ... +func (c CosmosDBClient) TableResourcesDeleteTable(ctx context.Context, id TableId) (result TableResourcesDeleteTableOperationResponse, 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 +} + +// TableResourcesDeleteTableThenPoll performs TableResourcesDeleteTable then polls until it's completed +func (c CosmosDBClient) TableResourcesDeleteTableThenPoll(ctx context.Context, id TableId) error { + result, err := c.TableResourcesDeleteTable(ctx, id) + if err != nil { + return fmt.Errorf("performing TableResourcesDeleteTable: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TableResourcesDeleteTable: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourcesgettable.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourcesgettable.go new file mode 100644 index 00000000000..26645d49a19 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourcesgettable.go @@ -0,0 +1,53 @@ +package cosmosdb + +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 TableResourcesGetTableOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TableGetResults +} + +// TableResourcesGetTable ... +func (c CosmosDBClient) TableResourcesGetTable(ctx context.Context, id TableId) (result TableResourcesGetTableOperationResponse, 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 TableGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourcesgettablethroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourcesgettablethroughput.go new file mode 100644 index 00000000000..8c7bf14664d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourcesgettablethroughput.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 TableResourcesGetTableThroughputOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// TableResourcesGetTableThroughput ... +func (c CosmosDBClient) TableResourcesGetTableThroughput(ctx context.Context, id TableId) (result TableResourcesGetTableThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/throughputSettings/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 ThroughputSettingsGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourceslisttables.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourceslisttables.go new file mode 100644 index 00000000000..9a22a7530b6 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourceslisttables.go @@ -0,0 +1,54 @@ +package cosmosdb + +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 TableResourcesListTablesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TableListResult +} + +// TableResourcesListTables ... +func (c CosmosDBClient) TableResourcesListTables(ctx context.Context, id DatabaseAccountId) (result TableResourcesListTablesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/tables", 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 TableListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourcesmigratetabletoautoscale.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourcesmigratetabletoautoscale.go new file mode 100644 index 00000000000..feb3b844a55 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourcesmigratetabletoautoscale.go @@ -0,0 +1,71 @@ +package cosmosdb + +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 TableResourcesMigrateTableToAutoscaleOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// TableResourcesMigrateTableToAutoscale ... +func (c CosmosDBClient) TableResourcesMigrateTableToAutoscale(ctx context.Context, id TableId) (result TableResourcesMigrateTableToAutoscaleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/throughputSettings/default/migrateToAutoscale", 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 +} + +// TableResourcesMigrateTableToAutoscaleThenPoll performs TableResourcesMigrateTableToAutoscale then polls until it's completed +func (c CosmosDBClient) TableResourcesMigrateTableToAutoscaleThenPoll(ctx context.Context, id TableId) error { + result, err := c.TableResourcesMigrateTableToAutoscale(ctx, id) + if err != nil { + return fmt.Errorf("performing TableResourcesMigrateTableToAutoscale: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TableResourcesMigrateTableToAutoscale: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourcesmigratetabletomanualthroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourcesmigratetabletomanualthroughput.go new file mode 100644 index 00000000000..bc4539e8f5a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourcesmigratetabletomanualthroughput.go @@ -0,0 +1,71 @@ +package cosmosdb + +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 TableResourcesMigrateTableToManualThroughputOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// TableResourcesMigrateTableToManualThroughput ... +func (c CosmosDBClient) TableResourcesMigrateTableToManualThroughput(ctx context.Context, id TableId) (result TableResourcesMigrateTableToManualThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/throughputSettings/default/migrateToManualThroughput", 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 +} + +// TableResourcesMigrateTableToManualThroughputThenPoll performs TableResourcesMigrateTableToManualThroughput then polls until it's completed +func (c CosmosDBClient) TableResourcesMigrateTableToManualThroughputThenPoll(ctx context.Context, id TableId) error { + result, err := c.TableResourcesMigrateTableToManualThroughput(ctx, id) + if err != nil { + return fmt.Errorf("performing TableResourcesMigrateTableToManualThroughput: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TableResourcesMigrateTableToManualThroughput: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourcesupdatetablethroughput.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourcesupdatetablethroughput.go new file mode 100644 index 00000000000..c24e9082b73 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/method_tableresourcesupdatetablethroughput.go @@ -0,0 +1,75 @@ +package cosmosdb + +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 TableResourcesUpdateTableThroughputOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ThroughputSettingsGetResults +} + +// TableResourcesUpdateTableThroughput ... +func (c CosmosDBClient) TableResourcesUpdateTableThroughput(ctx context.Context, id TableId, input ThroughputSettingsUpdateParameters) (result TableResourcesUpdateTableThroughputOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/throughputSettings/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 +} + +// TableResourcesUpdateTableThroughputThenPoll performs TableResourcesUpdateTableThroughput then polls until it's completed +func (c CosmosDBClient) TableResourcesUpdateTableThroughputThenPoll(ctx context.Context, id TableId, input ThroughputSettingsUpdateParameters) error { + result, err := c.TableResourcesUpdateTableThroughput(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TableResourcesUpdateTableThroughput: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TableResourcesUpdateTableThroughput: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_accountkeymetadata.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_accountkeymetadata.go new file mode 100644 index 00000000000..84fc00031f6 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_accountkeymetadata.go @@ -0,0 +1,26 @@ +package cosmosdb + +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 AccountKeyMetadata struct { + GenerationTime *string `json:"generationTime,omitempty"` +} + +func (o *AccountKeyMetadata) GetGenerationTimeAsTime() (*time.Time, error) { + if o.GenerationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.GenerationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AccountKeyMetadata) SetGenerationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.GenerationTime = &formatted +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_analyticalstorageconfiguration.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_analyticalstorageconfiguration.go new file mode 100644 index 00000000000..181589d115f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_analyticalstorageconfiguration.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AnalyticalStorageConfiguration struct { + SchemaType *AnalyticalStorageSchemaType `json:"schemaType,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_apiproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_apiproperties.go new file mode 100644 index 00000000000..231040ab44d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_apiproperties.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiProperties struct { + ServerVersion *ServerVersion `json:"serverVersion,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_autoscalesettings.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_autoscalesettings.go new file mode 100644 index 00000000000..bfe5f5bc085 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_autoscalesettings.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoScaleSettings struct { + MaxThroughput *int64 `json:"maxThroughput,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_autoscalesettingsresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_autoscalesettingsresource.go new file mode 100644 index 00000000000..2dae67d529f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_autoscalesettingsresource.go @@ -0,0 +1,10 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoscaleSettingsResource struct { + AutoUpgradePolicy *AutoUpgradePolicyResource `json:"autoUpgradePolicy,omitempty"` + MaxThroughput int64 `json:"maxThroughput"` + TargetMaxThroughput *int64 `json:"targetMaxThroughput,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_autoupgradepolicyresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_autoupgradepolicyresource.go new file mode 100644 index 00000000000..db0d65bbc3e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_autoupgradepolicyresource.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoUpgradePolicyResource struct { + ThroughputPolicy *ThroughputPolicyResource `json:"throughputPolicy,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_backuppolicy.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_backuppolicy.go new file mode 100644 index 00000000000..5d5d654a4c3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_backuppolicy.go @@ -0,0 +1,84 @@ +package cosmosdb + +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 BackupPolicy interface { + BackupPolicy() BaseBackupPolicyImpl +} + +var _ BackupPolicy = BaseBackupPolicyImpl{} + +type BaseBackupPolicyImpl struct { + MigrationState *BackupPolicyMigrationState `json:"migrationState,omitempty"` + Type BackupPolicyType `json:"type"` +} + +func (s BaseBackupPolicyImpl) BackupPolicy() BaseBackupPolicyImpl { + return s +} + +var _ BackupPolicy = RawBackupPolicyImpl{} + +// RawBackupPolicyImpl 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 RawBackupPolicyImpl struct { + backupPolicy BaseBackupPolicyImpl + Type string + Values map[string]interface{} +} + +func (s RawBackupPolicyImpl) BackupPolicy() BaseBackupPolicyImpl { + return s.backupPolicy +} + +func UnmarshalBackupPolicyImplementation(input []byte) (BackupPolicy, 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 BackupPolicy into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["type"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Continuous") { + var out ContinuousModeBackupPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ContinuousModeBackupPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Periodic") { + var out PeriodicModeBackupPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into PeriodicModeBackupPolicy: %+v", err) + } + return out, nil + } + + var parent BaseBackupPolicyImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseBackupPolicyImpl: %+v", err) + } + + return RawBackupPolicyImpl{ + backupPolicy: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_backuppolicymigrationstate.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_backuppolicymigrationstate.go new file mode 100644 index 00000000000..f23938e53e7 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_backuppolicymigrationstate.go @@ -0,0 +1,28 @@ +package cosmosdb + +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 BackupPolicyMigrationState struct { + StartTime *string `json:"startTime,omitempty"` + Status *BackupPolicyMigrationStatus `json:"status,omitempty"` + TargetType *BackupPolicyType `json:"targetType,omitempty"` +} + +func (o *BackupPolicyMigrationState) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupPolicyMigrationState) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_capability.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_capability.go new file mode 100644 index 00000000000..4306e287902 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_capability.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Capability struct { + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_capacity.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_capacity.go new file mode 100644 index 00000000000..e2cb98715db --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_capacity.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Capacity struct { + TotalThroughputLimit *int64 `json:"totalThroughputLimit,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrakeyspacecreateupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrakeyspacecreateupdateparameters.go new file mode 100644 index 00000000000..1b73cec354f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrakeyspacecreateupdateparameters.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CassandraKeyspaceCreateUpdateParameters struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties CassandraKeyspaceCreateUpdateProperties `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrakeyspacecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrakeyspacecreateupdateproperties.go new file mode 100644 index 00000000000..80ff43847f0 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrakeyspacecreateupdateproperties.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CassandraKeyspaceCreateUpdateProperties struct { + Options *CreateUpdateOptions `json:"options,omitempty"` + Resource CassandraKeyspaceResource `json:"resource"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrakeyspacegetproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrakeyspacegetproperties.go new file mode 100644 index 00000000000..a7ddd5ec3e3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrakeyspacegetproperties.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CassandraKeyspaceGetProperties struct { + Options *OptionsResource `json:"options,omitempty"` + Resource *CassandraKeyspaceGetPropertiesResource `json:"resource,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrakeyspacegetpropertiesresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrakeyspacegetpropertiesresource.go new file mode 100644 index 00000000000..800e3a798c1 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrakeyspacegetpropertiesresource.go @@ -0,0 +1,11 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CassandraKeyspaceGetPropertiesResource struct { + Etag *string `json:"_etag,omitempty"` + Id *string `json:"id,omitempty"` + Rid *string `json:"_rid,omitempty"` + Ts *float64 `json:"_ts,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrakeyspacegetresults.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrakeyspacegetresults.go new file mode 100644 index 00000000000..7a3f647c293 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrakeyspacegetresults.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CassandraKeyspaceGetResults struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CassandraKeyspaceGetProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrakeyspacelistresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrakeyspacelistresult.go new file mode 100644 index 00000000000..8b8cd939ed9 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrakeyspacelistresult.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CassandraKeyspaceListResult struct { + Value *[]CassandraKeyspaceGetResults `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrakeyspaceresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrakeyspaceresource.go new file mode 100644 index 00000000000..2000e088180 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrakeyspaceresource.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CassandraKeyspaceResource struct { + Id string `json:"id"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrapartitionkey.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrapartitionkey.go new file mode 100644 index 00000000000..5c50c3d8a6d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandrapartitionkey.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CassandraPartitionKey struct { + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandraschema.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandraschema.go new file mode 100644 index 00000000000..9d498a2a898 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandraschema.go @@ -0,0 +1,10 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CassandraSchema struct { + ClusterKeys *[]ClusterKey `json:"clusterKeys,omitempty"` + Columns *[]Column `json:"columns,omitempty"` + PartitionKeys *[]CassandraPartitionKey `json:"partitionKeys,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandratablecreateupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandratablecreateupdateparameters.go new file mode 100644 index 00000000000..e011ba22519 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandratablecreateupdateparameters.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CassandraTableCreateUpdateParameters struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties CassandraTableCreateUpdateProperties `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandratablecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandratablecreateupdateproperties.go new file mode 100644 index 00000000000..f08596cf88f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandratablecreateupdateproperties.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CassandraTableCreateUpdateProperties struct { + Options *CreateUpdateOptions `json:"options,omitempty"` + Resource CassandraTableResource `json:"resource"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandratablegetproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandratablegetproperties.go new file mode 100644 index 00000000000..349264a72b6 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandratablegetproperties.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CassandraTableGetProperties struct { + Options *OptionsResource `json:"options,omitempty"` + Resource *CassandraTableGetPropertiesResource `json:"resource,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandratablegetpropertiesresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandratablegetpropertiesresource.go new file mode 100644 index 00000000000..d354b262d53 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandratablegetpropertiesresource.go @@ -0,0 +1,14 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CassandraTableGetPropertiesResource struct { + AnalyticalStorageTtl *int64 `json:"analyticalStorageTtl,omitempty"` + DefaultTtl *int64 `json:"defaultTtl,omitempty"` + Etag *string `json:"_etag,omitempty"` + Id *string `json:"id,omitempty"` + Rid *string `json:"_rid,omitempty"` + Schema *CassandraSchema `json:"schema,omitempty"` + Ts *float64 `json:"_ts,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandratablegetresults.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandratablegetresults.go new file mode 100644 index 00000000000..f4b82a41cb6 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandratablegetresults.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CassandraTableGetResults struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CassandraTableGetProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandratablelistresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandratablelistresult.go new file mode 100644 index 00000000000..3b7a0f6a959 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandratablelistresult.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CassandraTableListResult struct { + Value *[]CassandraTableGetResults `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandratableresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandratableresource.go new file mode 100644 index 00000000000..7c20f9bf496 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_cassandratableresource.go @@ -0,0 +1,11 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CassandraTableResource struct { + AnalyticalStorageTtl *int64 `json:"analyticalStorageTtl,omitempty"` + DefaultTtl *int64 `json:"defaultTtl,omitempty"` + Id string `json:"id"` + Schema *CassandraSchema `json:"schema,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionincludedpath.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionincludedpath.go new file mode 100644 index 00000000000..58a0a131bec --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionincludedpath.go @@ -0,0 +1,11 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClientEncryptionIncludedPath struct { + ClientEncryptionKeyId string `json:"clientEncryptionKeyId"` + EncryptionAlgorithm string `json:"encryptionAlgorithm"` + EncryptionType string `json:"encryptionType"` + Path string `json:"path"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionkeycreateupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionkeycreateupdateparameters.go new file mode 100644 index 00000000000..f72409baaa3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionkeycreateupdateparameters.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClientEncryptionKeyCreateUpdateParameters struct { + Properties ClientEncryptionKeyCreateUpdateProperties `json:"properties"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionkeycreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionkeycreateupdateproperties.go new file mode 100644 index 00000000000..be2c9c68503 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionkeycreateupdateproperties.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClientEncryptionKeyCreateUpdateProperties struct { + Resource ClientEncryptionKeyResource `json:"resource"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionkeygetproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionkeygetproperties.go new file mode 100644 index 00000000000..b36904a66b8 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionkeygetproperties.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClientEncryptionKeyGetProperties struct { + Resource *ClientEncryptionKeyGetPropertiesResource `json:"resource,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionkeygetpropertiesresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionkeygetpropertiesresource.go new file mode 100644 index 00000000000..5393f919d3a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionkeygetpropertiesresource.go @@ -0,0 +1,14 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClientEncryptionKeyGetPropertiesResource struct { + EncryptionAlgorithm *string `json:"encryptionAlgorithm,omitempty"` + Etag *string `json:"_etag,omitempty"` + Id *string `json:"id,omitempty"` + KeyWrapMetadata *KeyWrapMetadata `json:"keyWrapMetadata,omitempty"` + Rid *string `json:"_rid,omitempty"` + Ts *float64 `json:"_ts,omitempty"` + WrappedDataEncryptionKey *string `json:"wrappedDataEncryptionKey,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionkeygetresults.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionkeygetresults.go new file mode 100644 index 00000000000..5c83f184f96 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionkeygetresults.go @@ -0,0 +1,11 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClientEncryptionKeyGetResults struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ClientEncryptionKeyGetProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionkeyresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionkeyresource.go new file mode 100644 index 00000000000..ddccb42a0bc --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionkeyresource.go @@ -0,0 +1,11 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClientEncryptionKeyResource struct { + EncryptionAlgorithm *string `json:"encryptionAlgorithm,omitempty"` + Id *string `json:"id,omitempty"` + KeyWrapMetadata *KeyWrapMetadata `json:"keyWrapMetadata,omitempty"` + WrappedDataEncryptionKey *string `json:"wrappedDataEncryptionKey,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionkeyslistresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionkeyslistresult.go new file mode 100644 index 00000000000..43f7501528f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionkeyslistresult.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClientEncryptionKeysListResult struct { + Value *[]ClientEncryptionKeyGetResults `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionpolicy.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionpolicy.go new file mode 100644 index 00000000000..6e692a77332 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clientencryptionpolicy.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClientEncryptionPolicy struct { + IncludedPaths []ClientEncryptionIncludedPath `json:"includedPaths"` + PolicyFormatVersion int64 `json:"policyFormatVersion"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clusterkey.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clusterkey.go new file mode 100644 index 00000000000..1f3a0293d8c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_clusterkey.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterKey struct { + Name *string `json:"name,omitempty"` + OrderBy *string `json:"orderBy,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_column.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_column.go new file mode 100644 index 00000000000..954c47686b8 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_column.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Column struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_compositepath.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_compositepath.go new file mode 100644 index 00000000000..33a9d51ace7 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_compositepath.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CompositePath struct { + Order *CompositePathSortOrder `json:"order,omitempty"` + Path *string `json:"path,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_computedproperty.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_computedproperty.go new file mode 100644 index 00000000000..4ef290fb612 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_computedproperty.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputedProperty struct { + Name *string `json:"name,omitempty"` + Query *string `json:"query,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_conflictresolutionpolicy.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_conflictresolutionpolicy.go new file mode 100644 index 00000000000..83eb7abe76c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_conflictresolutionpolicy.go @@ -0,0 +1,10 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConflictResolutionPolicy struct { + ConflictResolutionPath *string `json:"conflictResolutionPath,omitempty"` + ConflictResolutionProcedure *string `json:"conflictResolutionProcedure,omitempty"` + Mode *ConflictResolutionMode `json:"mode,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_consistencypolicy.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_consistencypolicy.go new file mode 100644 index 00000000000..07ce2103f5a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_consistencypolicy.go @@ -0,0 +1,10 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConsistencyPolicy struct { + DefaultConsistencyLevel DefaultConsistencyLevel `json:"defaultConsistencyLevel"` + MaxIntervalInSeconds *int64 `json:"maxIntervalInSeconds,omitempty"` + MaxStalenessPrefix *int64 `json:"maxStalenessPrefix,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_containerpartitionkey.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_containerpartitionkey.go new file mode 100644 index 00000000000..ee0d47799d1 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_containerpartitionkey.go @@ -0,0 +1,11 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerPartitionKey struct { + Kind *PartitionKind `json:"kind,omitempty"` + Paths *[]string `json:"paths,omitempty"` + SystemKey *bool `json:"systemKey,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_continuousmodebackuppolicy.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_continuousmodebackuppolicy.go new file mode 100644 index 00000000000..eb15c07e5f2 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_continuousmodebackuppolicy.go @@ -0,0 +1,52 @@ +package cosmosdb + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ BackupPolicy = ContinuousModeBackupPolicy{} + +type ContinuousModeBackupPolicy struct { + ContinuousModeProperties *ContinuousModeProperties `json:"continuousModeProperties,omitempty"` + + // Fields inherited from BackupPolicy + + MigrationState *BackupPolicyMigrationState `json:"migrationState,omitempty"` + Type BackupPolicyType `json:"type"` +} + +func (s ContinuousModeBackupPolicy) BackupPolicy() BaseBackupPolicyImpl { + return BaseBackupPolicyImpl{ + MigrationState: s.MigrationState, + Type: s.Type, + } +} + +var _ json.Marshaler = ContinuousModeBackupPolicy{} + +func (s ContinuousModeBackupPolicy) MarshalJSON() ([]byte, error) { + type wrapper ContinuousModeBackupPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ContinuousModeBackupPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ContinuousModeBackupPolicy: %+v", err) + } + + decoded["type"] = "Continuous" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ContinuousModeBackupPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_continuousmodeproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_continuousmodeproperties.go new file mode 100644 index 00000000000..daac5351471 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_continuousmodeproperties.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContinuousModeProperties struct { + Tier *ContinuousTier `json:"tier,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_corspolicy.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_corspolicy.go new file mode 100644 index 00000000000..99bbc49c972 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_corspolicy.go @@ -0,0 +1,12 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CorsPolicy struct { + AllowedHeaders *string `json:"allowedHeaders,omitempty"` + AllowedMethods *string `json:"allowedMethods,omitempty"` + AllowedOrigins string `json:"allowedOrigins"` + ExposedHeaders *string `json:"exposedHeaders,omitempty"` + MaxAgeInSeconds *int64 `json:"maxAgeInSeconds,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_createupdateoptions.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_createupdateoptions.go new file mode 100644 index 00000000000..050689a321e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_createupdateoptions.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateUpdateOptions struct { + AutoScaleSettings *AutoScaleSettings `json:"autoscaleSettings,omitempty"` + Throughput *int64 `json:"throughput,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountconnectionstring.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountconnectionstring.go new file mode 100644 index 00000000000..616420e0ea9 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountconnectionstring.go @@ -0,0 +1,11 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseAccountConnectionString struct { + ConnectionString *string `json:"connectionString,omitempty"` + Description *string `json:"description,omitempty"` + KeyKind *Kind `json:"keyKind,omitempty"` + Type *Type `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountcreateupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountcreateupdateparameters.go new file mode 100644 index 00000000000..a33d5146a81 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountcreateupdateparameters.go @@ -0,0 +1,19 @@ +package cosmosdb + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseAccountCreateUpdateParameters struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *DatabaseAccountKind `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties DatabaseAccountCreateUpdateProperties `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountcreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountcreateupdateproperties.go new file mode 100644 index 00000000000..3dc80282bb3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountcreateupdateproperties.go @@ -0,0 +1,135 @@ +package cosmosdb + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseAccountCreateUpdateProperties struct { + AnalyticalStorageConfiguration *AnalyticalStorageConfiguration `json:"analyticalStorageConfiguration,omitempty"` + ApiProperties *ApiProperties `json:"apiProperties,omitempty"` + BackupPolicy BackupPolicy `json:"backupPolicy"` + Capabilities *[]Capability `json:"capabilities,omitempty"` + Capacity *Capacity `json:"capacity,omitempty"` + ConnectorOffer *ConnectorOffer `json:"connectorOffer,omitempty"` + ConsistencyPolicy *ConsistencyPolicy `json:"consistencyPolicy,omitempty"` + Cors *[]CorsPolicy `json:"cors,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + CustomerManagedKeyStatus *string `json:"customerManagedKeyStatus,omitempty"` + DatabaseAccountOfferType DatabaseAccountOfferType `json:"databaseAccountOfferType"` + DefaultIdentity *string `json:"defaultIdentity,omitempty"` + DisableKeyBasedMetadataWriteAccess *bool `json:"disableKeyBasedMetadataWriteAccess,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + EnableAnalyticalStorage *bool `json:"enableAnalyticalStorage,omitempty"` + EnableAutomaticFailover *bool `json:"enableAutomaticFailover,omitempty"` + EnableBurstCapacity *bool `json:"enableBurstCapacity,omitempty"` + EnableCassandraConnector *bool `json:"enableCassandraConnector,omitempty"` + EnableFreeTier *bool `json:"enableFreeTier,omitempty"` + EnableMultipleWriteLocations *bool `json:"enableMultipleWriteLocations,omitempty"` + EnablePartitionMerge *bool `json:"enablePartitionMerge,omitempty"` + EnablePerRegionPerPartitionAutoscale *bool `json:"enablePerRegionPerPartitionAutoscale,omitempty"` + IPRules *[]IPAddressOrRange `json:"ipRules,omitempty"` + IsVirtualNetworkFilterEnabled *bool `json:"isVirtualNetworkFilterEnabled,omitempty"` + KeyVaultKeyUri *string `json:"keyVaultKeyUri,omitempty"` + KeysMetadata *DatabaseAccountKeysMetadata `json:"keysMetadata,omitempty"` + Locations []Location `json:"locations"` + MinimalTlsVersion *MinimalTlsVersion `json:"minimalTlsVersion,omitempty"` + NetworkAclBypass *NetworkAclBypass `json:"networkAclBypass,omitempty"` + NetworkAclBypassResourceIds *[]string `json:"networkAclBypassResourceIds,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + RestoreParameters *RestoreParameters `json:"restoreParameters,omitempty"` + VirtualNetworkRules *[]VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` +} + +var _ json.Unmarshaler = &DatabaseAccountCreateUpdateProperties{} + +func (s *DatabaseAccountCreateUpdateProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AnalyticalStorageConfiguration *AnalyticalStorageConfiguration `json:"analyticalStorageConfiguration,omitempty"` + ApiProperties *ApiProperties `json:"apiProperties,omitempty"` + Capabilities *[]Capability `json:"capabilities,omitempty"` + Capacity *Capacity `json:"capacity,omitempty"` + ConnectorOffer *ConnectorOffer `json:"connectorOffer,omitempty"` + ConsistencyPolicy *ConsistencyPolicy `json:"consistencyPolicy,omitempty"` + Cors *[]CorsPolicy `json:"cors,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + CustomerManagedKeyStatus *string `json:"customerManagedKeyStatus,omitempty"` + DatabaseAccountOfferType DatabaseAccountOfferType `json:"databaseAccountOfferType"` + DefaultIdentity *string `json:"defaultIdentity,omitempty"` + DisableKeyBasedMetadataWriteAccess *bool `json:"disableKeyBasedMetadataWriteAccess,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + EnableAnalyticalStorage *bool `json:"enableAnalyticalStorage,omitempty"` + EnableAutomaticFailover *bool `json:"enableAutomaticFailover,omitempty"` + EnableBurstCapacity *bool `json:"enableBurstCapacity,omitempty"` + EnableCassandraConnector *bool `json:"enableCassandraConnector,omitempty"` + EnableFreeTier *bool `json:"enableFreeTier,omitempty"` + EnableMultipleWriteLocations *bool `json:"enableMultipleWriteLocations,omitempty"` + EnablePartitionMerge *bool `json:"enablePartitionMerge,omitempty"` + EnablePerRegionPerPartitionAutoscale *bool `json:"enablePerRegionPerPartitionAutoscale,omitempty"` + IPRules *[]IPAddressOrRange `json:"ipRules,omitempty"` + IsVirtualNetworkFilterEnabled *bool `json:"isVirtualNetworkFilterEnabled,omitempty"` + KeyVaultKeyUri *string `json:"keyVaultKeyUri,omitempty"` + KeysMetadata *DatabaseAccountKeysMetadata `json:"keysMetadata,omitempty"` + Locations []Location `json:"locations"` + MinimalTlsVersion *MinimalTlsVersion `json:"minimalTlsVersion,omitempty"` + NetworkAclBypass *NetworkAclBypass `json:"networkAclBypass,omitempty"` + NetworkAclBypassResourceIds *[]string `json:"networkAclBypassResourceIds,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + RestoreParameters *RestoreParameters `json:"restoreParameters,omitempty"` + VirtualNetworkRules *[]VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AnalyticalStorageConfiguration = decoded.AnalyticalStorageConfiguration + s.ApiProperties = decoded.ApiProperties + s.Capabilities = decoded.Capabilities + s.Capacity = decoded.Capacity + s.ConnectorOffer = decoded.ConnectorOffer + s.ConsistencyPolicy = decoded.ConsistencyPolicy + s.Cors = decoded.Cors + s.CreateMode = decoded.CreateMode + s.CustomerManagedKeyStatus = decoded.CustomerManagedKeyStatus + s.DatabaseAccountOfferType = decoded.DatabaseAccountOfferType + s.DefaultIdentity = decoded.DefaultIdentity + s.DisableKeyBasedMetadataWriteAccess = decoded.DisableKeyBasedMetadataWriteAccess + s.DisableLocalAuth = decoded.DisableLocalAuth + s.EnableAnalyticalStorage = decoded.EnableAnalyticalStorage + s.EnableAutomaticFailover = decoded.EnableAutomaticFailover + s.EnableBurstCapacity = decoded.EnableBurstCapacity + s.EnableCassandraConnector = decoded.EnableCassandraConnector + s.EnableFreeTier = decoded.EnableFreeTier + s.EnableMultipleWriteLocations = decoded.EnableMultipleWriteLocations + s.EnablePartitionMerge = decoded.EnablePartitionMerge + s.EnablePerRegionPerPartitionAutoscale = decoded.EnablePerRegionPerPartitionAutoscale + s.IPRules = decoded.IPRules + s.IsVirtualNetworkFilterEnabled = decoded.IsVirtualNetworkFilterEnabled + s.KeyVaultKeyUri = decoded.KeyVaultKeyUri + s.KeysMetadata = decoded.KeysMetadata + s.Locations = decoded.Locations + s.MinimalTlsVersion = decoded.MinimalTlsVersion + s.NetworkAclBypass = decoded.NetworkAclBypass + s.NetworkAclBypassResourceIds = decoded.NetworkAclBypassResourceIds + s.PublicNetworkAccess = decoded.PublicNetworkAccess + s.RestoreParameters = decoded.RestoreParameters + s.VirtualNetworkRules = decoded.VirtualNetworkRules + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling DatabaseAccountCreateUpdateProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["backupPolicy"]; ok { + impl, err := UnmarshalBackupPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'BackupPolicy' for 'DatabaseAccountCreateUpdateProperties': %+v", err) + } + s.BackupPolicy = impl + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountgetproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountgetproperties.go new file mode 100644 index 00000000000..04aecb50cb8 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountgetproperties.go @@ -0,0 +1,156 @@ +package cosmosdb + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseAccountGetProperties struct { + AnalyticalStorageConfiguration *AnalyticalStorageConfiguration `json:"analyticalStorageConfiguration,omitempty"` + ApiProperties *ApiProperties `json:"apiProperties,omitempty"` + BackupPolicy BackupPolicy `json:"backupPolicy"` + Capabilities *[]Capability `json:"capabilities,omitempty"` + Capacity *Capacity `json:"capacity,omitempty"` + ConnectorOffer *ConnectorOffer `json:"connectorOffer,omitempty"` + ConsistencyPolicy *ConsistencyPolicy `json:"consistencyPolicy,omitempty"` + Cors *[]CorsPolicy `json:"cors,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + CustomerManagedKeyStatus *string `json:"customerManagedKeyStatus,omitempty"` + DatabaseAccountOfferType *DatabaseAccountOfferType `json:"databaseAccountOfferType,omitempty"` + DefaultIdentity *string `json:"defaultIdentity,omitempty"` + DisableKeyBasedMetadataWriteAccess *bool `json:"disableKeyBasedMetadataWriteAccess,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + DocumentEndpoint *string `json:"documentEndpoint,omitempty"` + EnableAnalyticalStorage *bool `json:"enableAnalyticalStorage,omitempty"` + EnableAutomaticFailover *bool `json:"enableAutomaticFailover,omitempty"` + EnableBurstCapacity *bool `json:"enableBurstCapacity,omitempty"` + EnableCassandraConnector *bool `json:"enableCassandraConnector,omitempty"` + EnableFreeTier *bool `json:"enableFreeTier,omitempty"` + EnableMultipleWriteLocations *bool `json:"enableMultipleWriteLocations,omitempty"` + EnablePartitionMerge *bool `json:"enablePartitionMerge,omitempty"` + EnablePerRegionPerPartitionAutoscale *bool `json:"enablePerRegionPerPartitionAutoscale,omitempty"` + FailoverPolicies *[]FailoverPolicy `json:"failoverPolicies,omitempty"` + IPRules *[]IPAddressOrRange `json:"ipRules,omitempty"` + InstanceId *string `json:"instanceId,omitempty"` + IsVirtualNetworkFilterEnabled *bool `json:"isVirtualNetworkFilterEnabled,omitempty"` + KeyVaultKeyUri *string `json:"keyVaultKeyUri,omitempty"` + KeysMetadata *DatabaseAccountKeysMetadata `json:"keysMetadata,omitempty"` + Locations *[]Location `json:"locations,omitempty"` + MinimalTlsVersion *MinimalTlsVersion `json:"minimalTlsVersion,omitempty"` + NetworkAclBypass *NetworkAclBypass `json:"networkAclBypass,omitempty"` + NetworkAclBypassResourceIds *[]string `json:"networkAclBypassResourceIds,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + ReadLocations *[]Location `json:"readLocations,omitempty"` + RestoreParameters *RestoreParameters `json:"restoreParameters,omitempty"` + VirtualNetworkRules *[]VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` + WriteLocations *[]Location `json:"writeLocations,omitempty"` +} + +var _ json.Unmarshaler = &DatabaseAccountGetProperties{} + +func (s *DatabaseAccountGetProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AnalyticalStorageConfiguration *AnalyticalStorageConfiguration `json:"analyticalStorageConfiguration,omitempty"` + ApiProperties *ApiProperties `json:"apiProperties,omitempty"` + Capabilities *[]Capability `json:"capabilities,omitempty"` + Capacity *Capacity `json:"capacity,omitempty"` + ConnectorOffer *ConnectorOffer `json:"connectorOffer,omitempty"` + ConsistencyPolicy *ConsistencyPolicy `json:"consistencyPolicy,omitempty"` + Cors *[]CorsPolicy `json:"cors,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + CustomerManagedKeyStatus *string `json:"customerManagedKeyStatus,omitempty"` + DatabaseAccountOfferType *DatabaseAccountOfferType `json:"databaseAccountOfferType,omitempty"` + DefaultIdentity *string `json:"defaultIdentity,omitempty"` + DisableKeyBasedMetadataWriteAccess *bool `json:"disableKeyBasedMetadataWriteAccess,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + DocumentEndpoint *string `json:"documentEndpoint,omitempty"` + EnableAnalyticalStorage *bool `json:"enableAnalyticalStorage,omitempty"` + EnableAutomaticFailover *bool `json:"enableAutomaticFailover,omitempty"` + EnableBurstCapacity *bool `json:"enableBurstCapacity,omitempty"` + EnableCassandraConnector *bool `json:"enableCassandraConnector,omitempty"` + EnableFreeTier *bool `json:"enableFreeTier,omitempty"` + EnableMultipleWriteLocations *bool `json:"enableMultipleWriteLocations,omitempty"` + EnablePartitionMerge *bool `json:"enablePartitionMerge,omitempty"` + EnablePerRegionPerPartitionAutoscale *bool `json:"enablePerRegionPerPartitionAutoscale,omitempty"` + FailoverPolicies *[]FailoverPolicy `json:"failoverPolicies,omitempty"` + IPRules *[]IPAddressOrRange `json:"ipRules,omitempty"` + InstanceId *string `json:"instanceId,omitempty"` + IsVirtualNetworkFilterEnabled *bool `json:"isVirtualNetworkFilterEnabled,omitempty"` + KeyVaultKeyUri *string `json:"keyVaultKeyUri,omitempty"` + KeysMetadata *DatabaseAccountKeysMetadata `json:"keysMetadata,omitempty"` + Locations *[]Location `json:"locations,omitempty"` + MinimalTlsVersion *MinimalTlsVersion `json:"minimalTlsVersion,omitempty"` + NetworkAclBypass *NetworkAclBypass `json:"networkAclBypass,omitempty"` + NetworkAclBypassResourceIds *[]string `json:"networkAclBypassResourceIds,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + ReadLocations *[]Location `json:"readLocations,omitempty"` + RestoreParameters *RestoreParameters `json:"restoreParameters,omitempty"` + VirtualNetworkRules *[]VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` + WriteLocations *[]Location `json:"writeLocations,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AnalyticalStorageConfiguration = decoded.AnalyticalStorageConfiguration + s.ApiProperties = decoded.ApiProperties + s.Capabilities = decoded.Capabilities + s.Capacity = decoded.Capacity + s.ConnectorOffer = decoded.ConnectorOffer + s.ConsistencyPolicy = decoded.ConsistencyPolicy + s.Cors = decoded.Cors + s.CreateMode = decoded.CreateMode + s.CustomerManagedKeyStatus = decoded.CustomerManagedKeyStatus + s.DatabaseAccountOfferType = decoded.DatabaseAccountOfferType + s.DefaultIdentity = decoded.DefaultIdentity + s.DisableKeyBasedMetadataWriteAccess = decoded.DisableKeyBasedMetadataWriteAccess + s.DisableLocalAuth = decoded.DisableLocalAuth + s.DocumentEndpoint = decoded.DocumentEndpoint + s.EnableAnalyticalStorage = decoded.EnableAnalyticalStorage + s.EnableAutomaticFailover = decoded.EnableAutomaticFailover + s.EnableBurstCapacity = decoded.EnableBurstCapacity + s.EnableCassandraConnector = decoded.EnableCassandraConnector + s.EnableFreeTier = decoded.EnableFreeTier + s.EnableMultipleWriteLocations = decoded.EnableMultipleWriteLocations + s.EnablePartitionMerge = decoded.EnablePartitionMerge + s.EnablePerRegionPerPartitionAutoscale = decoded.EnablePerRegionPerPartitionAutoscale + s.FailoverPolicies = decoded.FailoverPolicies + s.IPRules = decoded.IPRules + s.InstanceId = decoded.InstanceId + s.IsVirtualNetworkFilterEnabled = decoded.IsVirtualNetworkFilterEnabled + s.KeyVaultKeyUri = decoded.KeyVaultKeyUri + s.KeysMetadata = decoded.KeysMetadata + s.Locations = decoded.Locations + s.MinimalTlsVersion = decoded.MinimalTlsVersion + s.NetworkAclBypass = decoded.NetworkAclBypass + s.NetworkAclBypassResourceIds = decoded.NetworkAclBypassResourceIds + s.PrivateEndpointConnections = decoded.PrivateEndpointConnections + s.ProvisioningState = decoded.ProvisioningState + s.PublicNetworkAccess = decoded.PublicNetworkAccess + s.ReadLocations = decoded.ReadLocations + s.RestoreParameters = decoded.RestoreParameters + s.VirtualNetworkRules = decoded.VirtualNetworkRules + s.WriteLocations = decoded.WriteLocations + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling DatabaseAccountGetProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["backupPolicy"]; ok { + impl, err := UnmarshalBackupPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'BackupPolicy' for 'DatabaseAccountGetProperties': %+v", err) + } + s.BackupPolicy = impl + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountgetresults.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountgetresults.go new file mode 100644 index 00000000000..66628203254 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountgetresults.go @@ -0,0 +1,21 @@ +package cosmosdb + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseAccountGetResults struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *DatabaseAccountKind `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DatabaseAccountGetProperties `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/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountkeysmetadata.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountkeysmetadata.go new file mode 100644 index 00000000000..6c27837aef6 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountkeysmetadata.go @@ -0,0 +1,11 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseAccountKeysMetadata struct { + PrimaryMasterKey *AccountKeyMetadata `json:"primaryMasterKey,omitempty"` + PrimaryReadonlyMasterKey *AccountKeyMetadata `json:"primaryReadonlyMasterKey,omitempty"` + SecondaryMasterKey *AccountKeyMetadata `json:"secondaryMasterKey,omitempty"` + SecondaryReadonlyMasterKey *AccountKeyMetadata `json:"secondaryReadonlyMasterKey,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountlistconnectionstringsresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountlistconnectionstringsresult.go new file mode 100644 index 00000000000..2d12a4bf115 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountlistconnectionstringsresult.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseAccountListConnectionStringsResult struct { + ConnectionStrings *[]DatabaseAccountConnectionString `json:"connectionStrings,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountlistkeysresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountlistkeysresult.go new file mode 100644 index 00000000000..0b5791f5e82 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountlistkeysresult.go @@ -0,0 +1,11 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseAccountListKeysResult struct { + PrimaryMasterKey *string `json:"primaryMasterKey,omitempty"` + PrimaryReadonlyMasterKey *string `json:"primaryReadonlyMasterKey,omitempty"` + SecondaryMasterKey *string `json:"secondaryMasterKey,omitempty"` + SecondaryReadonlyMasterKey *string `json:"secondaryReadonlyMasterKey,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountlistreadonlykeysresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountlistreadonlykeysresult.go new file mode 100644 index 00000000000..94449f23b73 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountlistreadonlykeysresult.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseAccountListReadOnlyKeysResult struct { + PrimaryReadonlyMasterKey *string `json:"primaryReadonlyMasterKey,omitempty"` + SecondaryReadonlyMasterKey *string `json:"secondaryReadonlyMasterKey,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountregeneratekeyparameters.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountregeneratekeyparameters.go new file mode 100644 index 00000000000..24127f1ebf5 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountregeneratekeyparameters.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseAccountRegenerateKeyParameters struct { + KeyKind KeyKind `json:"keyKind"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountslistresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountslistresult.go new file mode 100644 index 00000000000..3ebc1f95822 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountslistresult.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseAccountsListResult struct { + Value *[]DatabaseAccountGetResults `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountupdateparameters.go new file mode 100644 index 00000000000..490983c3a36 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountupdateparameters.go @@ -0,0 +1,15 @@ +package cosmosdb + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseAccountUpdateParameters struct { + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Properties *DatabaseAccountUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountupdateproperties.go new file mode 100644 index 00000000000..129f48af19f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaseaccountupdateproperties.go @@ -0,0 +1,126 @@ +package cosmosdb + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseAccountUpdateProperties struct { + AnalyticalStorageConfiguration *AnalyticalStorageConfiguration `json:"analyticalStorageConfiguration,omitempty"` + ApiProperties *ApiProperties `json:"apiProperties,omitempty"` + BackupPolicy BackupPolicy `json:"backupPolicy"` + Capabilities *[]Capability `json:"capabilities,omitempty"` + Capacity *Capacity `json:"capacity,omitempty"` + ConnectorOffer *ConnectorOffer `json:"connectorOffer,omitempty"` + ConsistencyPolicy *ConsistencyPolicy `json:"consistencyPolicy,omitempty"` + Cors *[]CorsPolicy `json:"cors,omitempty"` + CustomerManagedKeyStatus *string `json:"customerManagedKeyStatus,omitempty"` + DefaultIdentity *string `json:"defaultIdentity,omitempty"` + DisableKeyBasedMetadataWriteAccess *bool `json:"disableKeyBasedMetadataWriteAccess,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + EnableAnalyticalStorage *bool `json:"enableAnalyticalStorage,omitempty"` + EnableAutomaticFailover *bool `json:"enableAutomaticFailover,omitempty"` + EnableBurstCapacity *bool `json:"enableBurstCapacity,omitempty"` + EnableCassandraConnector *bool `json:"enableCassandraConnector,omitempty"` + EnableFreeTier *bool `json:"enableFreeTier,omitempty"` + EnableMultipleWriteLocations *bool `json:"enableMultipleWriteLocations,omitempty"` + EnablePartitionMerge *bool `json:"enablePartitionMerge,omitempty"` + EnablePerRegionPerPartitionAutoscale *bool `json:"enablePerRegionPerPartitionAutoscale,omitempty"` + IPRules *[]IPAddressOrRange `json:"ipRules,omitempty"` + IsVirtualNetworkFilterEnabled *bool `json:"isVirtualNetworkFilterEnabled,omitempty"` + KeyVaultKeyUri *string `json:"keyVaultKeyUri,omitempty"` + KeysMetadata *DatabaseAccountKeysMetadata `json:"keysMetadata,omitempty"` + Locations *[]Location `json:"locations,omitempty"` + MinimalTlsVersion *MinimalTlsVersion `json:"minimalTlsVersion,omitempty"` + NetworkAclBypass *NetworkAclBypass `json:"networkAclBypass,omitempty"` + NetworkAclBypassResourceIds *[]string `json:"networkAclBypassResourceIds,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + VirtualNetworkRules *[]VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` +} + +var _ json.Unmarshaler = &DatabaseAccountUpdateProperties{} + +func (s *DatabaseAccountUpdateProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AnalyticalStorageConfiguration *AnalyticalStorageConfiguration `json:"analyticalStorageConfiguration,omitempty"` + ApiProperties *ApiProperties `json:"apiProperties,omitempty"` + Capabilities *[]Capability `json:"capabilities,omitempty"` + Capacity *Capacity `json:"capacity,omitempty"` + ConnectorOffer *ConnectorOffer `json:"connectorOffer,omitempty"` + ConsistencyPolicy *ConsistencyPolicy `json:"consistencyPolicy,omitempty"` + Cors *[]CorsPolicy `json:"cors,omitempty"` + CustomerManagedKeyStatus *string `json:"customerManagedKeyStatus,omitempty"` + DefaultIdentity *string `json:"defaultIdentity,omitempty"` + DisableKeyBasedMetadataWriteAccess *bool `json:"disableKeyBasedMetadataWriteAccess,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + EnableAnalyticalStorage *bool `json:"enableAnalyticalStorage,omitempty"` + EnableAutomaticFailover *bool `json:"enableAutomaticFailover,omitempty"` + EnableBurstCapacity *bool `json:"enableBurstCapacity,omitempty"` + EnableCassandraConnector *bool `json:"enableCassandraConnector,omitempty"` + EnableFreeTier *bool `json:"enableFreeTier,omitempty"` + EnableMultipleWriteLocations *bool `json:"enableMultipleWriteLocations,omitempty"` + EnablePartitionMerge *bool `json:"enablePartitionMerge,omitempty"` + EnablePerRegionPerPartitionAutoscale *bool `json:"enablePerRegionPerPartitionAutoscale,omitempty"` + IPRules *[]IPAddressOrRange `json:"ipRules,omitempty"` + IsVirtualNetworkFilterEnabled *bool `json:"isVirtualNetworkFilterEnabled,omitempty"` + KeyVaultKeyUri *string `json:"keyVaultKeyUri,omitempty"` + KeysMetadata *DatabaseAccountKeysMetadata `json:"keysMetadata,omitempty"` + Locations *[]Location `json:"locations,omitempty"` + MinimalTlsVersion *MinimalTlsVersion `json:"minimalTlsVersion,omitempty"` + NetworkAclBypass *NetworkAclBypass `json:"networkAclBypass,omitempty"` + NetworkAclBypassResourceIds *[]string `json:"networkAclBypassResourceIds,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + VirtualNetworkRules *[]VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AnalyticalStorageConfiguration = decoded.AnalyticalStorageConfiguration + s.ApiProperties = decoded.ApiProperties + s.Capabilities = decoded.Capabilities + s.Capacity = decoded.Capacity + s.ConnectorOffer = decoded.ConnectorOffer + s.ConsistencyPolicy = decoded.ConsistencyPolicy + s.Cors = decoded.Cors + s.CustomerManagedKeyStatus = decoded.CustomerManagedKeyStatus + s.DefaultIdentity = decoded.DefaultIdentity + s.DisableKeyBasedMetadataWriteAccess = decoded.DisableKeyBasedMetadataWriteAccess + s.DisableLocalAuth = decoded.DisableLocalAuth + s.EnableAnalyticalStorage = decoded.EnableAnalyticalStorage + s.EnableAutomaticFailover = decoded.EnableAutomaticFailover + s.EnableBurstCapacity = decoded.EnableBurstCapacity + s.EnableCassandraConnector = decoded.EnableCassandraConnector + s.EnableFreeTier = decoded.EnableFreeTier + s.EnableMultipleWriteLocations = decoded.EnableMultipleWriteLocations + s.EnablePartitionMerge = decoded.EnablePartitionMerge + s.EnablePerRegionPerPartitionAutoscale = decoded.EnablePerRegionPerPartitionAutoscale + s.IPRules = decoded.IPRules + s.IsVirtualNetworkFilterEnabled = decoded.IsVirtualNetworkFilterEnabled + s.KeyVaultKeyUri = decoded.KeyVaultKeyUri + s.KeysMetadata = decoded.KeysMetadata + s.Locations = decoded.Locations + s.MinimalTlsVersion = decoded.MinimalTlsVersion + s.NetworkAclBypass = decoded.NetworkAclBypass + s.NetworkAclBypassResourceIds = decoded.NetworkAclBypassResourceIds + s.PublicNetworkAccess = decoded.PublicNetworkAccess + s.VirtualNetworkRules = decoded.VirtualNetworkRules + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling DatabaseAccountUpdateProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["backupPolicy"]; ok { + impl, err := UnmarshalBackupPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'BackupPolicy' for 'DatabaseAccountUpdateProperties': %+v", err) + } + s.BackupPolicy = impl + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaserestoreresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaserestoreresource.go new file mode 100644 index 00000000000..dbd1f8d8ae2 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_databaserestoreresource.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseRestoreResource struct { + CollectionNames *[]string `json:"collectionNames,omitempty"` + DatabaseName *string `json:"databaseName,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_excludedpath.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_excludedpath.go new file mode 100644 index 00000000000..bde95e9be55 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_excludedpath.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExcludedPath struct { + Path *string `json:"path,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_failoverpolicies.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_failoverpolicies.go new file mode 100644 index 00000000000..74ed3bdeb21 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_failoverpolicies.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FailoverPolicies struct { + FailoverPolicies []FailoverPolicy `json:"failoverPolicies"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_failoverpolicy.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_failoverpolicy.go new file mode 100644 index 00000000000..097c14580fd --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_failoverpolicy.go @@ -0,0 +1,10 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FailoverPolicy struct { + FailoverPriority *int64 `json:"failoverPriority,omitempty"` + Id *string `json:"id,omitempty"` + LocationName *string `json:"locationName,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabasecreateupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabasecreateupdateparameters.go new file mode 100644 index 00000000000..c231e4cc38f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabasecreateupdateparameters.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GremlinDatabaseCreateUpdateParameters struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties GremlinDatabaseCreateUpdateProperties `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabasecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabasecreateupdateproperties.go new file mode 100644 index 00000000000..8c73f95990d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabasecreateupdateproperties.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GremlinDatabaseCreateUpdateProperties struct { + Options *CreateUpdateOptions `json:"options,omitempty"` + Resource GremlinDatabaseResource `json:"resource"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabasegetproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabasegetproperties.go new file mode 100644 index 00000000000..6cab09ef632 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabasegetproperties.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GremlinDatabaseGetProperties struct { + Options *OptionsResource `json:"options,omitempty"` + Resource *GremlinDatabaseGetPropertiesResource `json:"resource,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabasegetpropertiesresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabasegetpropertiesresource.go new file mode 100644 index 00000000000..8824421f703 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabasegetpropertiesresource.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GremlinDatabaseGetPropertiesResource struct { + CreateMode *CreateMode `json:"createMode,omitempty"` + Etag *string `json:"_etag,omitempty"` + Id *string `json:"id,omitempty"` + RestoreParameters *RestoreParametersBase `json:"restoreParameters,omitempty"` + Rid *string `json:"_rid,omitempty"` + Ts *float64 `json:"_ts,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabasegetresults.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabasegetresults.go new file mode 100644 index 00000000000..697b3fa2c47 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabasegetresults.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GremlinDatabaseGetResults struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *GremlinDatabaseGetProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabaselistresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabaselistresult.go new file mode 100644 index 00000000000..6cfabd66c63 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabaselistresult.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GremlinDatabaseListResult struct { + Value *[]GremlinDatabaseGetResults `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabaseresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabaseresource.go new file mode 100644 index 00000000000..7ec94a72a67 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabaseresource.go @@ -0,0 +1,10 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GremlinDatabaseResource struct { + CreateMode *CreateMode `json:"createMode,omitempty"` + Id string `json:"id"` + RestoreParameters *RestoreParametersBase `json:"restoreParameters,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabaserestoreresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabaserestoreresource.go new file mode 100644 index 00000000000..78d1f64828b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlindatabaserestoreresource.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GremlinDatabaseRestoreResource struct { + DatabaseName *string `json:"databaseName,omitempty"` + GraphNames *[]string `json:"graphNames,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlingraphcreateupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlingraphcreateupdateparameters.go new file mode 100644 index 00000000000..21a8cf39529 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlingraphcreateupdateparameters.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GremlinGraphCreateUpdateParameters struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties GremlinGraphCreateUpdateProperties `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlingraphcreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlingraphcreateupdateproperties.go new file mode 100644 index 00000000000..c0523a35b18 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlingraphcreateupdateproperties.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GremlinGraphCreateUpdateProperties struct { + Options *CreateUpdateOptions `json:"options,omitempty"` + Resource GremlinGraphResource `json:"resource"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlingraphgetproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlingraphgetproperties.go new file mode 100644 index 00000000000..fe2eb68f1d8 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlingraphgetproperties.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GremlinGraphGetProperties struct { + Options *OptionsResource `json:"options,omitempty"` + Resource *GremlinGraphGetPropertiesResource `json:"resource,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlingraphgetpropertiesresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlingraphgetpropertiesresource.go new file mode 100644 index 00000000000..671a45e836a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlingraphgetpropertiesresource.go @@ -0,0 +1,19 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GremlinGraphGetPropertiesResource struct { + AnalyticalStorageTtl *int64 `json:"analyticalStorageTtl,omitempty"` + ConflictResolutionPolicy *ConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DefaultTtl *int64 `json:"defaultTtl,omitempty"` + Etag *string `json:"_etag,omitempty"` + Id *string `json:"id,omitempty"` + IndexingPolicy *IndexingPolicy `json:"indexingPolicy,omitempty"` + PartitionKey *ContainerPartitionKey `json:"partitionKey,omitempty"` + RestoreParameters *RestoreParametersBase `json:"restoreParameters,omitempty"` + Rid *string `json:"_rid,omitempty"` + Ts *float64 `json:"_ts,omitempty"` + UniqueKeyPolicy *UniqueKeyPolicy `json:"uniqueKeyPolicy,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlingraphgetresults.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlingraphgetresults.go new file mode 100644 index 00000000000..fb47954496d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlingraphgetresults.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GremlinGraphGetResults struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *GremlinGraphGetProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlingraphlistresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlingraphlistresult.go new file mode 100644 index 00000000000..596577d1c37 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlingraphlistresult.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GremlinGraphListResult struct { + Value *[]GremlinGraphGetResults `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlingraphresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlingraphresource.go new file mode 100644 index 00000000000..3404319499d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_gremlingraphresource.go @@ -0,0 +1,16 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GremlinGraphResource struct { + AnalyticalStorageTtl *int64 `json:"analyticalStorageTtl,omitempty"` + ConflictResolutionPolicy *ConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DefaultTtl *int64 `json:"defaultTtl,omitempty"` + Id string `json:"id"` + IndexingPolicy *IndexingPolicy `json:"indexingPolicy,omitempty"` + PartitionKey *ContainerPartitionKey `json:"partitionKey,omitempty"` + RestoreParameters *RestoreParametersBase `json:"restoreParameters,omitempty"` + UniqueKeyPolicy *UniqueKeyPolicy `json:"uniqueKeyPolicy,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_includedpath.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_includedpath.go new file mode 100644 index 00000000000..fabdeb9057f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_includedpath.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IncludedPath struct { + Indexes *[]Indexes `json:"indexes,omitempty"` + Path *string `json:"path,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_indexes.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_indexes.go new file mode 100644 index 00000000000..c9329116817 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_indexes.go @@ -0,0 +1,10 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Indexes struct { + DataType *DataType `json:"dataType,omitempty"` + Kind *IndexKind `json:"kind,omitempty"` + Precision *int64 `json:"precision,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_indexingpolicy.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_indexingpolicy.go new file mode 100644 index 00000000000..c45ba92ffd7 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_indexingpolicy.go @@ -0,0 +1,14 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IndexingPolicy struct { + Automatic *bool `json:"automatic,omitempty"` + CompositeIndexes *[][]CompositePath `json:"compositeIndexes,omitempty"` + ExcludedPaths *[]ExcludedPath `json:"excludedPaths,omitempty"` + IncludedPaths *[]IncludedPath `json:"includedPaths,omitempty"` + IndexingMode *IndexingMode `json:"indexingMode,omitempty"` + SpatialIndexes *[]SpatialSpec `json:"spatialIndexes,omitempty"` + VectorIndexes *[]VectorIndex `json:"vectorIndexes,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_ipaddressorrange.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_ipaddressorrange.go new file mode 100644 index 00000000000..d98bf6d3d73 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_ipaddressorrange.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPAddressOrRange struct { + IPAddressOrRange *string `json:"ipAddressOrRange,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_keywrapmetadata.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_keywrapmetadata.go new file mode 100644 index 00000000000..1bf8dd8076c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_keywrapmetadata.go @@ -0,0 +1,11 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyWrapMetadata struct { + Algorithm *string `json:"algorithm,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_location.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_location.go new file mode 100644 index 00000000000..88037b00dc7 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_location.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Location struct { + DocumentEndpoint *string `json:"documentEndpoint,omitempty"` + FailoverPriority *int64 `json:"failoverPriority,omitempty"` + Id *string `json:"id,omitempty"` + IsZoneRedundant *bool `json:"isZoneRedundant,omitempty"` + LocationName *string `json:"locationName,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_locationgetresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_locationgetresult.go new file mode 100644 index 00000000000..fcfc7e8f075 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_locationgetresult.go @@ -0,0 +1,11 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocationGetResult struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *LocationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_locationlistresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_locationlistresult.go new file mode 100644 index 00000000000..91b00e28014 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_locationlistresult.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocationListResult struct { + Value *[]LocationGetResult `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_locationproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_locationproperties.go new file mode 100644 index 00000000000..90e7cdde389 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_locationproperties.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocationProperties struct { + BackupStorageRedundancies *[]BackupStorageRedundancy `json:"backupStorageRedundancies,omitempty"` + IsResidencyRestricted *bool `json:"isResidencyRestricted,omitempty"` + IsSubscriptionRegionAccessAllowedForAz *bool `json:"isSubscriptionRegionAccessAllowedForAz,omitempty"` + IsSubscriptionRegionAccessAllowedForRegular *bool `json:"isSubscriptionRegionAccessAllowedForRegular,omitempty"` + Status *Status `json:"status,omitempty"` + SupportsAvailabilityZone *bool `json:"supportsAvailabilityZone,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_metric.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_metric.go new file mode 100644 index 00000000000..86519de0a64 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_metric.go @@ -0,0 +1,43 @@ +package cosmosdb + +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 Metric struct { + EndTime *string `json:"endTime,omitempty"` + MetricValues *[]MetricValue `json:"metricValues,omitempty"` + Name *MetricName `json:"name,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimeGrain *string `json:"timeGrain,omitempty"` + Unit *UnitType `json:"unit,omitempty"` +} + +func (o *Metric) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *Metric) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *Metric) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *Metric) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_metricavailability.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_metricavailability.go new file mode 100644 index 00000000000..eb8fb801ac8 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_metricavailability.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MetricAvailability struct { + Retention *string `json:"retention,omitempty"` + TimeGrain *string `json:"timeGrain,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_metricdefinition.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_metricdefinition.go new file mode 100644 index 00000000000..cc6ee5b2df0 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_metricdefinition.go @@ -0,0 +1,12 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MetricDefinition struct { + MetricAvailabilities *[]MetricAvailability `json:"metricAvailabilities,omitempty"` + Name *MetricName `json:"name,omitempty"` + PrimaryAggregationType *PrimaryAggregationType `json:"primaryAggregationType,omitempty"` + ResourceUri *string `json:"resourceUri,omitempty"` + Unit *UnitType `json:"unit,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_metricdefinitionslistresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_metricdefinitionslistresult.go new file mode 100644 index 00000000000..8e95145ff46 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_metricdefinitionslistresult.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MetricDefinitionsListResult struct { + Value *[]MetricDefinition `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_metriclistresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_metriclistresult.go new file mode 100644 index 00000000000..2adeed3a122 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_metriclistresult.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MetricListResult struct { + Value *[]Metric `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_metricname.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_metricname.go new file mode 100644 index 00000000000..4b4b6b6bf68 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_metricname.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MetricName struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_metricvalue.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_metricvalue.go new file mode 100644 index 00000000000..e1daf9ac54c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_metricvalue.go @@ -0,0 +1,31 @@ +package cosmosdb + +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 MetricValue struct { + Average *float64 `json:"average,omitempty"` + Count *float64 `json:"_count,omitempty"` + Maximum *float64 `json:"maximum,omitempty"` + Minimum *float64 `json:"minimum,omitempty"` + Timestamp *string `json:"timestamp,omitempty"` + Total *float64 `json:"total,omitempty"` +} + +func (o *MetricValue) GetTimestampAsTime() (*time.Time, error) { + if o.Timestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Timestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *MetricValue) SetTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Timestamp = &formatted +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbcollectioncreateupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbcollectioncreateupdateparameters.go new file mode 100644 index 00000000000..2cc7d6a6c21 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbcollectioncreateupdateparameters.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoDBCollectionCreateUpdateParameters struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties MongoDBCollectionCreateUpdateProperties `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbcollectioncreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbcollectioncreateupdateproperties.go new file mode 100644 index 00000000000..94b9078b945 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbcollectioncreateupdateproperties.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoDBCollectionCreateUpdateProperties struct { + Options *CreateUpdateOptions `json:"options,omitempty"` + Resource MongoDBCollectionResource `json:"resource"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbcollectiongetproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbcollectiongetproperties.go new file mode 100644 index 00000000000..8316bb85fa7 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbcollectiongetproperties.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoDBCollectionGetProperties struct { + Options *OptionsResource `json:"options,omitempty"` + Resource *MongoDBCollectionGetPropertiesResource `json:"resource,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbcollectiongetpropertiesresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbcollectiongetpropertiesresource.go new file mode 100644 index 00000000000..4d7d8bd27e2 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbcollectiongetpropertiesresource.go @@ -0,0 +1,16 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoDBCollectionGetPropertiesResource struct { + AnalyticalStorageTtl *int64 `json:"analyticalStorageTtl,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + Etag *string `json:"_etag,omitempty"` + Id *string `json:"id,omitempty"` + Indexes *[]MongoIndex `json:"indexes,omitempty"` + RestoreParameters *RestoreParametersBase `json:"restoreParameters,omitempty"` + Rid *string `json:"_rid,omitempty"` + ShardKey *map[string]string `json:"shardKey,omitempty"` + Ts *float64 `json:"_ts,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbcollectiongetresults.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbcollectiongetresults.go new file mode 100644 index 00000000000..1e010f172d8 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbcollectiongetresults.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoDBCollectionGetResults struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MongoDBCollectionGetProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbcollectionlistresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbcollectionlistresult.go new file mode 100644 index 00000000000..ff9a2992f7a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbcollectionlistresult.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoDBCollectionListResult struct { + Value *[]MongoDBCollectionGetResults `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbcollectionresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbcollectionresource.go new file mode 100644 index 00000000000..b8289734332 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbcollectionresource.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoDBCollectionResource struct { + AnalyticalStorageTtl *int64 `json:"analyticalStorageTtl,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + Id string `json:"id"` + Indexes *[]MongoIndex `json:"indexes,omitempty"` + RestoreParameters *RestoreParametersBase `json:"restoreParameters,omitempty"` + ShardKey *map[string]string `json:"shardKey,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbdatabasecreateupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbdatabasecreateupdateparameters.go new file mode 100644 index 00000000000..39f29eca06a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbdatabasecreateupdateparameters.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoDBDatabaseCreateUpdateParameters struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties MongoDBDatabaseCreateUpdateProperties `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbdatabasecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbdatabasecreateupdateproperties.go new file mode 100644 index 00000000000..e2742259aad --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbdatabasecreateupdateproperties.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoDBDatabaseCreateUpdateProperties struct { + Options *CreateUpdateOptions `json:"options,omitempty"` + Resource MongoDBDatabaseResource `json:"resource"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbdatabasegetproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbdatabasegetproperties.go new file mode 100644 index 00000000000..3e65627e34a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbdatabasegetproperties.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoDBDatabaseGetProperties struct { + Options *OptionsResource `json:"options,omitempty"` + Resource *MongoDBDatabaseGetPropertiesResource `json:"resource,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbdatabasegetpropertiesresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbdatabasegetpropertiesresource.go new file mode 100644 index 00000000000..73e2923e280 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbdatabasegetpropertiesresource.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoDBDatabaseGetPropertiesResource struct { + CreateMode *CreateMode `json:"createMode,omitempty"` + Etag *string `json:"_etag,omitempty"` + Id *string `json:"id,omitempty"` + RestoreParameters *RestoreParametersBase `json:"restoreParameters,omitempty"` + Rid *string `json:"_rid,omitempty"` + Ts *float64 `json:"_ts,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbdatabasegetresults.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbdatabasegetresults.go new file mode 100644 index 00000000000..a46ab4a9340 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbdatabasegetresults.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoDBDatabaseGetResults struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MongoDBDatabaseGetProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbdatabaselistresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbdatabaselistresult.go new file mode 100644 index 00000000000..bd2d989ab0e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbdatabaselistresult.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoDBDatabaseListResult struct { + Value *[]MongoDBDatabaseGetResults `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbdatabaseresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbdatabaseresource.go new file mode 100644 index 00000000000..1e53b6b4e7b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongodbdatabaseresource.go @@ -0,0 +1,10 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoDBDatabaseResource struct { + CreateMode *CreateMode `json:"createMode,omitempty"` + Id string `json:"id"` + RestoreParameters *RestoreParametersBase `json:"restoreParameters,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongoindex.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongoindex.go new file mode 100644 index 00000000000..a6107d1601e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongoindex.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoIndex struct { + Key *MongoIndexKeys `json:"key,omitempty"` + Options *MongoIndexOptions `json:"options,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongoindexkeys.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongoindexkeys.go new file mode 100644 index 00000000000..a86dd3accb1 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongoindexkeys.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoIndexKeys struct { + Keys *[]string `json:"keys,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongoindexoptions.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongoindexoptions.go new file mode 100644 index 00000000000..1a1d7b4d8ee --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_mongoindexoptions.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoIndexOptions struct { + ExpireAfterSeconds *int64 `json:"expireAfterSeconds,omitempty"` + Unique *bool `json:"unique,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_optionsresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_optionsresource.go new file mode 100644 index 00000000000..59afcc42242 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_optionsresource.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OptionsResource struct { + AutoScaleSettings *AutoScaleSettings `json:"autoscaleSettings,omitempty"` + Throughput *int64 `json:"throughput,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_partitionmetric.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_partitionmetric.go new file mode 100644 index 00000000000..e1f09dcd6e4 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_partitionmetric.go @@ -0,0 +1,45 @@ +package cosmosdb + +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 PartitionMetric struct { + EndTime *string `json:"endTime,omitempty"` + MetricValues *[]MetricValue `json:"metricValues,omitempty"` + Name *MetricName `json:"name,omitempty"` + PartitionId *string `json:"partitionId,omitempty"` + PartitionKeyRangeId *string `json:"partitionKeyRangeId,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimeGrain *string `json:"timeGrain,omitempty"` + Unit *UnitType `json:"unit,omitempty"` +} + +func (o *PartitionMetric) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PartitionMetric) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *PartitionMetric) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PartitionMetric) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_partitionmetriclistresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_partitionmetriclistresult.go new file mode 100644 index 00000000000..201be59ac64 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_partitionmetriclistresult.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PartitionMetricListResult struct { + Value *[]PartitionMetric `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_partitionusage.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_partitionusage.go new file mode 100644 index 00000000000..a480ca1758f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_partitionusage.go @@ -0,0 +1,14 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PartitionUsage struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *MetricName `json:"name,omitempty"` + PartitionId *string `json:"partitionId,omitempty"` + PartitionKeyRangeId *string `json:"partitionKeyRangeId,omitempty"` + QuotaPeriod *string `json:"quotaPeriod,omitempty"` + Unit *UnitType `json:"unit,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_partitionusagesresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_partitionusagesresult.go new file mode 100644 index 00000000000..6d9d8fcb080 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_partitionusagesresult.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PartitionUsagesResult struct { + Value *[]PartitionUsage `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_percentilemetric.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_percentilemetric.go new file mode 100644 index 00000000000..3970d324e53 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_percentilemetric.go @@ -0,0 +1,43 @@ +package cosmosdb + +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 PercentileMetric struct { + EndTime *string `json:"endTime,omitempty"` + MetricValues *[]PercentileMetricValue `json:"metricValues,omitempty"` + Name *MetricName `json:"name,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimeGrain *string `json:"timeGrain,omitempty"` + Unit *UnitType `json:"unit,omitempty"` +} + +func (o *PercentileMetric) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PercentileMetric) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *PercentileMetric) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PercentileMetric) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_percentilemetriclistresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_percentilemetriclistresult.go new file mode 100644 index 00000000000..29162dadfc9 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_percentilemetriclistresult.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PercentileMetricListResult struct { + Value *[]PercentileMetric `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_percentilemetricvalue.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_percentilemetricvalue.go new file mode 100644 index 00000000000..38c6ab31142 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_percentilemetricvalue.go @@ -0,0 +1,38 @@ +package cosmosdb + +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 PercentileMetricValue struct { + Average *float64 `json:"average,omitempty"` + Count *float64 `json:"_count,omitempty"` + Maximum *float64 `json:"maximum,omitempty"` + Minimum *float64 `json:"minimum,omitempty"` + P10 *float64 `json:"P10,omitempty"` + P25 *float64 `json:"P25,omitempty"` + P50 *float64 `json:"P50,omitempty"` + P75 *float64 `json:"P75,omitempty"` + P90 *float64 `json:"P90,omitempty"` + P95 *float64 `json:"P95,omitempty"` + P99 *float64 `json:"P99,omitempty"` + Timestamp *string `json:"timestamp,omitempty"` + Total *float64 `json:"total,omitempty"` +} + +func (o *PercentileMetricValue) GetTimestampAsTime() (*time.Time, error) { + if o.Timestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Timestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *PercentileMetricValue) SetTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Timestamp = &formatted +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_periodicmodebackuppolicy.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_periodicmodebackuppolicy.go new file mode 100644 index 00000000000..0ead8c8a1f7 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_periodicmodebackuppolicy.go @@ -0,0 +1,52 @@ +package cosmosdb + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ BackupPolicy = PeriodicModeBackupPolicy{} + +type PeriodicModeBackupPolicy struct { + PeriodicModeProperties *PeriodicModeProperties `json:"periodicModeProperties,omitempty"` + + // Fields inherited from BackupPolicy + + MigrationState *BackupPolicyMigrationState `json:"migrationState,omitempty"` + Type BackupPolicyType `json:"type"` +} + +func (s PeriodicModeBackupPolicy) BackupPolicy() BaseBackupPolicyImpl { + return BaseBackupPolicyImpl{ + MigrationState: s.MigrationState, + Type: s.Type, + } +} + +var _ json.Marshaler = PeriodicModeBackupPolicy{} + +func (s PeriodicModeBackupPolicy) MarshalJSON() ([]byte, error) { + type wrapper PeriodicModeBackupPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling PeriodicModeBackupPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling PeriodicModeBackupPolicy: %+v", err) + } + + decoded["type"] = "Periodic" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling PeriodicModeBackupPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_periodicmodeproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_periodicmodeproperties.go new file mode 100644 index 00000000000..91556dc1a2c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_periodicmodeproperties.go @@ -0,0 +1,10 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PeriodicModeProperties struct { + BackupIntervalInMinutes *int64 `json:"backupIntervalInMinutes,omitempty"` + BackupRetentionIntervalInHours *int64 `json:"backupRetentionIntervalInHours,omitempty"` + BackupStorageRedundancy *BackupStorageRedundancy `json:"backupStorageRedundancy,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_privateendpointconnection.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_privateendpointconnection.go new file mode 100644 index 00000000000..252869eaec2 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_privateendpointconnection.go @@ -0,0 +1,11 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_privateendpointconnectionproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..ce1d70df3e5 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupId *string `json:"groupId,omitempty"` + PrivateEndpoint *PrivateEndpointProperty `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionStateProperty `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_privateendpointproperty.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_privateendpointproperty.go new file mode 100644 index 00000000000..19db84013f4 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_privateendpointproperty.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperty struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_privatelinkserviceconnectionstateproperty.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_privatelinkserviceconnectionstateproperty.go new file mode 100644 index 00000000000..06265a92fb4 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_privatelinkserviceconnectionstateproperty.go @@ -0,0 +1,10 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionStateProperty struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_regionforonlineoffline.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_regionforonlineoffline.go new file mode 100644 index 00000000000..8ccb60efd23 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_regionforonlineoffline.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegionForOnlineOffline struct { + Region string `json:"region"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_restoreparameters.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_restoreparameters.go new file mode 100644 index 00000000000..8d67489faa9 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_restoreparameters.go @@ -0,0 +1,32 @@ +package cosmosdb + +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 RestoreParameters struct { + DatabasesToRestore *[]DatabaseRestoreResource `json:"databasesToRestore,omitempty"` + GremlinDatabasesToRestore *[]GremlinDatabaseRestoreResource `json:"gremlinDatabasesToRestore,omitempty"` + RestoreMode *RestoreMode `json:"restoreMode,omitempty"` + RestoreSource *string `json:"restoreSource,omitempty"` + RestoreTimestampInUtc *string `json:"restoreTimestampInUtc,omitempty"` + RestoreWithTtlDisabled *bool `json:"restoreWithTtlDisabled,omitempty"` + TablesToRestore *[]string `json:"tablesToRestore,omitempty"` +} + +func (o *RestoreParameters) GetRestoreTimestampInUtcAsTime() (*time.Time, error) { + if o.RestoreTimestampInUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RestoreTimestampInUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *RestoreParameters) SetRestoreTimestampInUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RestoreTimestampInUtc = &formatted +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_restoreparametersbase.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_restoreparametersbase.go new file mode 100644 index 00000000000..d3097000872 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_restoreparametersbase.go @@ -0,0 +1,28 @@ +package cosmosdb + +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 RestoreParametersBase struct { + RestoreSource *string `json:"restoreSource,omitempty"` + RestoreTimestampInUtc *string `json:"restoreTimestampInUtc,omitempty"` + RestoreWithTtlDisabled *bool `json:"restoreWithTtlDisabled,omitempty"` +} + +func (o *RestoreParametersBase) GetRestoreTimestampInUtcAsTime() (*time.Time, error) { + if o.RestoreTimestampInUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RestoreTimestampInUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *RestoreParametersBase) SetRestoreTimestampInUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RestoreTimestampInUtc = &formatted +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_spatialspec.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_spatialspec.go new file mode 100644 index 00000000000..4282f14daf7 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_spatialspec.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SpatialSpec struct { + Path *string `json:"path,omitempty"` + Types *[]SpatialType `json:"types,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlcontainercreateupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlcontainercreateupdateparameters.go new file mode 100644 index 00000000000..ca6834e6723 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlcontainercreateupdateparameters.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlContainerCreateUpdateParameters struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties SqlContainerCreateUpdateProperties `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlcontainercreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlcontainercreateupdateproperties.go new file mode 100644 index 00000000000..cc551c2ee19 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlcontainercreateupdateproperties.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlContainerCreateUpdateProperties struct { + Options *CreateUpdateOptions `json:"options,omitempty"` + Resource SqlContainerResource `json:"resource"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlcontainergetproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlcontainergetproperties.go new file mode 100644 index 00000000000..ec769b430bf --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlcontainergetproperties.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlContainerGetProperties struct { + Options *OptionsResource `json:"options,omitempty"` + Resource *SqlContainerGetPropertiesResource `json:"resource,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlcontainergetpropertiesresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlcontainergetpropertiesresource.go new file mode 100644 index 00000000000..a73c8b3ade4 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlcontainergetpropertiesresource.go @@ -0,0 +1,22 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlContainerGetPropertiesResource struct { + AnalyticalStorageTtl *int64 `json:"analyticalStorageTtl,omitempty"` + ClientEncryptionPolicy *ClientEncryptionPolicy `json:"clientEncryptionPolicy,omitempty"` + ComputedProperties *[]ComputedProperty `json:"computedProperties,omitempty"` + ConflictResolutionPolicy *ConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DefaultTtl *int64 `json:"defaultTtl,omitempty"` + Etag *string `json:"_etag,omitempty"` + Id *string `json:"id,omitempty"` + IndexingPolicy *IndexingPolicy `json:"indexingPolicy,omitempty"` + PartitionKey *ContainerPartitionKey `json:"partitionKey,omitempty"` + RestoreParameters *RestoreParametersBase `json:"restoreParameters,omitempty"` + Rid *string `json:"_rid,omitempty"` + Ts *float64 `json:"_ts,omitempty"` + UniqueKeyPolicy *UniqueKeyPolicy `json:"uniqueKeyPolicy,omitempty"` + VectorEmbeddingPolicy *VectorEmbeddingPolicy `json:"vectorEmbeddingPolicy,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlcontainergetresults.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlcontainergetresults.go new file mode 100644 index 00000000000..59cde614180 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlcontainergetresults.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlContainerGetResults struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SqlContainerGetProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlcontainerlistresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlcontainerlistresult.go new file mode 100644 index 00000000000..0536cfcc0c6 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlcontainerlistresult.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlContainerListResult struct { + Value *[]SqlContainerGetResults `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlcontainerresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlcontainerresource.go new file mode 100644 index 00000000000..b83e3355936 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlcontainerresource.go @@ -0,0 +1,19 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlContainerResource struct { + AnalyticalStorageTtl *int64 `json:"analyticalStorageTtl,omitempty"` + ClientEncryptionPolicy *ClientEncryptionPolicy `json:"clientEncryptionPolicy,omitempty"` + ComputedProperties *[]ComputedProperty `json:"computedProperties,omitempty"` + ConflictResolutionPolicy *ConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DefaultTtl *int64 `json:"defaultTtl,omitempty"` + Id string `json:"id"` + IndexingPolicy *IndexingPolicy `json:"indexingPolicy,omitempty"` + PartitionKey *ContainerPartitionKey `json:"partitionKey,omitempty"` + RestoreParameters *RestoreParametersBase `json:"restoreParameters,omitempty"` + UniqueKeyPolicy *UniqueKeyPolicy `json:"uniqueKeyPolicy,omitempty"` + VectorEmbeddingPolicy *VectorEmbeddingPolicy `json:"vectorEmbeddingPolicy,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqldatabasecreateupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqldatabasecreateupdateparameters.go new file mode 100644 index 00000000000..050d7c20bb2 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqldatabasecreateupdateparameters.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlDatabaseCreateUpdateParameters struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties SqlDatabaseCreateUpdateProperties `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqldatabasecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqldatabasecreateupdateproperties.go new file mode 100644 index 00000000000..902885b9b94 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqldatabasecreateupdateproperties.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlDatabaseCreateUpdateProperties struct { + Options *CreateUpdateOptions `json:"options,omitempty"` + Resource SqlDatabaseResource `json:"resource"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqldatabasegetproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqldatabasegetproperties.go new file mode 100644 index 00000000000..861bd784b77 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqldatabasegetproperties.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlDatabaseGetProperties struct { + Options *OptionsResource `json:"options,omitempty"` + Resource *SqlDatabaseGetPropertiesResource `json:"resource,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqldatabasegetpropertiesresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqldatabasegetpropertiesresource.go new file mode 100644 index 00000000000..ce2fe1eda48 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqldatabasegetpropertiesresource.go @@ -0,0 +1,15 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlDatabaseGetPropertiesResource struct { + Colls *string `json:"_colls,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + Etag *string `json:"_etag,omitempty"` + Id *string `json:"id,omitempty"` + RestoreParameters *RestoreParametersBase `json:"restoreParameters,omitempty"` + Rid *string `json:"_rid,omitempty"` + Ts *float64 `json:"_ts,omitempty"` + Users *string `json:"_users,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqldatabasegetresults.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqldatabasegetresults.go new file mode 100644 index 00000000000..c78964be911 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqldatabasegetresults.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlDatabaseGetResults struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SqlDatabaseGetProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqldatabaselistresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqldatabaselistresult.go new file mode 100644 index 00000000000..f8f3a703ab3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqldatabaselistresult.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlDatabaseListResult struct { + Value *[]SqlDatabaseGetResults `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqldatabaseresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqldatabaseresource.go new file mode 100644 index 00000000000..f5967f263f6 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqldatabaseresource.go @@ -0,0 +1,10 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlDatabaseResource struct { + CreateMode *CreateMode `json:"createMode,omitempty"` + Id string `json:"id"` + RestoreParameters *RestoreParametersBase `json:"restoreParameters,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlstoredprocedurecreateupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlstoredprocedurecreateupdateparameters.go new file mode 100644 index 00000000000..6aed32d28c6 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlstoredprocedurecreateupdateparameters.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlStoredProcedureCreateUpdateParameters struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties SqlStoredProcedureCreateUpdateProperties `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlstoredprocedurecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlstoredprocedurecreateupdateproperties.go new file mode 100644 index 00000000000..37150ea7e53 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlstoredprocedurecreateupdateproperties.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlStoredProcedureCreateUpdateProperties struct { + Options *CreateUpdateOptions `json:"options,omitempty"` + Resource SqlStoredProcedureResource `json:"resource"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlstoredproceduregetproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlstoredproceduregetproperties.go new file mode 100644 index 00000000000..c0bfd416e39 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlstoredproceduregetproperties.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlStoredProcedureGetProperties struct { + Resource *SqlStoredProcedureGetPropertiesResource `json:"resource,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlstoredproceduregetpropertiesresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlstoredproceduregetpropertiesresource.go new file mode 100644 index 00000000000..db91c00dc1a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlstoredproceduregetpropertiesresource.go @@ -0,0 +1,12 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlStoredProcedureGetPropertiesResource struct { + Body *string `json:"body,omitempty"` + Etag *string `json:"_etag,omitempty"` + Id *string `json:"id,omitempty"` + Rid *string `json:"_rid,omitempty"` + Ts *float64 `json:"_ts,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlstoredproceduregetresults.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlstoredproceduregetresults.go new file mode 100644 index 00000000000..c5d8553b895 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlstoredproceduregetresults.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlStoredProcedureGetResults struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SqlStoredProcedureGetProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlstoredprocedurelistresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlstoredprocedurelistresult.go new file mode 100644 index 00000000000..07aaff40a2b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlstoredprocedurelistresult.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlStoredProcedureListResult struct { + Value *[]SqlStoredProcedureGetResults `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlstoredprocedureresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlstoredprocedureresource.go new file mode 100644 index 00000000000..182425cfbed --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqlstoredprocedureresource.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlStoredProcedureResource struct { + Body *string `json:"body,omitempty"` + Id string `json:"id"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqltriggercreateupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqltriggercreateupdateparameters.go new file mode 100644 index 00000000000..6ab4b680a2f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqltriggercreateupdateparameters.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlTriggerCreateUpdateParameters struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties SqlTriggerCreateUpdateProperties `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqltriggercreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqltriggercreateupdateproperties.go new file mode 100644 index 00000000000..ca1c76fb557 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqltriggercreateupdateproperties.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlTriggerCreateUpdateProperties struct { + Options *CreateUpdateOptions `json:"options,omitempty"` + Resource SqlTriggerResource `json:"resource"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqltriggergetproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqltriggergetproperties.go new file mode 100644 index 00000000000..72bddb60935 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqltriggergetproperties.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlTriggerGetProperties struct { + Resource *SqlTriggerGetPropertiesResource `json:"resource,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqltriggergetpropertiesresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqltriggergetpropertiesresource.go new file mode 100644 index 00000000000..bb70c215fcc --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqltriggergetpropertiesresource.go @@ -0,0 +1,14 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlTriggerGetPropertiesResource struct { + Body *string `json:"body,omitempty"` + Etag *string `json:"_etag,omitempty"` + Id *string `json:"id,omitempty"` + Rid *string `json:"_rid,omitempty"` + TriggerOperation *TriggerOperation `json:"triggerOperation,omitempty"` + TriggerType *TriggerType `json:"triggerType,omitempty"` + Ts *float64 `json:"_ts,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqltriggergetresults.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqltriggergetresults.go new file mode 100644 index 00000000000..4dc14101cde --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqltriggergetresults.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlTriggerGetResults struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SqlTriggerGetProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqltriggerlistresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqltriggerlistresult.go new file mode 100644 index 00000000000..67110264737 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqltriggerlistresult.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlTriggerListResult struct { + Value *[]SqlTriggerGetResults `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqltriggerresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqltriggerresource.go new file mode 100644 index 00000000000..bfa993fb964 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqltriggerresource.go @@ -0,0 +1,11 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlTriggerResource struct { + Body *string `json:"body,omitempty"` + Id string `json:"id"` + TriggerOperation *TriggerOperation `json:"triggerOperation,omitempty"` + TriggerType *TriggerType `json:"triggerType,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqluserdefinedfunctioncreateupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqluserdefinedfunctioncreateupdateparameters.go new file mode 100644 index 00000000000..77d5e85941d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqluserdefinedfunctioncreateupdateparameters.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlUserDefinedFunctionCreateUpdateParameters struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties SqlUserDefinedFunctionCreateUpdateProperties `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqluserdefinedfunctioncreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqluserdefinedfunctioncreateupdateproperties.go new file mode 100644 index 00000000000..c1948c08d65 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqluserdefinedfunctioncreateupdateproperties.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlUserDefinedFunctionCreateUpdateProperties struct { + Options *CreateUpdateOptions `json:"options,omitempty"` + Resource SqlUserDefinedFunctionResource `json:"resource"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqluserdefinedfunctiongetproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqluserdefinedfunctiongetproperties.go new file mode 100644 index 00000000000..16652a2d953 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqluserdefinedfunctiongetproperties.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlUserDefinedFunctionGetProperties struct { + Resource *SqlUserDefinedFunctionGetPropertiesResource `json:"resource,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqluserdefinedfunctiongetpropertiesresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqluserdefinedfunctiongetpropertiesresource.go new file mode 100644 index 00000000000..61463893687 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqluserdefinedfunctiongetpropertiesresource.go @@ -0,0 +1,12 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlUserDefinedFunctionGetPropertiesResource struct { + Body *string `json:"body,omitempty"` + Etag *string `json:"_etag,omitempty"` + Id *string `json:"id,omitempty"` + Rid *string `json:"_rid,omitempty"` + Ts *float64 `json:"_ts,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqluserdefinedfunctiongetresults.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqluserdefinedfunctiongetresults.go new file mode 100644 index 00000000000..8ac972d5508 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqluserdefinedfunctiongetresults.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlUserDefinedFunctionGetResults struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SqlUserDefinedFunctionGetProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqluserdefinedfunctionlistresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqluserdefinedfunctionlistresult.go new file mode 100644 index 00000000000..561cc720c2d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqluserdefinedfunctionlistresult.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlUserDefinedFunctionListResult struct { + Value *[]SqlUserDefinedFunctionGetResults `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqluserdefinedfunctionresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqluserdefinedfunctionresource.go new file mode 100644 index 00000000000..5cd0ae1bc74 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_sqluserdefinedfunctionresource.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlUserDefinedFunctionResource struct { + Body *string `json:"body,omitempty"` + Id string `json:"id"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_tablecreateupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_tablecreateupdateparameters.go new file mode 100644 index 00000000000..e65573f60ba --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_tablecreateupdateparameters.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TableCreateUpdateParameters struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties TableCreateUpdateProperties `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_tablecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_tablecreateupdateproperties.go new file mode 100644 index 00000000000..00b71f7cefa --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_tablecreateupdateproperties.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TableCreateUpdateProperties struct { + Options *CreateUpdateOptions `json:"options,omitempty"` + Resource TableResource `json:"resource"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_tablegetproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_tablegetproperties.go new file mode 100644 index 00000000000..7241c6c393e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_tablegetproperties.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TableGetProperties struct { + Options *OptionsResource `json:"options,omitempty"` + Resource *TableGetPropertiesResource `json:"resource,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_tablegetpropertiesresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_tablegetpropertiesresource.go new file mode 100644 index 00000000000..1ad52c941ad --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_tablegetpropertiesresource.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TableGetPropertiesResource struct { + CreateMode *CreateMode `json:"createMode,omitempty"` + Etag *string `json:"_etag,omitempty"` + Id *string `json:"id,omitempty"` + RestoreParameters *RestoreParametersBase `json:"restoreParameters,omitempty"` + Rid *string `json:"_rid,omitempty"` + Ts *float64 `json:"_ts,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_tablegetresults.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_tablegetresults.go new file mode 100644 index 00000000000..cd4ad22cc80 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_tablegetresults.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TableGetResults struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *TableGetProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_tablelistresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_tablelistresult.go new file mode 100644 index 00000000000..77b9bc4edea --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_tablelistresult.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TableListResult struct { + Value *[]TableGetResults `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_tableresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_tableresource.go new file mode 100644 index 00000000000..1d4df781e7a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_tableresource.go @@ -0,0 +1,10 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TableResource struct { + CreateMode *CreateMode `json:"createMode,omitempty"` + Id string `json:"id"` + RestoreParameters *RestoreParametersBase `json:"restoreParameters,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_throughputpolicyresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_throughputpolicyresource.go new file mode 100644 index 00000000000..12cae27f871 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_throughputpolicyresource.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ThroughputPolicyResource struct { + IncrementPercent *int64 `json:"incrementPercent,omitempty"` + IsEnabled *bool `json:"isEnabled,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_throughputsettingsgetproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_throughputsettingsgetproperties.go new file mode 100644 index 00000000000..87fb40f36ad --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_throughputsettingsgetproperties.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ThroughputSettingsGetProperties struct { + Resource *ThroughputSettingsGetPropertiesResource `json:"resource,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_throughputsettingsgetpropertiesresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_throughputsettingsgetpropertiesresource.go new file mode 100644 index 00000000000..3806d8bd4bb --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_throughputsettingsgetpropertiesresource.go @@ -0,0 +1,16 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ThroughputSettingsGetPropertiesResource struct { + AutoScaleSettings *AutoscaleSettingsResource `json:"autoscaleSettings,omitempty"` + Etag *string `json:"_etag,omitempty"` + InstantMaximumThroughput *string `json:"instantMaximumThroughput,omitempty"` + MinimumThroughput *string `json:"minimumThroughput,omitempty"` + OfferReplacePending *string `json:"offerReplacePending,omitempty"` + Rid *string `json:"_rid,omitempty"` + SoftAllowedMaximumThroughput *string `json:"softAllowedMaximumThroughput,omitempty"` + Throughput *int64 `json:"throughput,omitempty"` + Ts *float64 `json:"_ts,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_throughputsettingsgetresults.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_throughputsettingsgetresults.go new file mode 100644 index 00000000000..2185d88dc05 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_throughputsettingsgetresults.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ThroughputSettingsGetResults struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ThroughputSettingsGetProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_throughputsettingsresource.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_throughputsettingsresource.go new file mode 100644 index 00000000000..f959c25a927 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_throughputsettingsresource.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ThroughputSettingsResource struct { + AutoScaleSettings *AutoscaleSettingsResource `json:"autoscaleSettings,omitempty"` + InstantMaximumThroughput *string `json:"instantMaximumThroughput,omitempty"` + MinimumThroughput *string `json:"minimumThroughput,omitempty"` + OfferReplacePending *string `json:"offerReplacePending,omitempty"` + SoftAllowedMaximumThroughput *string `json:"softAllowedMaximumThroughput,omitempty"` + Throughput *int64 `json:"throughput,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_throughputsettingsupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_throughputsettingsupdateparameters.go new file mode 100644 index 00000000000..a21087a2944 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_throughputsettingsupdateparameters.go @@ -0,0 +1,13 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ThroughputSettingsUpdateParameters struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ThroughputSettingsUpdateProperties `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_throughputsettingsupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_throughputsettingsupdateproperties.go new file mode 100644 index 00000000000..4dd2779427a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_throughputsettingsupdateproperties.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ThroughputSettingsUpdateProperties struct { + Resource ThroughputSettingsResource `json:"resource"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_uniquekey.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_uniquekey.go new file mode 100644 index 00000000000..5339c8755c4 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_uniquekey.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UniqueKey struct { + Paths *[]string `json:"paths,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_uniquekeypolicy.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_uniquekeypolicy.go new file mode 100644 index 00000000000..3f5cd2d0e93 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_uniquekeypolicy.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UniqueKeyPolicy struct { + UniqueKeys *[]UniqueKey `json:"uniqueKeys,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_usage.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_usage.go new file mode 100644 index 00000000000..dd97540fb2f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_usage.go @@ -0,0 +1,12 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Usage struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *MetricName `json:"name,omitempty"` + QuotaPeriod *string `json:"quotaPeriod,omitempty"` + Unit *UnitType `json:"unit,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_usagesresult.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_usagesresult.go new file mode 100644 index 00000000000..dcb0c10e333 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_usagesresult.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsagesResult struct { + Value *[]Usage `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_vectorembedding.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_vectorembedding.go new file mode 100644 index 00000000000..62d142396d4 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_vectorembedding.go @@ -0,0 +1,11 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VectorEmbedding struct { + DataType VectorDataType `json:"dataType"` + Dimensions int64 `json:"dimensions"` + DistanceFunction DistanceFunction `json:"distanceFunction"` + Path string `json:"path"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_vectorembeddingpolicy.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_vectorembeddingpolicy.go new file mode 100644 index 00000000000..0a12ee86565 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_vectorembeddingpolicy.go @@ -0,0 +1,8 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VectorEmbeddingPolicy struct { + VectorEmbeddings *[]VectorEmbedding `json:"vectorEmbeddings,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_vectorindex.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_vectorindex.go new file mode 100644 index 00000000000..2b90b513b9b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_vectorindex.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VectorIndex struct { + Path string `json:"path"` + Type VectorIndexType `json:"type"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_virtualnetworkrule.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_virtualnetworkrule.go new file mode 100644 index 00000000000..7f767ef737b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/model_virtualnetworkrule.go @@ -0,0 +1,9 @@ +package cosmosdb + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkRule struct { + Id *string `json:"id,omitempty"` + IgnoreMissingVNetServiceEndpoint *bool `json:"ignoreMissingVNetServiceEndpoint,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/cosmosdb/version.go b/resource-manager/cosmosdb/2024-11-15/cosmosdb/version.go new file mode 100644 index 00000000000..c3b07f9ac06 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/cosmosdb/version.go @@ -0,0 +1,10 @@ +package cosmosdb + +// 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-11-15" + +func userAgent() string { + return "hashicorp/go-azure-sdk/cosmosdb/2024-11-15" +} diff --git a/resource-manager/cosmosdb/2024-11-15/datatransfer/README.md b/resource-manager/cosmosdb/2024-11-15/datatransfer/README.md new file mode 100644 index 00000000000..ab5a0fbc3ca --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/README.md @@ -0,0 +1,65 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/datatransfer` Documentation + +The `datatransfer` SDK allows for interaction with Azure Resource Manager `cosmosdb` (API Version `2024-11-15`). + +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/cosmosdb/2024-11-15/datatransfer" +``` + + +### Client Initialization + +```go +client := datatransfer.NewDataTransferClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DataTransferClient.ServiceCreate` + +```go +ctx := context.TODO() +id := datatransfer.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "serviceName") + +payload := datatransfer.ServiceResourceCreateUpdateParameters{ + // ... +} + + +if err := client.ServiceCreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DataTransferClient.ServiceDelete` + +```go +ctx := context.TODO() +id := datatransfer.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "serviceName") + +if err := client.ServiceDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `DataTransferClient.ServiceGet` + +```go +ctx := context.TODO() +id := datatransfer.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "serviceName") + +read, err := client.ServiceGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/cosmosdb/2024-11-15/datatransfer/client.go b/resource-manager/cosmosdb/2024-11-15/datatransfer/client.go new file mode 100644 index 00000000000..890e6ad354e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/client.go @@ -0,0 +1,26 @@ +package datatransfer + +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 DataTransferClient struct { + Client *resourcemanager.Client +} + +func NewDataTransferClientWithBaseURI(sdkApi sdkEnv.Api) (*DataTransferClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "datatransfer", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DataTransferClient: %+v", err) + } + + return &DataTransferClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/datatransfer/constants.go b/resource-manager/cosmosdb/2024-11-15/datatransfer/constants.go new file mode 100644 index 00000000000..b0677ce8b96 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/constants.go @@ -0,0 +1,195 @@ +package datatransfer + +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 DedicatedGatewayType string + +const ( + DedicatedGatewayTypeDistributedQuery DedicatedGatewayType = "DistributedQuery" + DedicatedGatewayTypeIntegratedCache DedicatedGatewayType = "IntegratedCache" +) + +func PossibleValuesForDedicatedGatewayType() []string { + return []string{ + string(DedicatedGatewayTypeDistributedQuery), + string(DedicatedGatewayTypeIntegratedCache), + } +} + +func (s *DedicatedGatewayType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDedicatedGatewayType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDedicatedGatewayType(input string) (*DedicatedGatewayType, error) { + vals := map[string]DedicatedGatewayType{ + "distributedquery": DedicatedGatewayTypeDistributedQuery, + "integratedcache": DedicatedGatewayTypeIntegratedCache, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DedicatedGatewayType(input) + return &out, nil +} + +type ServiceSize string + +const ( + ServiceSizeCosmosPointDEights ServiceSize = "Cosmos.D8s" + ServiceSizeCosmosPointDFours ServiceSize = "Cosmos.D4s" + ServiceSizeCosmosPointDOneSixs ServiceSize = "Cosmos.D16s" +) + +func PossibleValuesForServiceSize() []string { + return []string{ + string(ServiceSizeCosmosPointDEights), + string(ServiceSizeCosmosPointDFours), + string(ServiceSizeCosmosPointDOneSixs), + } +} + +func (s *ServiceSize) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceSize(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceSize(input string) (*ServiceSize, error) { + vals := map[string]ServiceSize{ + "cosmos.d8s": ServiceSizeCosmosPointDEights, + "cosmos.d4s": ServiceSizeCosmosPointDFours, + "cosmos.d16s": ServiceSizeCosmosPointDOneSixs, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceSize(input) + return &out, nil +} + +type ServiceStatus string + +const ( + ServiceStatusCreating ServiceStatus = "Creating" + ServiceStatusDeleting ServiceStatus = "Deleting" + ServiceStatusError ServiceStatus = "Error" + ServiceStatusRunning ServiceStatus = "Running" + ServiceStatusStopped ServiceStatus = "Stopped" + ServiceStatusUpdating ServiceStatus = "Updating" +) + +func PossibleValuesForServiceStatus() []string { + return []string{ + string(ServiceStatusCreating), + string(ServiceStatusDeleting), + string(ServiceStatusError), + string(ServiceStatusRunning), + string(ServiceStatusStopped), + string(ServiceStatusUpdating), + } +} + +func (s *ServiceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceStatus(input string) (*ServiceStatus, error) { + vals := map[string]ServiceStatus{ + "creating": ServiceStatusCreating, + "deleting": ServiceStatusDeleting, + "error": ServiceStatusError, + "running": ServiceStatusRunning, + "stopped": ServiceStatusStopped, + "updating": ServiceStatusUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceStatus(input) + return &out, nil +} + +type ServiceType string + +const ( + ServiceTypeDataTransfer ServiceType = "DataTransfer" + ServiceTypeGraphAPICompute ServiceType = "GraphAPICompute" + ServiceTypeMaterializedViewsBuilder ServiceType = "MaterializedViewsBuilder" + ServiceTypeSqlDedicatedGateway ServiceType = "SqlDedicatedGateway" +) + +func PossibleValuesForServiceType() []string { + return []string{ + string(ServiceTypeDataTransfer), + string(ServiceTypeGraphAPICompute), + string(ServiceTypeMaterializedViewsBuilder), + string(ServiceTypeSqlDedicatedGateway), + } +} + +func (s *ServiceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceType(input string) (*ServiceType, error) { + vals := map[string]ServiceType{ + "datatransfer": ServiceTypeDataTransfer, + "graphapicompute": ServiceTypeGraphAPICompute, + "materializedviewsbuilder": ServiceTypeMaterializedViewsBuilder, + "sqldedicatedgateway": ServiceTypeSqlDedicatedGateway, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceType(input) + return &out, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/datatransfer/id_service.go b/resource-manager/cosmosdb/2024-11-15/datatransfer/id_service.go new file mode 100644 index 00000000000..58fd3f22eb2 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/id_service.go @@ -0,0 +1,139 @@ +package datatransfer + +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(&ServiceId{}) +} + +var _ resourceids.ResourceId = &ServiceId{} + +// ServiceId is a struct representing the Resource ID for a Service +type ServiceId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + ServiceName string +} + +// NewServiceID returns a new ServiceId struct +func NewServiceID(subscriptionId string, resourceGroupName string, databaseAccountName string, serviceName string) ServiceId { + return ServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + ServiceName: serviceName, + } +} + +// ParseServiceID parses 'input' into a ServiceId +func ParseServiceID(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseServiceIDInsensitively parses 'input' case-insensitively into a ServiceId +// note: this method should only be used for API response data and not user input +func ParseServiceIDInsensitively(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ServiceId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.ServiceName, ok = input.Parsed["serviceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serviceName", input) + } + + return nil +} + +// ValidateServiceID checks that 'input' can be parsed as a Service ID +func ValidateServiceID(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 := ParseServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Service ID +func (id ServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/services/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.ServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Service ID +func (id ServiceId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticServices", "services", "services"), + resourceids.UserSpecifiedSegment("serviceName", "serviceName"), + } +} + +// String returns a human-readable description of this Service ID +func (id ServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Service Name: %q", id.ServiceName), + } + return fmt.Sprintf("Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/datatransfer/id_service_test.go b/resource-manager/cosmosdb/2024-11-15/datatransfer/id_service_test.go new file mode 100644 index 00000000000..b3261c00b8b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/id_service_test.go @@ -0,0 +1,327 @@ +package datatransfer + +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 = &ServiceId{} + +func TestNewServiceID(t *testing.T) { + id := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "serviceName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.ServiceName != "serviceName" { + t.Fatalf("Expected %q but got %q for Segment 'ServiceName'", id.ServiceName, "serviceName") + } +} + +func TestFormatServiceID(t *testing.T) { + actual := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "serviceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services/serviceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services/serviceName", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + ServiceName: "serviceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services/serviceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.ServiceName != v.Expected.ServiceName { + t.Fatalf("Expected %q but got %q for ServiceName", v.Expected.ServiceName, actual.ServiceName) + } + + } +} + +func TestParseServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services/serviceName", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + ServiceName: "serviceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services/serviceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sErViCeS/sErViCeNaMe", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + ServiceName: "sErViCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sErViCeS/sErViCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.ServiceName != v.Expected.ServiceName { + t.Fatalf("Expected %q but got %q for ServiceName", v.Expected.ServiceName, actual.ServiceName) + } + + } +} + +func TestSegmentsForServiceId(t *testing.T) { + segments := ServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ServiceId 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/cosmosdb/2024-11-15/datatransfer/method_servicecreate.go b/resource-manager/cosmosdb/2024-11-15/datatransfer/method_servicecreate.go new file mode 100644 index 00000000000..64cfaacd572 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/method_servicecreate.go @@ -0,0 +1,75 @@ +package datatransfer + +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 ServiceCreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ServiceResource +} + +// ServiceCreate ... +func (c DataTransferClient) ServiceCreate(ctx context.Context, id ServiceId, input ServiceResourceCreateUpdateParameters) (result ServiceCreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// ServiceCreateThenPoll performs ServiceCreate then polls until it's completed +func (c DataTransferClient) ServiceCreateThenPoll(ctx context.Context, id ServiceId, input ServiceResourceCreateUpdateParameters) error { + result, err := c.ServiceCreate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ServiceCreate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServiceCreate: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/datatransfer/method_servicedelete.go b/resource-manager/cosmosdb/2024-11-15/datatransfer/method_servicedelete.go new file mode 100644 index 00000000000..fdefa81557c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/method_servicedelete.go @@ -0,0 +1,71 @@ +package datatransfer + +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 ServiceDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ServiceDelete ... +func (c DataTransferClient) ServiceDelete(ctx context.Context, id ServiceId) (result ServiceDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ServiceDeleteThenPoll performs ServiceDelete then polls until it's completed +func (c DataTransferClient) ServiceDeleteThenPoll(ctx context.Context, id ServiceId) error { + result, err := c.ServiceDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing ServiceDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServiceDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/datatransfer/method_serviceget.go b/resource-manager/cosmosdb/2024-11-15/datatransfer/method_serviceget.go new file mode 100644 index 00000000000..1b9f727f156 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/method_serviceget.go @@ -0,0 +1,53 @@ +package datatransfer + +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 ServiceGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ServiceResource +} + +// ServiceGet ... +func (c DataTransferClient) ServiceGet(ctx context.Context, id ServiceId) (result ServiceGetOperationResponse, 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 ServiceResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/datatransfer/model_datatransferserviceresourcecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_datatransferserviceresourcecreateupdateproperties.go new file mode 100644 index 00000000000..2ca1a6279a6 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_datatransferserviceresourcecreateupdateproperties.go @@ -0,0 +1,53 @@ +package datatransfer + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServiceResourceCreateUpdateProperties = DataTransferServiceResourceCreateUpdateProperties{} + +type DataTransferServiceResourceCreateUpdateProperties struct { + + // Fields inherited from ServiceResourceCreateUpdateProperties + + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` +} + +func (s DataTransferServiceResourceCreateUpdateProperties) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return BaseServiceResourceCreateUpdatePropertiesImpl{ + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + } +} + +var _ json.Marshaler = DataTransferServiceResourceCreateUpdateProperties{} + +func (s DataTransferServiceResourceCreateUpdateProperties) MarshalJSON() ([]byte, error) { + type wrapper DataTransferServiceResourceCreateUpdateProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DataTransferServiceResourceCreateUpdateProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DataTransferServiceResourceCreateUpdateProperties: %+v", err) + } + + decoded["serviceType"] = "DataTransfer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DataTransferServiceResourceCreateUpdateProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/datatransfer/model_datatransferserviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_datatransferserviceresourceproperties.go new file mode 100644 index 00000000000..df3ab2d06ac --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_datatransferserviceresourceproperties.go @@ -0,0 +1,73 @@ +package datatransfer + +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 _ ServiceResourceProperties = DataTransferServiceResourceProperties{} + +type DataTransferServiceResourceProperties struct { + Locations *[]RegionalServiceResource `json:"locations,omitempty"` + + // Fields inherited from ServiceResourceProperties + + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s DataTransferServiceResourceProperties) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return BaseServiceResourcePropertiesImpl{ + CreationTime: s.CreationTime, + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + Status: s.Status, + } +} + +func (o *DataTransferServiceResourceProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DataTransferServiceResourceProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +var _ json.Marshaler = DataTransferServiceResourceProperties{} + +func (s DataTransferServiceResourceProperties) MarshalJSON() ([]byte, error) { + type wrapper DataTransferServiceResourceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DataTransferServiceResourceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DataTransferServiceResourceProperties: %+v", err) + } + + decoded["serviceType"] = "DataTransfer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DataTransferServiceResourceProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/datatransfer/model_graphapicomputeregionalserviceresource.go b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_graphapicomputeregionalserviceresource.go new file mode 100644 index 00000000000..b0788106213 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_graphapicomputeregionalserviceresource.go @@ -0,0 +1,11 @@ +package datatransfer + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GraphAPIComputeRegionalServiceResource struct { + GraphApiComputeEndpoint *string `json:"graphApiComputeEndpoint,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Status *ServiceStatus `json:"status,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/datatransfer/model_graphapicomputeserviceresourcecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_graphapicomputeserviceresourcecreateupdateproperties.go new file mode 100644 index 00000000000..8434caa4227 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_graphapicomputeserviceresourcecreateupdateproperties.go @@ -0,0 +1,53 @@ +package datatransfer + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServiceResourceCreateUpdateProperties = GraphAPIComputeServiceResourceCreateUpdateProperties{} + +type GraphAPIComputeServiceResourceCreateUpdateProperties struct { + + // Fields inherited from ServiceResourceCreateUpdateProperties + + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` +} + +func (s GraphAPIComputeServiceResourceCreateUpdateProperties) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return BaseServiceResourceCreateUpdatePropertiesImpl{ + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + } +} + +var _ json.Marshaler = GraphAPIComputeServiceResourceCreateUpdateProperties{} + +func (s GraphAPIComputeServiceResourceCreateUpdateProperties) MarshalJSON() ([]byte, error) { + type wrapper GraphAPIComputeServiceResourceCreateUpdateProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GraphAPIComputeServiceResourceCreateUpdateProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GraphAPIComputeServiceResourceCreateUpdateProperties: %+v", err) + } + + decoded["serviceType"] = "GraphAPICompute" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GraphAPIComputeServiceResourceCreateUpdateProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/datatransfer/model_graphapicomputeserviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_graphapicomputeserviceresourceproperties.go new file mode 100644 index 00000000000..8cac60c8de8 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_graphapicomputeserviceresourceproperties.go @@ -0,0 +1,74 @@ +package datatransfer + +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 _ ServiceResourceProperties = GraphAPIComputeServiceResourceProperties{} + +type GraphAPIComputeServiceResourceProperties struct { + GraphApiComputeEndpoint *string `json:"graphApiComputeEndpoint,omitempty"` + Locations *[]GraphAPIComputeRegionalServiceResource `json:"locations,omitempty"` + + // Fields inherited from ServiceResourceProperties + + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s GraphAPIComputeServiceResourceProperties) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return BaseServiceResourcePropertiesImpl{ + CreationTime: s.CreationTime, + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + Status: s.Status, + } +} + +func (o *GraphAPIComputeServiceResourceProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *GraphAPIComputeServiceResourceProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +var _ json.Marshaler = GraphAPIComputeServiceResourceProperties{} + +func (s GraphAPIComputeServiceResourceProperties) MarshalJSON() ([]byte, error) { + type wrapper GraphAPIComputeServiceResourceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GraphAPIComputeServiceResourceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GraphAPIComputeServiceResourceProperties: %+v", err) + } + + decoded["serviceType"] = "GraphAPICompute" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GraphAPIComputeServiceResourceProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/datatransfer/model_materializedviewsbuilderserviceresourcecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_materializedviewsbuilderserviceresourcecreateupdateproperties.go new file mode 100644 index 00000000000..fbab9b8f4d4 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_materializedviewsbuilderserviceresourcecreateupdateproperties.go @@ -0,0 +1,53 @@ +package datatransfer + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServiceResourceCreateUpdateProperties = MaterializedViewsBuilderServiceResourceCreateUpdateProperties{} + +type MaterializedViewsBuilderServiceResourceCreateUpdateProperties struct { + + // Fields inherited from ServiceResourceCreateUpdateProperties + + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` +} + +func (s MaterializedViewsBuilderServiceResourceCreateUpdateProperties) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return BaseServiceResourceCreateUpdatePropertiesImpl{ + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + } +} + +var _ json.Marshaler = MaterializedViewsBuilderServiceResourceCreateUpdateProperties{} + +func (s MaterializedViewsBuilderServiceResourceCreateUpdateProperties) MarshalJSON() ([]byte, error) { + type wrapper MaterializedViewsBuilderServiceResourceCreateUpdateProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MaterializedViewsBuilderServiceResourceCreateUpdateProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MaterializedViewsBuilderServiceResourceCreateUpdateProperties: %+v", err) + } + + decoded["serviceType"] = "MaterializedViewsBuilder" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MaterializedViewsBuilderServiceResourceCreateUpdateProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/datatransfer/model_materializedviewsbuilderserviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_materializedviewsbuilderserviceresourceproperties.go new file mode 100644 index 00000000000..eadc905e763 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_materializedviewsbuilderserviceresourceproperties.go @@ -0,0 +1,73 @@ +package datatransfer + +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 _ ServiceResourceProperties = MaterializedViewsBuilderServiceResourceProperties{} + +type MaterializedViewsBuilderServiceResourceProperties struct { + Locations *[]RegionalServiceResource `json:"locations,omitempty"` + + // Fields inherited from ServiceResourceProperties + + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s MaterializedViewsBuilderServiceResourceProperties) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return BaseServiceResourcePropertiesImpl{ + CreationTime: s.CreationTime, + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + Status: s.Status, + } +} + +func (o *MaterializedViewsBuilderServiceResourceProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MaterializedViewsBuilderServiceResourceProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +var _ json.Marshaler = MaterializedViewsBuilderServiceResourceProperties{} + +func (s MaterializedViewsBuilderServiceResourceProperties) MarshalJSON() ([]byte, error) { + type wrapper MaterializedViewsBuilderServiceResourceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MaterializedViewsBuilderServiceResourceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MaterializedViewsBuilderServiceResourceProperties: %+v", err) + } + + decoded["serviceType"] = "MaterializedViewsBuilder" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MaterializedViewsBuilderServiceResourceProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/datatransfer/model_regionalserviceresource.go b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_regionalserviceresource.go new file mode 100644 index 00000000000..7eae475d6a4 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_regionalserviceresource.go @@ -0,0 +1,10 @@ +package datatransfer + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegionalServiceResource struct { + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Status *ServiceStatus `json:"status,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/datatransfer/model_serviceresource.go b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_serviceresource.go new file mode 100644 index 00000000000..51ed19cc212 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_serviceresource.go @@ -0,0 +1,48 @@ +package datatransfer + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties ServiceResourceProperties `json:"properties"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ServiceResource{} + +func (s *ServiceResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Id = decoded.Id + s.Name = decoded.Name + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ServiceResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalServiceResourcePropertiesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ServiceResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/datatransfer/model_serviceresourcecreateupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_serviceresourcecreateupdateparameters.go new file mode 100644 index 00000000000..6dd67d683ab --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_serviceresourcecreateupdateparameters.go @@ -0,0 +1,33 @@ +package datatransfer + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceResourceCreateUpdateParameters struct { + Properties ServiceResourceCreateUpdateProperties `json:"properties"` +} + +var _ json.Unmarshaler = &ServiceResourceCreateUpdateParameters{} + +func (s *ServiceResourceCreateUpdateParameters) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ServiceResourceCreateUpdateParameters into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalServiceResourceCreateUpdatePropertiesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ServiceResourceCreateUpdateParameters': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/datatransfer/model_serviceresourcecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_serviceresourcecreateupdateproperties.go new file mode 100644 index 00000000000..621e0f7ad11 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_serviceresourcecreateupdateproperties.go @@ -0,0 +1,101 @@ +package datatransfer + +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 ServiceResourceCreateUpdateProperties interface { + ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl +} + +var _ ServiceResourceCreateUpdateProperties = BaseServiceResourceCreateUpdatePropertiesImpl{} + +type BaseServiceResourceCreateUpdatePropertiesImpl struct { + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` +} + +func (s BaseServiceResourceCreateUpdatePropertiesImpl) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return s +} + +var _ ServiceResourceCreateUpdateProperties = RawServiceResourceCreateUpdatePropertiesImpl{} + +// RawServiceResourceCreateUpdatePropertiesImpl 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 RawServiceResourceCreateUpdatePropertiesImpl struct { + serviceResourceCreateUpdateProperties BaseServiceResourceCreateUpdatePropertiesImpl + Type string + Values map[string]interface{} +} + +func (s RawServiceResourceCreateUpdatePropertiesImpl) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return s.serviceResourceCreateUpdateProperties +} + +func UnmarshalServiceResourceCreateUpdatePropertiesImplementation(input []byte) (ServiceResourceCreateUpdateProperties, 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 ServiceResourceCreateUpdateProperties into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["serviceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "DataTransfer") { + var out DataTransferServiceResourceCreateUpdateProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DataTransferServiceResourceCreateUpdateProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GraphAPICompute") { + var out GraphAPIComputeServiceResourceCreateUpdateProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GraphAPIComputeServiceResourceCreateUpdateProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MaterializedViewsBuilder") { + var out MaterializedViewsBuilderServiceResourceCreateUpdateProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MaterializedViewsBuilderServiceResourceCreateUpdateProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SqlDedicatedGateway") { + var out SqlDedicatedGatewayServiceResourceCreateUpdateProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SqlDedicatedGatewayServiceResourceCreateUpdateProperties: %+v", err) + } + return out, nil + } + + var parent BaseServiceResourceCreateUpdatePropertiesImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseServiceResourceCreateUpdatePropertiesImpl: %+v", err) + } + + return RawServiceResourceCreateUpdatePropertiesImpl{ + serviceResourceCreateUpdateProperties: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/cosmosdb/2024-11-15/datatransfer/model_serviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_serviceresourceproperties.go new file mode 100644 index 00000000000..39506eb52a8 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_serviceresourceproperties.go @@ -0,0 +1,103 @@ +package datatransfer + +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 ServiceResourceProperties interface { + ServiceResourceProperties() BaseServiceResourcePropertiesImpl +} + +var _ ServiceResourceProperties = BaseServiceResourcePropertiesImpl{} + +type BaseServiceResourcePropertiesImpl struct { + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s BaseServiceResourcePropertiesImpl) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return s +} + +var _ ServiceResourceProperties = RawServiceResourcePropertiesImpl{} + +// RawServiceResourcePropertiesImpl 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 RawServiceResourcePropertiesImpl struct { + serviceResourceProperties BaseServiceResourcePropertiesImpl + Type string + Values map[string]interface{} +} + +func (s RawServiceResourcePropertiesImpl) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return s.serviceResourceProperties +} + +func UnmarshalServiceResourcePropertiesImplementation(input []byte) (ServiceResourceProperties, 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 ServiceResourceProperties into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["serviceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "DataTransfer") { + var out DataTransferServiceResourceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DataTransferServiceResourceProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GraphAPICompute") { + var out GraphAPIComputeServiceResourceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GraphAPIComputeServiceResourceProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MaterializedViewsBuilder") { + var out MaterializedViewsBuilderServiceResourceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MaterializedViewsBuilderServiceResourceProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SqlDedicatedGateway") { + var out SqlDedicatedGatewayServiceResourceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SqlDedicatedGatewayServiceResourceProperties: %+v", err) + } + return out, nil + } + + var parent BaseServiceResourcePropertiesImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseServiceResourcePropertiesImpl: %+v", err) + } + + return RawServiceResourcePropertiesImpl{ + serviceResourceProperties: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/cosmosdb/2024-11-15/datatransfer/model_sqldedicatedgatewayregionalserviceresource.go b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_sqldedicatedgatewayregionalserviceresource.go new file mode 100644 index 00000000000..f09e96fdd1c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_sqldedicatedgatewayregionalserviceresource.go @@ -0,0 +1,11 @@ +package datatransfer + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlDedicatedGatewayRegionalServiceResource struct { + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + SqlDedicatedGatewayEndpoint *string `json:"sqlDedicatedGatewayEndpoint,omitempty"` + Status *ServiceStatus `json:"status,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/datatransfer/model_sqldedicatedgatewayserviceresourcecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_sqldedicatedgatewayserviceresourcecreateupdateproperties.go new file mode 100644 index 00000000000..4c2a7576bf1 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_sqldedicatedgatewayserviceresourcecreateupdateproperties.go @@ -0,0 +1,54 @@ +package datatransfer + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServiceResourceCreateUpdateProperties = SqlDedicatedGatewayServiceResourceCreateUpdateProperties{} + +type SqlDedicatedGatewayServiceResourceCreateUpdateProperties struct { + DedicatedGatewayType *DedicatedGatewayType `json:"dedicatedGatewayType,omitempty"` + + // Fields inherited from ServiceResourceCreateUpdateProperties + + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` +} + +func (s SqlDedicatedGatewayServiceResourceCreateUpdateProperties) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return BaseServiceResourceCreateUpdatePropertiesImpl{ + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + } +} + +var _ json.Marshaler = SqlDedicatedGatewayServiceResourceCreateUpdateProperties{} + +func (s SqlDedicatedGatewayServiceResourceCreateUpdateProperties) MarshalJSON() ([]byte, error) { + type wrapper SqlDedicatedGatewayServiceResourceCreateUpdateProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SqlDedicatedGatewayServiceResourceCreateUpdateProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SqlDedicatedGatewayServiceResourceCreateUpdateProperties: %+v", err) + } + + decoded["serviceType"] = "SqlDedicatedGateway" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SqlDedicatedGatewayServiceResourceCreateUpdateProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/datatransfer/model_sqldedicatedgatewayserviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_sqldedicatedgatewayserviceresourceproperties.go new file mode 100644 index 00000000000..83bc369f117 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/model_sqldedicatedgatewayserviceresourceproperties.go @@ -0,0 +1,75 @@ +package datatransfer + +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 _ ServiceResourceProperties = SqlDedicatedGatewayServiceResourceProperties{} + +type SqlDedicatedGatewayServiceResourceProperties struct { + DedicatedGatewayType *DedicatedGatewayType `json:"dedicatedGatewayType,omitempty"` + Locations *[]SqlDedicatedGatewayRegionalServiceResource `json:"locations,omitempty"` + SqlDedicatedGatewayEndpoint *string `json:"sqlDedicatedGatewayEndpoint,omitempty"` + + // Fields inherited from ServiceResourceProperties + + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s SqlDedicatedGatewayServiceResourceProperties) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return BaseServiceResourcePropertiesImpl{ + CreationTime: s.CreationTime, + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + Status: s.Status, + } +} + +func (o *SqlDedicatedGatewayServiceResourceProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SqlDedicatedGatewayServiceResourceProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +var _ json.Marshaler = SqlDedicatedGatewayServiceResourceProperties{} + +func (s SqlDedicatedGatewayServiceResourceProperties) MarshalJSON() ([]byte, error) { + type wrapper SqlDedicatedGatewayServiceResourceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SqlDedicatedGatewayServiceResourceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SqlDedicatedGatewayServiceResourceProperties: %+v", err) + } + + decoded["serviceType"] = "SqlDedicatedGateway" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SqlDedicatedGatewayServiceResourceProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/datatransfer/version.go b/resource-manager/cosmosdb/2024-11-15/datatransfer/version.go new file mode 100644 index 00000000000..c2e0db85a6a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/datatransfer/version.go @@ -0,0 +1,10 @@ +package datatransfer + +// 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-11-15" + +func userAgent() string { + return "hashicorp/go-azure-sdk/datatransfer/2024-11-15" +} diff --git a/resource-manager/cosmosdb/2024-11-15/graphapicompute/README.md b/resource-manager/cosmosdb/2024-11-15/graphapicompute/README.md new file mode 100644 index 00000000000..51ee0317a92 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/README.md @@ -0,0 +1,65 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/graphapicompute` Documentation + +The `graphapicompute` SDK allows for interaction with Azure Resource Manager `cosmosdb` (API Version `2024-11-15`). + +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/cosmosdb/2024-11-15/graphapicompute" +``` + + +### Client Initialization + +```go +client := graphapicompute.NewGraphAPIComputeClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `GraphAPIComputeClient.ServiceCreate` + +```go +ctx := context.TODO() +id := graphapicompute.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "serviceName") + +payload := graphapicompute.ServiceResourceCreateUpdateParameters{ + // ... +} + + +if err := client.ServiceCreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `GraphAPIComputeClient.ServiceDelete` + +```go +ctx := context.TODO() +id := graphapicompute.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "serviceName") + +if err := client.ServiceDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `GraphAPIComputeClient.ServiceGet` + +```go +ctx := context.TODO() +id := graphapicompute.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "serviceName") + +read, err := client.ServiceGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/cosmosdb/2024-11-15/graphapicompute/client.go b/resource-manager/cosmosdb/2024-11-15/graphapicompute/client.go new file mode 100644 index 00000000000..3a7548e0438 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/client.go @@ -0,0 +1,26 @@ +package graphapicompute + +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 GraphAPIComputeClient struct { + Client *resourcemanager.Client +} + +func NewGraphAPIComputeClientWithBaseURI(sdkApi sdkEnv.Api) (*GraphAPIComputeClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "graphapicompute", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GraphAPIComputeClient: %+v", err) + } + + return &GraphAPIComputeClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/graphapicompute/constants.go b/resource-manager/cosmosdb/2024-11-15/graphapicompute/constants.go new file mode 100644 index 00000000000..e5df153931c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/constants.go @@ -0,0 +1,195 @@ +package graphapicompute + +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 DedicatedGatewayType string + +const ( + DedicatedGatewayTypeDistributedQuery DedicatedGatewayType = "DistributedQuery" + DedicatedGatewayTypeIntegratedCache DedicatedGatewayType = "IntegratedCache" +) + +func PossibleValuesForDedicatedGatewayType() []string { + return []string{ + string(DedicatedGatewayTypeDistributedQuery), + string(DedicatedGatewayTypeIntegratedCache), + } +} + +func (s *DedicatedGatewayType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDedicatedGatewayType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDedicatedGatewayType(input string) (*DedicatedGatewayType, error) { + vals := map[string]DedicatedGatewayType{ + "distributedquery": DedicatedGatewayTypeDistributedQuery, + "integratedcache": DedicatedGatewayTypeIntegratedCache, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DedicatedGatewayType(input) + return &out, nil +} + +type ServiceSize string + +const ( + ServiceSizeCosmosPointDEights ServiceSize = "Cosmos.D8s" + ServiceSizeCosmosPointDFours ServiceSize = "Cosmos.D4s" + ServiceSizeCosmosPointDOneSixs ServiceSize = "Cosmos.D16s" +) + +func PossibleValuesForServiceSize() []string { + return []string{ + string(ServiceSizeCosmosPointDEights), + string(ServiceSizeCosmosPointDFours), + string(ServiceSizeCosmosPointDOneSixs), + } +} + +func (s *ServiceSize) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceSize(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceSize(input string) (*ServiceSize, error) { + vals := map[string]ServiceSize{ + "cosmos.d8s": ServiceSizeCosmosPointDEights, + "cosmos.d4s": ServiceSizeCosmosPointDFours, + "cosmos.d16s": ServiceSizeCosmosPointDOneSixs, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceSize(input) + return &out, nil +} + +type ServiceStatus string + +const ( + ServiceStatusCreating ServiceStatus = "Creating" + ServiceStatusDeleting ServiceStatus = "Deleting" + ServiceStatusError ServiceStatus = "Error" + ServiceStatusRunning ServiceStatus = "Running" + ServiceStatusStopped ServiceStatus = "Stopped" + ServiceStatusUpdating ServiceStatus = "Updating" +) + +func PossibleValuesForServiceStatus() []string { + return []string{ + string(ServiceStatusCreating), + string(ServiceStatusDeleting), + string(ServiceStatusError), + string(ServiceStatusRunning), + string(ServiceStatusStopped), + string(ServiceStatusUpdating), + } +} + +func (s *ServiceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceStatus(input string) (*ServiceStatus, error) { + vals := map[string]ServiceStatus{ + "creating": ServiceStatusCreating, + "deleting": ServiceStatusDeleting, + "error": ServiceStatusError, + "running": ServiceStatusRunning, + "stopped": ServiceStatusStopped, + "updating": ServiceStatusUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceStatus(input) + return &out, nil +} + +type ServiceType string + +const ( + ServiceTypeDataTransfer ServiceType = "DataTransfer" + ServiceTypeGraphAPICompute ServiceType = "GraphAPICompute" + ServiceTypeMaterializedViewsBuilder ServiceType = "MaterializedViewsBuilder" + ServiceTypeSqlDedicatedGateway ServiceType = "SqlDedicatedGateway" +) + +func PossibleValuesForServiceType() []string { + return []string{ + string(ServiceTypeDataTransfer), + string(ServiceTypeGraphAPICompute), + string(ServiceTypeMaterializedViewsBuilder), + string(ServiceTypeSqlDedicatedGateway), + } +} + +func (s *ServiceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceType(input string) (*ServiceType, error) { + vals := map[string]ServiceType{ + "datatransfer": ServiceTypeDataTransfer, + "graphapicompute": ServiceTypeGraphAPICompute, + "materializedviewsbuilder": ServiceTypeMaterializedViewsBuilder, + "sqldedicatedgateway": ServiceTypeSqlDedicatedGateway, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceType(input) + return &out, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/graphapicompute/id_service.go b/resource-manager/cosmosdb/2024-11-15/graphapicompute/id_service.go new file mode 100644 index 00000000000..a4987f4b408 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/id_service.go @@ -0,0 +1,139 @@ +package graphapicompute + +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(&ServiceId{}) +} + +var _ resourceids.ResourceId = &ServiceId{} + +// ServiceId is a struct representing the Resource ID for a Service +type ServiceId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + ServiceName string +} + +// NewServiceID returns a new ServiceId struct +func NewServiceID(subscriptionId string, resourceGroupName string, databaseAccountName string, serviceName string) ServiceId { + return ServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + ServiceName: serviceName, + } +} + +// ParseServiceID parses 'input' into a ServiceId +func ParseServiceID(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseServiceIDInsensitively parses 'input' case-insensitively into a ServiceId +// note: this method should only be used for API response data and not user input +func ParseServiceIDInsensitively(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ServiceId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.ServiceName, ok = input.Parsed["serviceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serviceName", input) + } + + return nil +} + +// ValidateServiceID checks that 'input' can be parsed as a Service ID +func ValidateServiceID(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 := ParseServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Service ID +func (id ServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/services/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.ServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Service ID +func (id ServiceId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticServices", "services", "services"), + resourceids.UserSpecifiedSegment("serviceName", "serviceName"), + } +} + +// String returns a human-readable description of this Service ID +func (id ServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Service Name: %q", id.ServiceName), + } + return fmt.Sprintf("Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/graphapicompute/id_service_test.go b/resource-manager/cosmosdb/2024-11-15/graphapicompute/id_service_test.go new file mode 100644 index 00000000000..4be092ed7b2 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/id_service_test.go @@ -0,0 +1,327 @@ +package graphapicompute + +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 = &ServiceId{} + +func TestNewServiceID(t *testing.T) { + id := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "serviceName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.ServiceName != "serviceName" { + t.Fatalf("Expected %q but got %q for Segment 'ServiceName'", id.ServiceName, "serviceName") + } +} + +func TestFormatServiceID(t *testing.T) { + actual := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "serviceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services/serviceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services/serviceName", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + ServiceName: "serviceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services/serviceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.ServiceName != v.Expected.ServiceName { + t.Fatalf("Expected %q but got %q for ServiceName", v.Expected.ServiceName, actual.ServiceName) + } + + } +} + +func TestParseServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services/serviceName", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + ServiceName: "serviceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services/serviceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sErViCeS/sErViCeNaMe", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + ServiceName: "sErViCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sErViCeS/sErViCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.ServiceName != v.Expected.ServiceName { + t.Fatalf("Expected %q but got %q for ServiceName", v.Expected.ServiceName, actual.ServiceName) + } + + } +} + +func TestSegmentsForServiceId(t *testing.T) { + segments := ServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ServiceId 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/cosmosdb/2024-11-15/graphapicompute/method_servicecreate.go b/resource-manager/cosmosdb/2024-11-15/graphapicompute/method_servicecreate.go new file mode 100644 index 00000000000..1c8cb94c71a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/method_servicecreate.go @@ -0,0 +1,75 @@ +package graphapicompute + +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 ServiceCreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ServiceResource +} + +// ServiceCreate ... +func (c GraphAPIComputeClient) ServiceCreate(ctx context.Context, id ServiceId, input ServiceResourceCreateUpdateParameters) (result ServiceCreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// ServiceCreateThenPoll performs ServiceCreate then polls until it's completed +func (c GraphAPIComputeClient) ServiceCreateThenPoll(ctx context.Context, id ServiceId, input ServiceResourceCreateUpdateParameters) error { + result, err := c.ServiceCreate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ServiceCreate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServiceCreate: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/graphapicompute/method_servicedelete.go b/resource-manager/cosmosdb/2024-11-15/graphapicompute/method_servicedelete.go new file mode 100644 index 00000000000..b92c77276ef --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/method_servicedelete.go @@ -0,0 +1,71 @@ +package graphapicompute + +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 ServiceDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ServiceDelete ... +func (c GraphAPIComputeClient) ServiceDelete(ctx context.Context, id ServiceId) (result ServiceDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ServiceDeleteThenPoll performs ServiceDelete then polls until it's completed +func (c GraphAPIComputeClient) ServiceDeleteThenPoll(ctx context.Context, id ServiceId) error { + result, err := c.ServiceDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing ServiceDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServiceDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/graphapicompute/method_serviceget.go b/resource-manager/cosmosdb/2024-11-15/graphapicompute/method_serviceget.go new file mode 100644 index 00000000000..57b27bc513c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/method_serviceget.go @@ -0,0 +1,53 @@ +package graphapicompute + +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 ServiceGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ServiceResource +} + +// ServiceGet ... +func (c GraphAPIComputeClient) ServiceGet(ctx context.Context, id ServiceId) (result ServiceGetOperationResponse, 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 ServiceResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_datatransferserviceresourcecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_datatransferserviceresourcecreateupdateproperties.go new file mode 100644 index 00000000000..9f86d71cea8 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_datatransferserviceresourcecreateupdateproperties.go @@ -0,0 +1,53 @@ +package graphapicompute + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServiceResourceCreateUpdateProperties = DataTransferServiceResourceCreateUpdateProperties{} + +type DataTransferServiceResourceCreateUpdateProperties struct { + + // Fields inherited from ServiceResourceCreateUpdateProperties + + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` +} + +func (s DataTransferServiceResourceCreateUpdateProperties) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return BaseServiceResourceCreateUpdatePropertiesImpl{ + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + } +} + +var _ json.Marshaler = DataTransferServiceResourceCreateUpdateProperties{} + +func (s DataTransferServiceResourceCreateUpdateProperties) MarshalJSON() ([]byte, error) { + type wrapper DataTransferServiceResourceCreateUpdateProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DataTransferServiceResourceCreateUpdateProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DataTransferServiceResourceCreateUpdateProperties: %+v", err) + } + + decoded["serviceType"] = "DataTransfer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DataTransferServiceResourceCreateUpdateProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_datatransferserviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_datatransferserviceresourceproperties.go new file mode 100644 index 00000000000..a0cf9e497ba --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_datatransferserviceresourceproperties.go @@ -0,0 +1,73 @@ +package graphapicompute + +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 _ ServiceResourceProperties = DataTransferServiceResourceProperties{} + +type DataTransferServiceResourceProperties struct { + Locations *[]RegionalServiceResource `json:"locations,omitempty"` + + // Fields inherited from ServiceResourceProperties + + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s DataTransferServiceResourceProperties) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return BaseServiceResourcePropertiesImpl{ + CreationTime: s.CreationTime, + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + Status: s.Status, + } +} + +func (o *DataTransferServiceResourceProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DataTransferServiceResourceProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +var _ json.Marshaler = DataTransferServiceResourceProperties{} + +func (s DataTransferServiceResourceProperties) MarshalJSON() ([]byte, error) { + type wrapper DataTransferServiceResourceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DataTransferServiceResourceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DataTransferServiceResourceProperties: %+v", err) + } + + decoded["serviceType"] = "DataTransfer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DataTransferServiceResourceProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_graphapicomputeregionalserviceresource.go b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_graphapicomputeregionalserviceresource.go new file mode 100644 index 00000000000..4e347cf59f4 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_graphapicomputeregionalserviceresource.go @@ -0,0 +1,11 @@ +package graphapicompute + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GraphAPIComputeRegionalServiceResource struct { + GraphApiComputeEndpoint *string `json:"graphApiComputeEndpoint,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Status *ServiceStatus `json:"status,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_graphapicomputeserviceresourcecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_graphapicomputeserviceresourcecreateupdateproperties.go new file mode 100644 index 00000000000..b2a96f18e2b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_graphapicomputeserviceresourcecreateupdateproperties.go @@ -0,0 +1,53 @@ +package graphapicompute + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServiceResourceCreateUpdateProperties = GraphAPIComputeServiceResourceCreateUpdateProperties{} + +type GraphAPIComputeServiceResourceCreateUpdateProperties struct { + + // Fields inherited from ServiceResourceCreateUpdateProperties + + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` +} + +func (s GraphAPIComputeServiceResourceCreateUpdateProperties) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return BaseServiceResourceCreateUpdatePropertiesImpl{ + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + } +} + +var _ json.Marshaler = GraphAPIComputeServiceResourceCreateUpdateProperties{} + +func (s GraphAPIComputeServiceResourceCreateUpdateProperties) MarshalJSON() ([]byte, error) { + type wrapper GraphAPIComputeServiceResourceCreateUpdateProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GraphAPIComputeServiceResourceCreateUpdateProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GraphAPIComputeServiceResourceCreateUpdateProperties: %+v", err) + } + + decoded["serviceType"] = "GraphAPICompute" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GraphAPIComputeServiceResourceCreateUpdateProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_graphapicomputeserviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_graphapicomputeserviceresourceproperties.go new file mode 100644 index 00000000000..7db063700d2 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_graphapicomputeserviceresourceproperties.go @@ -0,0 +1,74 @@ +package graphapicompute + +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 _ ServiceResourceProperties = GraphAPIComputeServiceResourceProperties{} + +type GraphAPIComputeServiceResourceProperties struct { + GraphApiComputeEndpoint *string `json:"graphApiComputeEndpoint,omitempty"` + Locations *[]GraphAPIComputeRegionalServiceResource `json:"locations,omitempty"` + + // Fields inherited from ServiceResourceProperties + + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s GraphAPIComputeServiceResourceProperties) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return BaseServiceResourcePropertiesImpl{ + CreationTime: s.CreationTime, + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + Status: s.Status, + } +} + +func (o *GraphAPIComputeServiceResourceProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *GraphAPIComputeServiceResourceProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +var _ json.Marshaler = GraphAPIComputeServiceResourceProperties{} + +func (s GraphAPIComputeServiceResourceProperties) MarshalJSON() ([]byte, error) { + type wrapper GraphAPIComputeServiceResourceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GraphAPIComputeServiceResourceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GraphAPIComputeServiceResourceProperties: %+v", err) + } + + decoded["serviceType"] = "GraphAPICompute" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GraphAPIComputeServiceResourceProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_materializedviewsbuilderserviceresourcecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_materializedviewsbuilderserviceresourcecreateupdateproperties.go new file mode 100644 index 00000000000..850555c0254 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_materializedviewsbuilderserviceresourcecreateupdateproperties.go @@ -0,0 +1,53 @@ +package graphapicompute + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServiceResourceCreateUpdateProperties = MaterializedViewsBuilderServiceResourceCreateUpdateProperties{} + +type MaterializedViewsBuilderServiceResourceCreateUpdateProperties struct { + + // Fields inherited from ServiceResourceCreateUpdateProperties + + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` +} + +func (s MaterializedViewsBuilderServiceResourceCreateUpdateProperties) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return BaseServiceResourceCreateUpdatePropertiesImpl{ + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + } +} + +var _ json.Marshaler = MaterializedViewsBuilderServiceResourceCreateUpdateProperties{} + +func (s MaterializedViewsBuilderServiceResourceCreateUpdateProperties) MarshalJSON() ([]byte, error) { + type wrapper MaterializedViewsBuilderServiceResourceCreateUpdateProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MaterializedViewsBuilderServiceResourceCreateUpdateProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MaterializedViewsBuilderServiceResourceCreateUpdateProperties: %+v", err) + } + + decoded["serviceType"] = "MaterializedViewsBuilder" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MaterializedViewsBuilderServiceResourceCreateUpdateProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_materializedviewsbuilderserviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_materializedviewsbuilderserviceresourceproperties.go new file mode 100644 index 00000000000..affb11a6ba9 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_materializedviewsbuilderserviceresourceproperties.go @@ -0,0 +1,73 @@ +package graphapicompute + +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 _ ServiceResourceProperties = MaterializedViewsBuilderServiceResourceProperties{} + +type MaterializedViewsBuilderServiceResourceProperties struct { + Locations *[]RegionalServiceResource `json:"locations,omitempty"` + + // Fields inherited from ServiceResourceProperties + + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s MaterializedViewsBuilderServiceResourceProperties) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return BaseServiceResourcePropertiesImpl{ + CreationTime: s.CreationTime, + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + Status: s.Status, + } +} + +func (o *MaterializedViewsBuilderServiceResourceProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MaterializedViewsBuilderServiceResourceProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +var _ json.Marshaler = MaterializedViewsBuilderServiceResourceProperties{} + +func (s MaterializedViewsBuilderServiceResourceProperties) MarshalJSON() ([]byte, error) { + type wrapper MaterializedViewsBuilderServiceResourceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MaterializedViewsBuilderServiceResourceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MaterializedViewsBuilderServiceResourceProperties: %+v", err) + } + + decoded["serviceType"] = "MaterializedViewsBuilder" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MaterializedViewsBuilderServiceResourceProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_regionalserviceresource.go b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_regionalserviceresource.go new file mode 100644 index 00000000000..c4e5ad88bba --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_regionalserviceresource.go @@ -0,0 +1,10 @@ +package graphapicompute + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegionalServiceResource struct { + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Status *ServiceStatus `json:"status,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_serviceresource.go b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_serviceresource.go new file mode 100644 index 00000000000..363a5d2ec5b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_serviceresource.go @@ -0,0 +1,48 @@ +package graphapicompute + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties ServiceResourceProperties `json:"properties"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ServiceResource{} + +func (s *ServiceResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Id = decoded.Id + s.Name = decoded.Name + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ServiceResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalServiceResourcePropertiesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ServiceResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_serviceresourcecreateupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_serviceresourcecreateupdateparameters.go new file mode 100644 index 00000000000..3acfcc67128 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_serviceresourcecreateupdateparameters.go @@ -0,0 +1,33 @@ +package graphapicompute + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceResourceCreateUpdateParameters struct { + Properties ServiceResourceCreateUpdateProperties `json:"properties"` +} + +var _ json.Unmarshaler = &ServiceResourceCreateUpdateParameters{} + +func (s *ServiceResourceCreateUpdateParameters) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ServiceResourceCreateUpdateParameters into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalServiceResourceCreateUpdatePropertiesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ServiceResourceCreateUpdateParameters': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_serviceresourcecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_serviceresourcecreateupdateproperties.go new file mode 100644 index 00000000000..08b4ac7b558 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_serviceresourcecreateupdateproperties.go @@ -0,0 +1,101 @@ +package graphapicompute + +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 ServiceResourceCreateUpdateProperties interface { + ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl +} + +var _ ServiceResourceCreateUpdateProperties = BaseServiceResourceCreateUpdatePropertiesImpl{} + +type BaseServiceResourceCreateUpdatePropertiesImpl struct { + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` +} + +func (s BaseServiceResourceCreateUpdatePropertiesImpl) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return s +} + +var _ ServiceResourceCreateUpdateProperties = RawServiceResourceCreateUpdatePropertiesImpl{} + +// RawServiceResourceCreateUpdatePropertiesImpl 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 RawServiceResourceCreateUpdatePropertiesImpl struct { + serviceResourceCreateUpdateProperties BaseServiceResourceCreateUpdatePropertiesImpl + Type string + Values map[string]interface{} +} + +func (s RawServiceResourceCreateUpdatePropertiesImpl) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return s.serviceResourceCreateUpdateProperties +} + +func UnmarshalServiceResourceCreateUpdatePropertiesImplementation(input []byte) (ServiceResourceCreateUpdateProperties, 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 ServiceResourceCreateUpdateProperties into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["serviceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "DataTransfer") { + var out DataTransferServiceResourceCreateUpdateProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DataTransferServiceResourceCreateUpdateProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GraphAPICompute") { + var out GraphAPIComputeServiceResourceCreateUpdateProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GraphAPIComputeServiceResourceCreateUpdateProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MaterializedViewsBuilder") { + var out MaterializedViewsBuilderServiceResourceCreateUpdateProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MaterializedViewsBuilderServiceResourceCreateUpdateProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SqlDedicatedGateway") { + var out SqlDedicatedGatewayServiceResourceCreateUpdateProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SqlDedicatedGatewayServiceResourceCreateUpdateProperties: %+v", err) + } + return out, nil + } + + var parent BaseServiceResourceCreateUpdatePropertiesImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseServiceResourceCreateUpdatePropertiesImpl: %+v", err) + } + + return RawServiceResourceCreateUpdatePropertiesImpl{ + serviceResourceCreateUpdateProperties: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_serviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_serviceresourceproperties.go new file mode 100644 index 00000000000..4cfafd0f09e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_serviceresourceproperties.go @@ -0,0 +1,103 @@ +package graphapicompute + +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 ServiceResourceProperties interface { + ServiceResourceProperties() BaseServiceResourcePropertiesImpl +} + +var _ ServiceResourceProperties = BaseServiceResourcePropertiesImpl{} + +type BaseServiceResourcePropertiesImpl struct { + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s BaseServiceResourcePropertiesImpl) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return s +} + +var _ ServiceResourceProperties = RawServiceResourcePropertiesImpl{} + +// RawServiceResourcePropertiesImpl 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 RawServiceResourcePropertiesImpl struct { + serviceResourceProperties BaseServiceResourcePropertiesImpl + Type string + Values map[string]interface{} +} + +func (s RawServiceResourcePropertiesImpl) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return s.serviceResourceProperties +} + +func UnmarshalServiceResourcePropertiesImplementation(input []byte) (ServiceResourceProperties, 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 ServiceResourceProperties into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["serviceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "DataTransfer") { + var out DataTransferServiceResourceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DataTransferServiceResourceProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GraphAPICompute") { + var out GraphAPIComputeServiceResourceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GraphAPIComputeServiceResourceProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MaterializedViewsBuilder") { + var out MaterializedViewsBuilderServiceResourceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MaterializedViewsBuilderServiceResourceProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SqlDedicatedGateway") { + var out SqlDedicatedGatewayServiceResourceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SqlDedicatedGatewayServiceResourceProperties: %+v", err) + } + return out, nil + } + + var parent BaseServiceResourcePropertiesImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseServiceResourcePropertiesImpl: %+v", err) + } + + return RawServiceResourcePropertiesImpl{ + serviceResourceProperties: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_sqldedicatedgatewayregionalserviceresource.go b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_sqldedicatedgatewayregionalserviceresource.go new file mode 100644 index 00000000000..9df5a20b631 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_sqldedicatedgatewayregionalserviceresource.go @@ -0,0 +1,11 @@ +package graphapicompute + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlDedicatedGatewayRegionalServiceResource struct { + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + SqlDedicatedGatewayEndpoint *string `json:"sqlDedicatedGatewayEndpoint,omitempty"` + Status *ServiceStatus `json:"status,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_sqldedicatedgatewayserviceresourcecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_sqldedicatedgatewayserviceresourcecreateupdateproperties.go new file mode 100644 index 00000000000..7c3c86dacb4 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_sqldedicatedgatewayserviceresourcecreateupdateproperties.go @@ -0,0 +1,54 @@ +package graphapicompute + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServiceResourceCreateUpdateProperties = SqlDedicatedGatewayServiceResourceCreateUpdateProperties{} + +type SqlDedicatedGatewayServiceResourceCreateUpdateProperties struct { + DedicatedGatewayType *DedicatedGatewayType `json:"dedicatedGatewayType,omitempty"` + + // Fields inherited from ServiceResourceCreateUpdateProperties + + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` +} + +func (s SqlDedicatedGatewayServiceResourceCreateUpdateProperties) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return BaseServiceResourceCreateUpdatePropertiesImpl{ + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + } +} + +var _ json.Marshaler = SqlDedicatedGatewayServiceResourceCreateUpdateProperties{} + +func (s SqlDedicatedGatewayServiceResourceCreateUpdateProperties) MarshalJSON() ([]byte, error) { + type wrapper SqlDedicatedGatewayServiceResourceCreateUpdateProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SqlDedicatedGatewayServiceResourceCreateUpdateProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SqlDedicatedGatewayServiceResourceCreateUpdateProperties: %+v", err) + } + + decoded["serviceType"] = "SqlDedicatedGateway" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SqlDedicatedGatewayServiceResourceCreateUpdateProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_sqldedicatedgatewayserviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_sqldedicatedgatewayserviceresourceproperties.go new file mode 100644 index 00000000000..d2da743c829 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/model_sqldedicatedgatewayserviceresourceproperties.go @@ -0,0 +1,75 @@ +package graphapicompute + +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 _ ServiceResourceProperties = SqlDedicatedGatewayServiceResourceProperties{} + +type SqlDedicatedGatewayServiceResourceProperties struct { + DedicatedGatewayType *DedicatedGatewayType `json:"dedicatedGatewayType,omitempty"` + Locations *[]SqlDedicatedGatewayRegionalServiceResource `json:"locations,omitempty"` + SqlDedicatedGatewayEndpoint *string `json:"sqlDedicatedGatewayEndpoint,omitempty"` + + // Fields inherited from ServiceResourceProperties + + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s SqlDedicatedGatewayServiceResourceProperties) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return BaseServiceResourcePropertiesImpl{ + CreationTime: s.CreationTime, + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + Status: s.Status, + } +} + +func (o *SqlDedicatedGatewayServiceResourceProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SqlDedicatedGatewayServiceResourceProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +var _ json.Marshaler = SqlDedicatedGatewayServiceResourceProperties{} + +func (s SqlDedicatedGatewayServiceResourceProperties) MarshalJSON() ([]byte, error) { + type wrapper SqlDedicatedGatewayServiceResourceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SqlDedicatedGatewayServiceResourceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SqlDedicatedGatewayServiceResourceProperties: %+v", err) + } + + decoded["serviceType"] = "SqlDedicatedGateway" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SqlDedicatedGatewayServiceResourceProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/graphapicompute/version.go b/resource-manager/cosmosdb/2024-11-15/graphapicompute/version.go new file mode 100644 index 00000000000..1f660424fe4 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/graphapicompute/version.go @@ -0,0 +1,10 @@ +package graphapicompute + +// 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-11-15" + +func userAgent() string { + return "hashicorp/go-azure-sdk/graphapicompute/2024-11-15" +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/README.md b/resource-manager/cosmosdb/2024-11-15/managedcassandras/README.md new file mode 100644 index 00000000000..5078fb72ed2 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/README.md @@ -0,0 +1,250 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/managedcassandras` Documentation + +The `managedcassandras` SDK allows for interaction with Azure Resource Manager `cosmosdb` (API Version `2024-11-15`). + +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/cosmosdb/2024-11-15/managedcassandras" +``` + + +### Client Initialization + +```go +client := managedcassandras.NewManagedCassandrasClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedCassandrasClient.CassandraClustersCreateUpdate` + +```go +ctx := context.TODO() +id := managedcassandras.NewCassandraClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cassandraClusterName") + +payload := managedcassandras.ClusterResource{ + // ... +} + + +if err := client.CassandraClustersCreateUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedCassandrasClient.CassandraClustersDeallocate` + +```go +ctx := context.TODO() +id := managedcassandras.NewCassandraClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cassandraClusterName") + +if err := client.CassandraClustersDeallocateThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedCassandrasClient.CassandraClustersDelete` + +```go +ctx := context.TODO() +id := managedcassandras.NewCassandraClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cassandraClusterName") + +if err := client.CassandraClustersDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedCassandrasClient.CassandraClustersGet` + +```go +ctx := context.TODO() +id := managedcassandras.NewCassandraClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cassandraClusterName") + +read, err := client.CassandraClustersGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedCassandrasClient.CassandraClustersInvokeCommand` + +```go +ctx := context.TODO() +id := managedcassandras.NewCassandraClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cassandraClusterName") + +payload := managedcassandras.CommandPostBody{ + // ... +} + + +if err := client.CassandraClustersInvokeCommandThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedCassandrasClient.CassandraClustersListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +read, err := client.CassandraClustersListByResourceGroup(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedCassandrasClient.CassandraClustersListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.CassandraClustersListBySubscription(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedCassandrasClient.CassandraClustersStart` + +```go +ctx := context.TODO() +id := managedcassandras.NewCassandraClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cassandraClusterName") + +if err := client.CassandraClustersStartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedCassandrasClient.CassandraClustersStatus` + +```go +ctx := context.TODO() +id := managedcassandras.NewCassandraClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cassandraClusterName") + +read, err := client.CassandraClustersStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedCassandrasClient.CassandraClustersUpdate` + +```go +ctx := context.TODO() +id := managedcassandras.NewCassandraClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cassandraClusterName") + +payload := managedcassandras.ClusterResource{ + // ... +} + + +if err := client.CassandraClustersUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedCassandrasClient.CassandraDataCentersCreateUpdate` + +```go +ctx := context.TODO() +id := managedcassandras.NewDataCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cassandraClusterName", "dataCenterName") + +payload := managedcassandras.DataCenterResource{ + // ... +} + + +if err := client.CassandraDataCentersCreateUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedCassandrasClient.CassandraDataCentersDelete` + +```go +ctx := context.TODO() +id := managedcassandras.NewDataCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cassandraClusterName", "dataCenterName") + +if err := client.CassandraDataCentersDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedCassandrasClient.CassandraDataCentersGet` + +```go +ctx := context.TODO() +id := managedcassandras.NewDataCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cassandraClusterName", "dataCenterName") + +read, err := client.CassandraDataCentersGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedCassandrasClient.CassandraDataCentersList` + +```go +ctx := context.TODO() +id := managedcassandras.NewCassandraClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cassandraClusterName") + +read, err := client.CassandraDataCentersList(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedCassandrasClient.CassandraDataCentersUpdate` + +```go +ctx := context.TODO() +id := managedcassandras.NewDataCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cassandraClusterName", "dataCenterName") + +payload := managedcassandras.DataCenterResource{ + // ... +} + + +if err := client.CassandraDataCentersUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/client.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/client.go new file mode 100644 index 00000000000..381eeefaf3c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/client.go @@ -0,0 +1,26 @@ +package managedcassandras + +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 ManagedCassandrasClient struct { + Client *resourcemanager.Client +} + +func NewManagedCassandrasClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedCassandrasClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "managedcassandras", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedCassandrasClient: %+v", err) + } + + return &ManagedCassandrasClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/constants.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/constants.go new file mode 100644 index 00000000000..3c7c3bd13c0 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/constants.go @@ -0,0 +1,251 @@ +package managedcassandras + +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 AuthenticationMethod string + +const ( + AuthenticationMethodCassandra AuthenticationMethod = "Cassandra" + AuthenticationMethodLdap AuthenticationMethod = "Ldap" + AuthenticationMethodNone AuthenticationMethod = "None" +) + +func PossibleValuesForAuthenticationMethod() []string { + return []string{ + string(AuthenticationMethodCassandra), + string(AuthenticationMethodLdap), + string(AuthenticationMethodNone), + } +} + +func (s *AuthenticationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthenticationMethod(input string) (*AuthenticationMethod, error) { + vals := map[string]AuthenticationMethod{ + "cassandra": AuthenticationMethodCassandra, + "ldap": AuthenticationMethodLdap, + "none": AuthenticationMethodNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthenticationMethod(input) + return &out, nil +} + +type AzureConnectionType string + +const ( + AzureConnectionTypeNone AzureConnectionType = "None" + AzureConnectionTypeVPN AzureConnectionType = "VPN" +) + +func PossibleValuesForAzureConnectionType() []string { + return []string{ + string(AzureConnectionTypeNone), + string(AzureConnectionTypeVPN), + } +} + +func (s *AzureConnectionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureConnectionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureConnectionType(input string) (*AzureConnectionType, error) { + vals := map[string]AzureConnectionType{ + "none": AzureConnectionTypeNone, + "vpn": AzureConnectionTypeVPN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureConnectionType(input) + return &out, nil +} + +type ConnectionState string + +const ( + ConnectionStateDatacenterToDatacenterNetworkError ConnectionState = "DatacenterToDatacenterNetworkError" + ConnectionStateInternalError ConnectionState = "InternalError" + ConnectionStateInternalOperatorToDataCenterCertificateError ConnectionState = "InternalOperatorToDataCenterCertificateError" + ConnectionStateOK ConnectionState = "OK" + ConnectionStateOperatorToDataCenterNetworkError ConnectionState = "OperatorToDataCenterNetworkError" + ConnectionStateUnknown ConnectionState = "Unknown" +) + +func PossibleValuesForConnectionState() []string { + return []string{ + string(ConnectionStateDatacenterToDatacenterNetworkError), + string(ConnectionStateInternalError), + string(ConnectionStateInternalOperatorToDataCenterCertificateError), + string(ConnectionStateOK), + string(ConnectionStateOperatorToDataCenterNetworkError), + string(ConnectionStateUnknown), + } +} + +func (s *ConnectionState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectionState(input string) (*ConnectionState, error) { + vals := map[string]ConnectionState{ + "datacentertodatacenternetworkerror": ConnectionStateDatacenterToDatacenterNetworkError, + "internalerror": ConnectionStateInternalError, + "internaloperatortodatacentercertificateerror": ConnectionStateInternalOperatorToDataCenterCertificateError, + "ok": ConnectionStateOK, + "operatortodatacenternetworkerror": ConnectionStateOperatorToDataCenterNetworkError, + "unknown": ConnectionStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectionState(input) + return &out, nil +} + +type ManagedCassandraProvisioningState string + +const ( + ManagedCassandraProvisioningStateCanceled ManagedCassandraProvisioningState = "Canceled" + ManagedCassandraProvisioningStateCreating ManagedCassandraProvisioningState = "Creating" + ManagedCassandraProvisioningStateDeleting ManagedCassandraProvisioningState = "Deleting" + ManagedCassandraProvisioningStateFailed ManagedCassandraProvisioningState = "Failed" + ManagedCassandraProvisioningStateSucceeded ManagedCassandraProvisioningState = "Succeeded" + ManagedCassandraProvisioningStateUpdating ManagedCassandraProvisioningState = "Updating" +) + +func PossibleValuesForManagedCassandraProvisioningState() []string { + return []string{ + string(ManagedCassandraProvisioningStateCanceled), + string(ManagedCassandraProvisioningStateCreating), + string(ManagedCassandraProvisioningStateDeleting), + string(ManagedCassandraProvisioningStateFailed), + string(ManagedCassandraProvisioningStateSucceeded), + string(ManagedCassandraProvisioningStateUpdating), + } +} + +func (s *ManagedCassandraProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedCassandraProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedCassandraProvisioningState(input string) (*ManagedCassandraProvisioningState, error) { + vals := map[string]ManagedCassandraProvisioningState{ + "canceled": ManagedCassandraProvisioningStateCanceled, + "creating": ManagedCassandraProvisioningStateCreating, + "deleting": ManagedCassandraProvisioningStateDeleting, + "failed": ManagedCassandraProvisioningStateFailed, + "succeeded": ManagedCassandraProvisioningStateSucceeded, + "updating": ManagedCassandraProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedCassandraProvisioningState(input) + return &out, nil +} + +type NodeState string + +const ( + NodeStateJoining NodeState = "Joining" + NodeStateLeaving NodeState = "Leaving" + NodeStateMoving NodeState = "Moving" + NodeStateNormal NodeState = "Normal" + NodeStateStopped NodeState = "Stopped" +) + +func PossibleValuesForNodeState() []string { + return []string{ + string(NodeStateJoining), + string(NodeStateLeaving), + string(NodeStateMoving), + string(NodeStateNormal), + string(NodeStateStopped), + } +} + +func (s *NodeState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNodeState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNodeState(input string) (*NodeState, error) { + vals := map[string]NodeState{ + "joining": NodeStateJoining, + "leaving": NodeStateLeaving, + "moving": NodeStateMoving, + "normal": NodeStateNormal, + "stopped": NodeStateStopped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NodeState(input) + return &out, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/id_cassandracluster.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/id_cassandracluster.go new file mode 100644 index 00000000000..b189a0db128 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/id_cassandracluster.go @@ -0,0 +1,130 @@ +package managedcassandras + +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(&CassandraClusterId{}) +} + +var _ resourceids.ResourceId = &CassandraClusterId{} + +// CassandraClusterId is a struct representing the Resource ID for a Cassandra Cluster +type CassandraClusterId struct { + SubscriptionId string + ResourceGroupName string + CassandraClusterName string +} + +// NewCassandraClusterID returns a new CassandraClusterId struct +func NewCassandraClusterID(subscriptionId string, resourceGroupName string, cassandraClusterName string) CassandraClusterId { + return CassandraClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CassandraClusterName: cassandraClusterName, + } +} + +// ParseCassandraClusterID parses 'input' into a CassandraClusterId +func ParseCassandraClusterID(input string) (*CassandraClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CassandraClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CassandraClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCassandraClusterIDInsensitively parses 'input' case-insensitively into a CassandraClusterId +// note: this method should only be used for API response data and not user input +func ParseCassandraClusterIDInsensitively(input string) (*CassandraClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CassandraClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CassandraClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CassandraClusterId) 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.CassandraClusterName, ok = input.Parsed["cassandraClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cassandraClusterName", input) + } + + return nil +} + +// ValidateCassandraClusterID checks that 'input' can be parsed as a Cassandra Cluster ID +func ValidateCassandraClusterID(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 := ParseCassandraClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cassandra Cluster ID +func (id CassandraClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/cassandraClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CassandraClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cassandra Cluster ID +func (id CassandraClusterId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticCassandraClusters", "cassandraClusters", "cassandraClusters"), + resourceids.UserSpecifiedSegment("cassandraClusterName", "cassandraClusterName"), + } +} + +// String returns a human-readable description of this Cassandra Cluster ID +func (id CassandraClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cassandra Cluster Name: %q", id.CassandraClusterName), + } + return fmt.Sprintf("Cassandra Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/id_cassandracluster_test.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/id_cassandracluster_test.go new file mode 100644 index 00000000000..6e99daf02bb --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/id_cassandracluster_test.go @@ -0,0 +1,282 @@ +package managedcassandras + +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 = &CassandraClusterId{} + +func TestNewCassandraClusterID(t *testing.T) { + id := NewCassandraClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cassandraClusterName") + + 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.CassandraClusterName != "cassandraClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'CassandraClusterName'", id.CassandraClusterName, "cassandraClusterName") + } +} + +func TestFormatCassandraClusterID(t *testing.T) { + actual := NewCassandraClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cassandraClusterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/cassandraClusters/cassandraClusterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCassandraClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CassandraClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/cassandraClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/cassandraClusters/cassandraClusterName", + Expected: &CassandraClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CassandraClusterName: "cassandraClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/cassandraClusters/cassandraClusterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCassandraClusterID(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.CassandraClusterName != v.Expected.CassandraClusterName { + t.Fatalf("Expected %q but got %q for CassandraClusterName", v.Expected.CassandraClusterName, actual.CassandraClusterName) + } + + } +} + +func TestParseCassandraClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CassandraClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/cassandraClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/cAsSaNdRaClUsTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/cassandraClusters/cassandraClusterName", + Expected: &CassandraClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CassandraClusterName: "cassandraClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/cassandraClusters/cassandraClusterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/cAsSaNdRaClUsTeRs/cAsSaNdRaClUsTeRnAmE", + Expected: &CassandraClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CassandraClusterName: "cAsSaNdRaClUsTeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/cAsSaNdRaClUsTeRs/cAsSaNdRaClUsTeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCassandraClusterIDInsensitively(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.CassandraClusterName != v.Expected.CassandraClusterName { + t.Fatalf("Expected %q but got %q for CassandraClusterName", v.Expected.CassandraClusterName, actual.CassandraClusterName) + } + + } +} + +func TestSegmentsForCassandraClusterId(t *testing.T) { + segments := CassandraClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CassandraClusterId 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/cosmosdb/2024-11-15/managedcassandras/id_datacenter.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/id_datacenter.go new file mode 100644 index 00000000000..5c5a637c822 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/id_datacenter.go @@ -0,0 +1,139 @@ +package managedcassandras + +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(&DataCenterId{}) +} + +var _ resourceids.ResourceId = &DataCenterId{} + +// DataCenterId is a struct representing the Resource ID for a Data Center +type DataCenterId struct { + SubscriptionId string + ResourceGroupName string + CassandraClusterName string + DataCenterName string +} + +// NewDataCenterID returns a new DataCenterId struct +func NewDataCenterID(subscriptionId string, resourceGroupName string, cassandraClusterName string, dataCenterName string) DataCenterId { + return DataCenterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CassandraClusterName: cassandraClusterName, + DataCenterName: dataCenterName, + } +} + +// ParseDataCenterID parses 'input' into a DataCenterId +func ParseDataCenterID(input string) (*DataCenterId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataCenterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataCenterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDataCenterIDInsensitively parses 'input' case-insensitively into a DataCenterId +// note: this method should only be used for API response data and not user input +func ParseDataCenterIDInsensitively(input string) (*DataCenterId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataCenterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataCenterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DataCenterId) 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.CassandraClusterName, ok = input.Parsed["cassandraClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cassandraClusterName", input) + } + + if id.DataCenterName, ok = input.Parsed["dataCenterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dataCenterName", input) + } + + return nil +} + +// ValidateDataCenterID checks that 'input' can be parsed as a Data Center ID +func ValidateDataCenterID(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 := ParseDataCenterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Data Center ID +func (id DataCenterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/cassandraClusters/%s/dataCenters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CassandraClusterName, id.DataCenterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Data Center ID +func (id DataCenterId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticCassandraClusters", "cassandraClusters", "cassandraClusters"), + resourceids.UserSpecifiedSegment("cassandraClusterName", "cassandraClusterName"), + resourceids.StaticSegment("staticDataCenters", "dataCenters", "dataCenters"), + resourceids.UserSpecifiedSegment("dataCenterName", "dataCenterName"), + } +} + +// String returns a human-readable description of this Data Center ID +func (id DataCenterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cassandra Cluster Name: %q", id.CassandraClusterName), + fmt.Sprintf("Data Center Name: %q", id.DataCenterName), + } + return fmt.Sprintf("Data Center (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/id_datacenter_test.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/id_datacenter_test.go new file mode 100644 index 00000000000..e958093a948 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/id_datacenter_test.go @@ -0,0 +1,327 @@ +package managedcassandras + +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 = &DataCenterId{} + +func TestNewDataCenterID(t *testing.T) { + id := NewDataCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cassandraClusterName", "dataCenterName") + + 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.CassandraClusterName != "cassandraClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'CassandraClusterName'", id.CassandraClusterName, "cassandraClusterName") + } + + if id.DataCenterName != "dataCenterName" { + t.Fatalf("Expected %q but got %q for Segment 'DataCenterName'", id.DataCenterName, "dataCenterName") + } +} + +func TestFormatDataCenterID(t *testing.T) { + actual := NewDataCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cassandraClusterName", "dataCenterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/cassandraClusters/cassandraClusterName/dataCenters/dataCenterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDataCenterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataCenterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/cassandraClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/cassandraClusters/cassandraClusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/cassandraClusters/cassandraClusterName/dataCenters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/cassandraClusters/cassandraClusterName/dataCenters/dataCenterName", + Expected: &DataCenterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CassandraClusterName: "cassandraClusterName", + DataCenterName: "dataCenterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/cassandraClusters/cassandraClusterName/dataCenters/dataCenterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataCenterID(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.CassandraClusterName != v.Expected.CassandraClusterName { + t.Fatalf("Expected %q but got %q for CassandraClusterName", v.Expected.CassandraClusterName, actual.CassandraClusterName) + } + + if actual.DataCenterName != v.Expected.DataCenterName { + t.Fatalf("Expected %q but got %q for DataCenterName", v.Expected.DataCenterName, actual.DataCenterName) + } + + } +} + +func TestParseDataCenterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataCenterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/cassandraClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/cAsSaNdRaClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/cassandraClusters/cassandraClusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/cAsSaNdRaClUsTeRs/cAsSaNdRaClUsTeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/cassandraClusters/cassandraClusterName/dataCenters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/cAsSaNdRaClUsTeRs/cAsSaNdRaClUsTeRnAmE/dAtAcEnTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/cassandraClusters/cassandraClusterName/dataCenters/dataCenterName", + Expected: &DataCenterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CassandraClusterName: "cassandraClusterName", + DataCenterName: "dataCenterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/cassandraClusters/cassandraClusterName/dataCenters/dataCenterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/cAsSaNdRaClUsTeRs/cAsSaNdRaClUsTeRnAmE/dAtAcEnTeRs/dAtAcEnTeRnAmE", + Expected: &DataCenterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CassandraClusterName: "cAsSaNdRaClUsTeRnAmE", + DataCenterName: "dAtAcEnTeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/cAsSaNdRaClUsTeRs/cAsSaNdRaClUsTeRnAmE/dAtAcEnTeRs/dAtAcEnTeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataCenterIDInsensitively(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.CassandraClusterName != v.Expected.CassandraClusterName { + t.Fatalf("Expected %q but got %q for CassandraClusterName", v.Expected.CassandraClusterName, actual.CassandraClusterName) + } + + if actual.DataCenterName != v.Expected.DataCenterName { + t.Fatalf("Expected %q but got %q for DataCenterName", v.Expected.DataCenterName, actual.DataCenterName) + } + + } +} + +func TestSegmentsForDataCenterId(t *testing.T) { + segments := DataCenterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DataCenterId 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/cosmosdb/2024-11-15/managedcassandras/method_cassandraclusterscreateupdate.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclusterscreateupdate.go new file mode 100644 index 00000000000..8d5cc52e113 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclusterscreateupdate.go @@ -0,0 +1,75 @@ +package managedcassandras + +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 CassandraClustersCreateUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ClusterResource +} + +// CassandraClustersCreateUpdate ... +func (c ManagedCassandrasClient) CassandraClustersCreateUpdate(ctx context.Context, id CassandraClusterId, input ClusterResource) (result CassandraClustersCreateUpdateOperationResponse, 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 +} + +// CassandraClustersCreateUpdateThenPoll performs CassandraClustersCreateUpdate then polls until it's completed +func (c ManagedCassandrasClient) CassandraClustersCreateUpdateThenPoll(ctx context.Context, id CassandraClusterId, input ClusterResource) error { + result, err := c.CassandraClustersCreateUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CassandraClustersCreateUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CassandraClustersCreateUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclustersdeallocate.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclustersdeallocate.go new file mode 100644 index 00000000000..1c379fdf5eb --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclustersdeallocate.go @@ -0,0 +1,69 @@ +package managedcassandras + +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 CassandraClustersDeallocateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CassandraClustersDeallocate ... +func (c ManagedCassandrasClient) CassandraClustersDeallocate(ctx context.Context, id CassandraClusterId) (result CassandraClustersDeallocateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deallocate", 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 +} + +// CassandraClustersDeallocateThenPoll performs CassandraClustersDeallocate then polls until it's completed +func (c ManagedCassandrasClient) CassandraClustersDeallocateThenPoll(ctx context.Context, id CassandraClusterId) error { + result, err := c.CassandraClustersDeallocate(ctx, id) + if err != nil { + return fmt.Errorf("performing CassandraClustersDeallocate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CassandraClustersDeallocate: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclustersdelete.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclustersdelete.go new file mode 100644 index 00000000000..f384b072b9d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclustersdelete.go @@ -0,0 +1,70 @@ +package managedcassandras + +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 CassandraClustersDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CassandraClustersDelete ... +func (c ManagedCassandrasClient) CassandraClustersDelete(ctx context.Context, id CassandraClusterId) (result CassandraClustersDeleteOperationResponse, 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 +} + +// CassandraClustersDeleteThenPoll performs CassandraClustersDelete then polls until it's completed +func (c ManagedCassandrasClient) CassandraClustersDeleteThenPoll(ctx context.Context, id CassandraClusterId) error { + result, err := c.CassandraClustersDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing CassandraClustersDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CassandraClustersDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclustersget.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclustersget.go new file mode 100644 index 00000000000..2f175432557 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclustersget.go @@ -0,0 +1,53 @@ +package managedcassandras + +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 CassandraClustersGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ClusterResource +} + +// CassandraClustersGet ... +func (c ManagedCassandrasClient) CassandraClustersGet(ctx context.Context, id CassandraClusterId) (result CassandraClustersGetOperationResponse, 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 ClusterResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclustersinvokecommand.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclustersinvokecommand.go new file mode 100644 index 00000000000..1ac428cc9d9 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclustersinvokecommand.go @@ -0,0 +1,74 @@ +package managedcassandras + +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 CassandraClustersInvokeCommandOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CommandOutput +} + +// CassandraClustersInvokeCommand ... +func (c ManagedCassandrasClient) CassandraClustersInvokeCommand(ctx context.Context, id CassandraClusterId, input CommandPostBody) (result CassandraClustersInvokeCommandOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/invokeCommand", 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 +} + +// CassandraClustersInvokeCommandThenPoll performs CassandraClustersInvokeCommand then polls until it's completed +func (c ManagedCassandrasClient) CassandraClustersInvokeCommandThenPoll(ctx context.Context, id CassandraClusterId, input CommandPostBody) error { + result, err := c.CassandraClustersInvokeCommand(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CassandraClustersInvokeCommand: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CassandraClustersInvokeCommand: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclusterslistbyresourcegroup.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclusterslistbyresourcegroup.go new file mode 100644 index 00000000000..118bde5196f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclusterslistbyresourcegroup.go @@ -0,0 +1,55 @@ +package managedcassandras + +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 CassandraClustersListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ListClusters +} + +// CassandraClustersListByResourceGroup ... +func (c ManagedCassandrasClient) CassandraClustersListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result CassandraClustersListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DocumentDB/cassandraClusters", 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 ListClusters + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclusterslistbysubscription.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclusterslistbysubscription.go new file mode 100644 index 00000000000..07ee7cad4fe --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclusterslistbysubscription.go @@ -0,0 +1,55 @@ +package managedcassandras + +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 CassandraClustersListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ListClusters +} + +// CassandraClustersListBySubscription ... +func (c ManagedCassandrasClient) CassandraClustersListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result CassandraClustersListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DocumentDB/cassandraClusters", 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 ListClusters + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclustersstart.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclustersstart.go new file mode 100644 index 00000000000..5c6ef23b014 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclustersstart.go @@ -0,0 +1,69 @@ +package managedcassandras + +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 CassandraClustersStartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CassandraClustersStart ... +func (c ManagedCassandrasClient) CassandraClustersStart(ctx context.Context, id CassandraClusterId) (result CassandraClustersStartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CassandraClustersStartThenPoll performs CassandraClustersStart then polls until it's completed +func (c ManagedCassandrasClient) CassandraClustersStartThenPoll(ctx context.Context, id CassandraClusterId) error { + result, err := c.CassandraClustersStart(ctx, id) + if err != nil { + return fmt.Errorf("performing CassandraClustersStart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CassandraClustersStart: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclustersstatus.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclustersstatus.go new file mode 100644 index 00000000000..e893f931bed --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclustersstatus.go @@ -0,0 +1,54 @@ +package managedcassandras + +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 CassandraClustersStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CassandraClusterPublicStatus +} + +// CassandraClustersStatus ... +func (c ManagedCassandrasClient) CassandraClustersStatus(ctx context.Context, id CassandraClusterId) (result CassandraClustersStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/status", 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 CassandraClusterPublicStatus + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclustersupdate.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclustersupdate.go new file mode 100644 index 00000000000..531b153cb16 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandraclustersupdate.go @@ -0,0 +1,75 @@ +package managedcassandras + +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 CassandraClustersUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ClusterResource +} + +// CassandraClustersUpdate ... +func (c ManagedCassandrasClient) CassandraClustersUpdate(ctx context.Context, id CassandraClusterId, input ClusterResource) (result CassandraClustersUpdateOperationResponse, 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 +} + +// CassandraClustersUpdateThenPoll performs CassandraClustersUpdate then polls until it's completed +func (c ManagedCassandrasClient) CassandraClustersUpdateThenPoll(ctx context.Context, id CassandraClusterId, input ClusterResource) error { + result, err := c.CassandraClustersUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CassandraClustersUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CassandraClustersUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandradatacenterscreateupdate.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandradatacenterscreateupdate.go new file mode 100644 index 00000000000..27f74d9206d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandradatacenterscreateupdate.go @@ -0,0 +1,75 @@ +package managedcassandras + +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 CassandraDataCentersCreateUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DataCenterResource +} + +// CassandraDataCentersCreateUpdate ... +func (c ManagedCassandrasClient) CassandraDataCentersCreateUpdate(ctx context.Context, id DataCenterId, input DataCenterResource) (result CassandraDataCentersCreateUpdateOperationResponse, 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 +} + +// CassandraDataCentersCreateUpdateThenPoll performs CassandraDataCentersCreateUpdate then polls until it's completed +func (c ManagedCassandrasClient) CassandraDataCentersCreateUpdateThenPoll(ctx context.Context, id DataCenterId, input DataCenterResource) error { + result, err := c.CassandraDataCentersCreateUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CassandraDataCentersCreateUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CassandraDataCentersCreateUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandradatacentersdelete.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandradatacentersdelete.go new file mode 100644 index 00000000000..10984b43db3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandradatacentersdelete.go @@ -0,0 +1,70 @@ +package managedcassandras + +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 CassandraDataCentersDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CassandraDataCentersDelete ... +func (c ManagedCassandrasClient) CassandraDataCentersDelete(ctx context.Context, id DataCenterId) (result CassandraDataCentersDeleteOperationResponse, 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 +} + +// CassandraDataCentersDeleteThenPoll performs CassandraDataCentersDelete then polls until it's completed +func (c ManagedCassandrasClient) CassandraDataCentersDeleteThenPoll(ctx context.Context, id DataCenterId) error { + result, err := c.CassandraDataCentersDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing CassandraDataCentersDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CassandraDataCentersDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandradatacentersget.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandradatacentersget.go new file mode 100644 index 00000000000..1da18b7e763 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandradatacentersget.go @@ -0,0 +1,53 @@ +package managedcassandras + +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 CassandraDataCentersGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DataCenterResource +} + +// CassandraDataCentersGet ... +func (c ManagedCassandrasClient) CassandraDataCentersGet(ctx context.Context, id DataCenterId) (result CassandraDataCentersGetOperationResponse, 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 DataCenterResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandradatacenterslist.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandradatacenterslist.go new file mode 100644 index 00000000000..00794e30f1f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandradatacenterslist.go @@ -0,0 +1,54 @@ +package managedcassandras + +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 CassandraDataCentersListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ListDataCenters +} + +// CassandraDataCentersList ... +func (c ManagedCassandrasClient) CassandraDataCentersList(ctx context.Context, id CassandraClusterId) (result CassandraDataCentersListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/dataCenters", 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 ListDataCenters + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandradatacentersupdate.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandradatacentersupdate.go new file mode 100644 index 00000000000..284eee0ef1c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/method_cassandradatacentersupdate.go @@ -0,0 +1,75 @@ +package managedcassandras + +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 CassandraDataCentersUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DataCenterResource +} + +// CassandraDataCentersUpdate ... +func (c ManagedCassandrasClient) CassandraDataCentersUpdate(ctx context.Context, id DataCenterId, input DataCenterResource) (result CassandraDataCentersUpdateOperationResponse, 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 +} + +// CassandraDataCentersUpdateThenPoll performs CassandraDataCentersUpdate then polls until it's completed +func (c ManagedCassandrasClient) CassandraDataCentersUpdateThenPoll(ctx context.Context, id DataCenterId, input DataCenterResource) error { + result, err := c.CassandraDataCentersUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CassandraDataCentersUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CassandraDataCentersUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_authenticationmethodldapproperties.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_authenticationmethodldapproperties.go new file mode 100644 index 00000000000..c7a9f432d0f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_authenticationmethodldapproperties.go @@ -0,0 +1,15 @@ +package managedcassandras + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthenticationMethodLdapProperties struct { + ConnectionTimeoutInMs *int64 `json:"connectionTimeoutInMs,omitempty"` + SearchBaseDistinguishedName *string `json:"searchBaseDistinguishedName,omitempty"` + SearchFilterTemplate *string `json:"searchFilterTemplate,omitempty"` + ServerCertificates *[]Certificate `json:"serverCertificates,omitempty"` + ServerHostname *string `json:"serverHostname,omitempty"` + ServerPort *int64 `json:"serverPort,omitempty"` + ServiceUserDistinguishedName *string `json:"serviceUserDistinguishedName,omitempty"` + ServiceUserPassword *string `json:"serviceUserPassword,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_cassandraclusterpublicstatus.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_cassandraclusterpublicstatus.go new file mode 100644 index 00000000000..84f74679736 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_cassandraclusterpublicstatus.go @@ -0,0 +1,12 @@ +package managedcassandras + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CassandraClusterPublicStatus struct { + ConnectionErrors *[]ConnectionError `json:"connectionErrors,omitempty"` + DataCenters *[]CassandraClusterPublicStatusDataCentersInlined `json:"dataCenters,omitempty"` + ETag *string `json:"eTag,omitempty"` + Errors *[]CassandraError `json:"errors,omitempty"` + ReaperStatus *ManagedCassandraReaperStatus `json:"reaperStatus,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_cassandraclusterpublicstatusdatacentersinlined.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_cassandraclusterpublicstatusdatacentersinlined.go new file mode 100644 index 00000000000..553b6259db1 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_cassandraclusterpublicstatusdatacentersinlined.go @@ -0,0 +1,10 @@ +package managedcassandras + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CassandraClusterPublicStatusDataCentersInlined struct { + Name *string `json:"name,omitempty"` + Nodes *[]CassandraClusterPublicStatusDataCentersInlinedNodesInlined `json:"nodes,omitempty"` + SeedNodes *[]string `json:"seedNodes,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_cassandraclusterpublicstatusdatacentersinlinednodesinlined.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_cassandraclusterpublicstatusdatacentersinlinednodesinlined.go new file mode 100644 index 00000000000..56fe106a00c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_cassandraclusterpublicstatusdatacentersinlinednodesinlined.go @@ -0,0 +1,24 @@ +package managedcassandras + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CassandraClusterPublicStatusDataCentersInlinedNodesInlined struct { + Address *string `json:"address,omitempty"` + CassandraProcessStatus *string `json:"cassandraProcessStatus,omitempty"` + CpuUsage *float64 `json:"cpuUsage,omitempty"` + DiskFreeKB *int64 `json:"diskFreeKB,omitempty"` + DiskUsedKB *int64 `json:"diskUsedKB,omitempty"` + HostID *string `json:"hostID,omitempty"` + Load *string `json:"load,omitempty"` + MemoryBuffersAndCachedKB *int64 `json:"memoryBuffersAndCachedKB,omitempty"` + MemoryFreeKB *int64 `json:"memoryFreeKB,omitempty"` + MemoryTotalKB *int64 `json:"memoryTotalKB,omitempty"` + MemoryUsedKB *int64 `json:"memoryUsedKB,omitempty"` + Rack *string `json:"rack,omitempty"` + Size *int64 `json:"size,omitempty"` + State *NodeState `json:"state,omitempty"` + Status *string `json:"status,omitempty"` + Timestamp *string `json:"timestamp,omitempty"` + Tokens *[]string `json:"tokens,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_cassandraerror.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_cassandraerror.go new file mode 100644 index 00000000000..5fb8d8d739d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_cassandraerror.go @@ -0,0 +1,11 @@ +package managedcassandras + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CassandraError struct { + AdditionalErrorInfo *string `json:"additionalErrorInfo,omitempty"` + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_certificate.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_certificate.go new file mode 100644 index 00000000000..66f3a92b668 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_certificate.go @@ -0,0 +1,8 @@ +package managedcassandras + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Certificate struct { + Pem *string `json:"pem,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_clusterresource.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_clusterresource.go new file mode 100644 index 00000000000..50fe6a97995 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_clusterresource.go @@ -0,0 +1,18 @@ +package managedcassandras + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterResource struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAssigned `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ClusterResourceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_clusterresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_clusterresourceproperties.go new file mode 100644 index 00000000000..e8a1fad7a8b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_clusterresourceproperties.go @@ -0,0 +1,27 @@ +package managedcassandras + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterResourceProperties struct { + AuthenticationMethod *AuthenticationMethod `json:"authenticationMethod,omitempty"` + AzureConnectionMethod *AzureConnectionType `json:"azureConnectionMethod,omitempty"` + CassandraAuditLoggingEnabled *bool `json:"cassandraAuditLoggingEnabled,omitempty"` + CassandraVersion *string `json:"cassandraVersion,omitempty"` + ClientCertificates *[]Certificate `json:"clientCertificates,omitempty"` + ClusterNameOverride *string `json:"clusterNameOverride,omitempty"` + Deallocated *bool `json:"deallocated,omitempty"` + DelegatedManagementSubnetId *string `json:"delegatedManagementSubnetId,omitempty"` + ExternalGossipCertificates *[]Certificate `json:"externalGossipCertificates,omitempty"` + ExternalSeedNodes *[]SeedNode `json:"externalSeedNodes,omitempty"` + GossipCertificates *[]Certificate `json:"gossipCertificates,omitempty"` + HoursBetweenBackups *int64 `json:"hoursBetweenBackups,omitempty"` + InitialCassandraAdminPassword *string `json:"initialCassandraAdminPassword,omitempty"` + PrivateLinkResourceId *string `json:"privateLinkResourceId,omitempty"` + PrometheusEndpoint *SeedNode `json:"prometheusEndpoint,omitempty"` + ProvisionError *CassandraError `json:"provisionError,omitempty"` + ProvisioningState *ManagedCassandraProvisioningState `json:"provisioningState,omitempty"` + RepairEnabled *bool `json:"repairEnabled,omitempty"` + RestoreFromBackupId *string `json:"restoreFromBackupId,omitempty"` + SeedNodes *[]SeedNode `json:"seedNodes,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_commandoutput.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_commandoutput.go new file mode 100644 index 00000000000..aadc96cec32 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_commandoutput.go @@ -0,0 +1,8 @@ +package managedcassandras + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CommandOutput struct { + CommandOutput *string `json:"commandOutput,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_commandpostbody.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_commandpostbody.go new file mode 100644 index 00000000000..878f7cf0742 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_commandpostbody.go @@ -0,0 +1,12 @@ +package managedcassandras + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CommandPostBody struct { + Arguments *map[string]string `json:"arguments,omitempty"` + CassandraStopStart *bool `json:"cassandra-stop-start,omitempty"` + Command string `json:"command"` + Host string `json:"host"` + Readwrite *bool `json:"readwrite,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_connectionerror.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_connectionerror.go new file mode 100644 index 00000000000..affa653c1ce --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_connectionerror.go @@ -0,0 +1,12 @@ +package managedcassandras + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionError struct { + ConnectionState *ConnectionState `json:"connectionState,omitempty"` + Exception *string `json:"exception,omitempty"` + IPFrom *string `json:"iPFrom,omitempty"` + IPTo *string `json:"iPTo,omitempty"` + Port *int64 `json:"port,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_datacenterresource.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_datacenterresource.go new file mode 100644 index 00000000000..517859ce7f3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_datacenterresource.go @@ -0,0 +1,11 @@ +package managedcassandras + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataCenterResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DataCenterResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_datacenterresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_datacenterresourceproperties.go new file mode 100644 index 00000000000..57d14a88db5 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_datacenterresourceproperties.go @@ -0,0 +1,23 @@ +package managedcassandras + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataCenterResourceProperties struct { + AuthenticationMethodLdapProperties *AuthenticationMethodLdapProperties `json:"authenticationMethodLdapProperties,omitempty"` + AvailabilityZone *bool `json:"availabilityZone,omitempty"` + BackupStorageCustomerKeyUri *string `json:"backupStorageCustomerKeyUri,omitempty"` + Base64EncodedCassandraYamlFragment *string `json:"base64EncodedCassandraYamlFragment,omitempty"` + DataCenterLocation *string `json:"dataCenterLocation,omitempty"` + Deallocated *bool `json:"deallocated,omitempty"` + DelegatedSubnetId *string `json:"delegatedSubnetId,omitempty"` + DiskCapacity *int64 `json:"diskCapacity,omitempty"` + DiskSku *string `json:"diskSku,omitempty"` + ManagedDiskCustomerKeyUri *string `json:"managedDiskCustomerKeyUri,omitempty"` + NodeCount *int64 `json:"nodeCount,omitempty"` + PrivateEndpointIPAddress *string `json:"privateEndpointIpAddress,omitempty"` + ProvisionError *CassandraError `json:"provisionError,omitempty"` + ProvisioningState *ManagedCassandraProvisioningState `json:"provisioningState,omitempty"` + SeedNodes *[]SeedNode `json:"seedNodes,omitempty"` + Sku *string `json:"sku,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_listclusters.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_listclusters.go new file mode 100644 index 00000000000..5da5485e489 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_listclusters.go @@ -0,0 +1,8 @@ +package managedcassandras + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListClusters struct { + Value *[]ClusterResource `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_listdatacenters.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_listdatacenters.go new file mode 100644 index 00000000000..9f253b81b85 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_listdatacenters.go @@ -0,0 +1,8 @@ +package managedcassandras + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListDataCenters struct { + Value *[]DataCenterResource `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_managedcassandrareaperstatus.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_managedcassandrareaperstatus.go new file mode 100644 index 00000000000..7802e9d2ef5 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_managedcassandrareaperstatus.go @@ -0,0 +1,10 @@ +package managedcassandras + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedCassandraReaperStatus struct { + Healthy *bool `json:"healthy,omitempty"` + RepairRunIds *map[string]string `json:"repairRunIds,omitempty"` + RepairSchedules *map[string]string `json:"repairSchedules,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_seednode.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_seednode.go new file mode 100644 index 00000000000..4381037df45 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/model_seednode.go @@ -0,0 +1,8 @@ +package managedcassandras + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SeedNode struct { + IPAddress *string `json:"ipAddress,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/managedcassandras/version.go b/resource-manager/cosmosdb/2024-11-15/managedcassandras/version.go new file mode 100644 index 00000000000..3a86dc1a329 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/managedcassandras/version.go @@ -0,0 +1,10 @@ +package managedcassandras + +// 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-11-15" + +func userAgent() string { + return "hashicorp/go-azure-sdk/managedcassandras/2024-11-15" +} diff --git a/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/README.md b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/README.md new file mode 100644 index 00000000000..5474a455d4f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/README.md @@ -0,0 +1,65 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder` Documentation + +The `materializedviewsbuilder` SDK allows for interaction with Azure Resource Manager `cosmosdb` (API Version `2024-11-15`). + +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/cosmosdb/2024-11-15/materializedviewsbuilder" +``` + + +### Client Initialization + +```go +client := materializedviewsbuilder.NewMaterializedViewsBuilderClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `MaterializedViewsBuilderClient.ServiceCreate` + +```go +ctx := context.TODO() +id := materializedviewsbuilder.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "serviceName") + +payload := materializedviewsbuilder.ServiceResourceCreateUpdateParameters{ + // ... +} + + +if err := client.ServiceCreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `MaterializedViewsBuilderClient.ServiceDelete` + +```go +ctx := context.TODO() +id := materializedviewsbuilder.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "serviceName") + +if err := client.ServiceDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `MaterializedViewsBuilderClient.ServiceGet` + +```go +ctx := context.TODO() +id := materializedviewsbuilder.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "serviceName") + +read, err := client.ServiceGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/client.go b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/client.go new file mode 100644 index 00000000000..0a72e3e9ade --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/client.go @@ -0,0 +1,26 @@ +package materializedviewsbuilder + +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 MaterializedViewsBuilderClient struct { + Client *resourcemanager.Client +} + +func NewMaterializedViewsBuilderClientWithBaseURI(sdkApi sdkEnv.Api) (*MaterializedViewsBuilderClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "materializedviewsbuilder", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating MaterializedViewsBuilderClient: %+v", err) + } + + return &MaterializedViewsBuilderClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/constants.go b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/constants.go new file mode 100644 index 00000000000..1c2b4f7adc1 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/constants.go @@ -0,0 +1,195 @@ +package materializedviewsbuilder + +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 DedicatedGatewayType string + +const ( + DedicatedGatewayTypeDistributedQuery DedicatedGatewayType = "DistributedQuery" + DedicatedGatewayTypeIntegratedCache DedicatedGatewayType = "IntegratedCache" +) + +func PossibleValuesForDedicatedGatewayType() []string { + return []string{ + string(DedicatedGatewayTypeDistributedQuery), + string(DedicatedGatewayTypeIntegratedCache), + } +} + +func (s *DedicatedGatewayType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDedicatedGatewayType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDedicatedGatewayType(input string) (*DedicatedGatewayType, error) { + vals := map[string]DedicatedGatewayType{ + "distributedquery": DedicatedGatewayTypeDistributedQuery, + "integratedcache": DedicatedGatewayTypeIntegratedCache, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DedicatedGatewayType(input) + return &out, nil +} + +type ServiceSize string + +const ( + ServiceSizeCosmosPointDEights ServiceSize = "Cosmos.D8s" + ServiceSizeCosmosPointDFours ServiceSize = "Cosmos.D4s" + ServiceSizeCosmosPointDOneSixs ServiceSize = "Cosmos.D16s" +) + +func PossibleValuesForServiceSize() []string { + return []string{ + string(ServiceSizeCosmosPointDEights), + string(ServiceSizeCosmosPointDFours), + string(ServiceSizeCosmosPointDOneSixs), + } +} + +func (s *ServiceSize) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceSize(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceSize(input string) (*ServiceSize, error) { + vals := map[string]ServiceSize{ + "cosmos.d8s": ServiceSizeCosmosPointDEights, + "cosmos.d4s": ServiceSizeCosmosPointDFours, + "cosmos.d16s": ServiceSizeCosmosPointDOneSixs, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceSize(input) + return &out, nil +} + +type ServiceStatus string + +const ( + ServiceStatusCreating ServiceStatus = "Creating" + ServiceStatusDeleting ServiceStatus = "Deleting" + ServiceStatusError ServiceStatus = "Error" + ServiceStatusRunning ServiceStatus = "Running" + ServiceStatusStopped ServiceStatus = "Stopped" + ServiceStatusUpdating ServiceStatus = "Updating" +) + +func PossibleValuesForServiceStatus() []string { + return []string{ + string(ServiceStatusCreating), + string(ServiceStatusDeleting), + string(ServiceStatusError), + string(ServiceStatusRunning), + string(ServiceStatusStopped), + string(ServiceStatusUpdating), + } +} + +func (s *ServiceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceStatus(input string) (*ServiceStatus, error) { + vals := map[string]ServiceStatus{ + "creating": ServiceStatusCreating, + "deleting": ServiceStatusDeleting, + "error": ServiceStatusError, + "running": ServiceStatusRunning, + "stopped": ServiceStatusStopped, + "updating": ServiceStatusUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceStatus(input) + return &out, nil +} + +type ServiceType string + +const ( + ServiceTypeDataTransfer ServiceType = "DataTransfer" + ServiceTypeGraphAPICompute ServiceType = "GraphAPICompute" + ServiceTypeMaterializedViewsBuilder ServiceType = "MaterializedViewsBuilder" + ServiceTypeSqlDedicatedGateway ServiceType = "SqlDedicatedGateway" +) + +func PossibleValuesForServiceType() []string { + return []string{ + string(ServiceTypeDataTransfer), + string(ServiceTypeGraphAPICompute), + string(ServiceTypeMaterializedViewsBuilder), + string(ServiceTypeSqlDedicatedGateway), + } +} + +func (s *ServiceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceType(input string) (*ServiceType, error) { + vals := map[string]ServiceType{ + "datatransfer": ServiceTypeDataTransfer, + "graphapicompute": ServiceTypeGraphAPICompute, + "materializedviewsbuilder": ServiceTypeMaterializedViewsBuilder, + "sqldedicatedgateway": ServiceTypeSqlDedicatedGateway, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceType(input) + return &out, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/id_service.go b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/id_service.go new file mode 100644 index 00000000000..2eb7e5e0d31 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/id_service.go @@ -0,0 +1,139 @@ +package materializedviewsbuilder + +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(&ServiceId{}) +} + +var _ resourceids.ResourceId = &ServiceId{} + +// ServiceId is a struct representing the Resource ID for a Service +type ServiceId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + ServiceName string +} + +// NewServiceID returns a new ServiceId struct +func NewServiceID(subscriptionId string, resourceGroupName string, databaseAccountName string, serviceName string) ServiceId { + return ServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + ServiceName: serviceName, + } +} + +// ParseServiceID parses 'input' into a ServiceId +func ParseServiceID(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseServiceIDInsensitively parses 'input' case-insensitively into a ServiceId +// note: this method should only be used for API response data and not user input +func ParseServiceIDInsensitively(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ServiceId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.ServiceName, ok = input.Parsed["serviceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serviceName", input) + } + + return nil +} + +// ValidateServiceID checks that 'input' can be parsed as a Service ID +func ValidateServiceID(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 := ParseServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Service ID +func (id ServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/services/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.ServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Service ID +func (id ServiceId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticServices", "services", "services"), + resourceids.UserSpecifiedSegment("serviceName", "serviceName"), + } +} + +// String returns a human-readable description of this Service ID +func (id ServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Service Name: %q", id.ServiceName), + } + return fmt.Sprintf("Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/id_service_test.go b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/id_service_test.go new file mode 100644 index 00000000000..577612d3e07 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/id_service_test.go @@ -0,0 +1,327 @@ +package materializedviewsbuilder + +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 = &ServiceId{} + +func TestNewServiceID(t *testing.T) { + id := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "serviceName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.ServiceName != "serviceName" { + t.Fatalf("Expected %q but got %q for Segment 'ServiceName'", id.ServiceName, "serviceName") + } +} + +func TestFormatServiceID(t *testing.T) { + actual := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "serviceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services/serviceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services/serviceName", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + ServiceName: "serviceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services/serviceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.ServiceName != v.Expected.ServiceName { + t.Fatalf("Expected %q but got %q for ServiceName", v.Expected.ServiceName, actual.ServiceName) + } + + } +} + +func TestParseServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services/serviceName", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + ServiceName: "serviceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services/serviceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sErViCeS/sErViCeNaMe", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + ServiceName: "sErViCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sErViCeS/sErViCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.ServiceName != v.Expected.ServiceName { + t.Fatalf("Expected %q but got %q for ServiceName", v.Expected.ServiceName, actual.ServiceName) + } + + } +} + +func TestSegmentsForServiceId(t *testing.T) { + segments := ServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ServiceId 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/cosmosdb/2024-11-15/materializedviewsbuilder/method_servicecreate.go b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/method_servicecreate.go new file mode 100644 index 00000000000..f40148be8ea --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/method_servicecreate.go @@ -0,0 +1,75 @@ +package materializedviewsbuilder + +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 ServiceCreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ServiceResource +} + +// ServiceCreate ... +func (c MaterializedViewsBuilderClient) ServiceCreate(ctx context.Context, id ServiceId, input ServiceResourceCreateUpdateParameters) (result ServiceCreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// ServiceCreateThenPoll performs ServiceCreate then polls until it's completed +func (c MaterializedViewsBuilderClient) ServiceCreateThenPoll(ctx context.Context, id ServiceId, input ServiceResourceCreateUpdateParameters) error { + result, err := c.ServiceCreate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ServiceCreate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServiceCreate: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/method_servicedelete.go b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/method_servicedelete.go new file mode 100644 index 00000000000..3331bfb8c06 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/method_servicedelete.go @@ -0,0 +1,71 @@ +package materializedviewsbuilder + +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 ServiceDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ServiceDelete ... +func (c MaterializedViewsBuilderClient) ServiceDelete(ctx context.Context, id ServiceId) (result ServiceDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ServiceDeleteThenPoll performs ServiceDelete then polls until it's completed +func (c MaterializedViewsBuilderClient) ServiceDeleteThenPoll(ctx context.Context, id ServiceId) error { + result, err := c.ServiceDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing ServiceDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServiceDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/method_serviceget.go b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/method_serviceget.go new file mode 100644 index 00000000000..98965b6b841 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/method_serviceget.go @@ -0,0 +1,53 @@ +package materializedviewsbuilder + +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 ServiceGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ServiceResource +} + +// ServiceGet ... +func (c MaterializedViewsBuilderClient) ServiceGet(ctx context.Context, id ServiceId) (result ServiceGetOperationResponse, 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 ServiceResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_datatransferserviceresourcecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_datatransferserviceresourcecreateupdateproperties.go new file mode 100644 index 00000000000..58ad99ee73c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_datatransferserviceresourcecreateupdateproperties.go @@ -0,0 +1,53 @@ +package materializedviewsbuilder + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServiceResourceCreateUpdateProperties = DataTransferServiceResourceCreateUpdateProperties{} + +type DataTransferServiceResourceCreateUpdateProperties struct { + + // Fields inherited from ServiceResourceCreateUpdateProperties + + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` +} + +func (s DataTransferServiceResourceCreateUpdateProperties) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return BaseServiceResourceCreateUpdatePropertiesImpl{ + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + } +} + +var _ json.Marshaler = DataTransferServiceResourceCreateUpdateProperties{} + +func (s DataTransferServiceResourceCreateUpdateProperties) MarshalJSON() ([]byte, error) { + type wrapper DataTransferServiceResourceCreateUpdateProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DataTransferServiceResourceCreateUpdateProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DataTransferServiceResourceCreateUpdateProperties: %+v", err) + } + + decoded["serviceType"] = "DataTransfer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DataTransferServiceResourceCreateUpdateProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_datatransferserviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_datatransferserviceresourceproperties.go new file mode 100644 index 00000000000..ea79107534b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_datatransferserviceresourceproperties.go @@ -0,0 +1,73 @@ +package materializedviewsbuilder + +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 _ ServiceResourceProperties = DataTransferServiceResourceProperties{} + +type DataTransferServiceResourceProperties struct { + Locations *[]RegionalServiceResource `json:"locations,omitempty"` + + // Fields inherited from ServiceResourceProperties + + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s DataTransferServiceResourceProperties) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return BaseServiceResourcePropertiesImpl{ + CreationTime: s.CreationTime, + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + Status: s.Status, + } +} + +func (o *DataTransferServiceResourceProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DataTransferServiceResourceProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +var _ json.Marshaler = DataTransferServiceResourceProperties{} + +func (s DataTransferServiceResourceProperties) MarshalJSON() ([]byte, error) { + type wrapper DataTransferServiceResourceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DataTransferServiceResourceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DataTransferServiceResourceProperties: %+v", err) + } + + decoded["serviceType"] = "DataTransfer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DataTransferServiceResourceProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_graphapicomputeregionalserviceresource.go b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_graphapicomputeregionalserviceresource.go new file mode 100644 index 00000000000..2b26b42b371 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_graphapicomputeregionalserviceresource.go @@ -0,0 +1,11 @@ +package materializedviewsbuilder + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GraphAPIComputeRegionalServiceResource struct { + GraphApiComputeEndpoint *string `json:"graphApiComputeEndpoint,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Status *ServiceStatus `json:"status,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_graphapicomputeserviceresourcecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_graphapicomputeserviceresourcecreateupdateproperties.go new file mode 100644 index 00000000000..00b10609019 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_graphapicomputeserviceresourcecreateupdateproperties.go @@ -0,0 +1,53 @@ +package materializedviewsbuilder + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServiceResourceCreateUpdateProperties = GraphAPIComputeServiceResourceCreateUpdateProperties{} + +type GraphAPIComputeServiceResourceCreateUpdateProperties struct { + + // Fields inherited from ServiceResourceCreateUpdateProperties + + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` +} + +func (s GraphAPIComputeServiceResourceCreateUpdateProperties) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return BaseServiceResourceCreateUpdatePropertiesImpl{ + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + } +} + +var _ json.Marshaler = GraphAPIComputeServiceResourceCreateUpdateProperties{} + +func (s GraphAPIComputeServiceResourceCreateUpdateProperties) MarshalJSON() ([]byte, error) { + type wrapper GraphAPIComputeServiceResourceCreateUpdateProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GraphAPIComputeServiceResourceCreateUpdateProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GraphAPIComputeServiceResourceCreateUpdateProperties: %+v", err) + } + + decoded["serviceType"] = "GraphAPICompute" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GraphAPIComputeServiceResourceCreateUpdateProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_graphapicomputeserviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_graphapicomputeserviceresourceproperties.go new file mode 100644 index 00000000000..069b276664b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_graphapicomputeserviceresourceproperties.go @@ -0,0 +1,74 @@ +package materializedviewsbuilder + +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 _ ServiceResourceProperties = GraphAPIComputeServiceResourceProperties{} + +type GraphAPIComputeServiceResourceProperties struct { + GraphApiComputeEndpoint *string `json:"graphApiComputeEndpoint,omitempty"` + Locations *[]GraphAPIComputeRegionalServiceResource `json:"locations,omitempty"` + + // Fields inherited from ServiceResourceProperties + + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s GraphAPIComputeServiceResourceProperties) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return BaseServiceResourcePropertiesImpl{ + CreationTime: s.CreationTime, + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + Status: s.Status, + } +} + +func (o *GraphAPIComputeServiceResourceProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *GraphAPIComputeServiceResourceProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +var _ json.Marshaler = GraphAPIComputeServiceResourceProperties{} + +func (s GraphAPIComputeServiceResourceProperties) MarshalJSON() ([]byte, error) { + type wrapper GraphAPIComputeServiceResourceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GraphAPIComputeServiceResourceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GraphAPIComputeServiceResourceProperties: %+v", err) + } + + decoded["serviceType"] = "GraphAPICompute" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GraphAPIComputeServiceResourceProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_materializedviewsbuilderserviceresourcecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_materializedviewsbuilderserviceresourcecreateupdateproperties.go new file mode 100644 index 00000000000..ef2299db0d7 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_materializedviewsbuilderserviceresourcecreateupdateproperties.go @@ -0,0 +1,53 @@ +package materializedviewsbuilder + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServiceResourceCreateUpdateProperties = MaterializedViewsBuilderServiceResourceCreateUpdateProperties{} + +type MaterializedViewsBuilderServiceResourceCreateUpdateProperties struct { + + // Fields inherited from ServiceResourceCreateUpdateProperties + + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` +} + +func (s MaterializedViewsBuilderServiceResourceCreateUpdateProperties) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return BaseServiceResourceCreateUpdatePropertiesImpl{ + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + } +} + +var _ json.Marshaler = MaterializedViewsBuilderServiceResourceCreateUpdateProperties{} + +func (s MaterializedViewsBuilderServiceResourceCreateUpdateProperties) MarshalJSON() ([]byte, error) { + type wrapper MaterializedViewsBuilderServiceResourceCreateUpdateProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MaterializedViewsBuilderServiceResourceCreateUpdateProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MaterializedViewsBuilderServiceResourceCreateUpdateProperties: %+v", err) + } + + decoded["serviceType"] = "MaterializedViewsBuilder" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MaterializedViewsBuilderServiceResourceCreateUpdateProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_materializedviewsbuilderserviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_materializedviewsbuilderserviceresourceproperties.go new file mode 100644 index 00000000000..235a61a3a58 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_materializedviewsbuilderserviceresourceproperties.go @@ -0,0 +1,73 @@ +package materializedviewsbuilder + +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 _ ServiceResourceProperties = MaterializedViewsBuilderServiceResourceProperties{} + +type MaterializedViewsBuilderServiceResourceProperties struct { + Locations *[]RegionalServiceResource `json:"locations,omitempty"` + + // Fields inherited from ServiceResourceProperties + + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s MaterializedViewsBuilderServiceResourceProperties) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return BaseServiceResourcePropertiesImpl{ + CreationTime: s.CreationTime, + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + Status: s.Status, + } +} + +func (o *MaterializedViewsBuilderServiceResourceProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MaterializedViewsBuilderServiceResourceProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +var _ json.Marshaler = MaterializedViewsBuilderServiceResourceProperties{} + +func (s MaterializedViewsBuilderServiceResourceProperties) MarshalJSON() ([]byte, error) { + type wrapper MaterializedViewsBuilderServiceResourceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MaterializedViewsBuilderServiceResourceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MaterializedViewsBuilderServiceResourceProperties: %+v", err) + } + + decoded["serviceType"] = "MaterializedViewsBuilder" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MaterializedViewsBuilderServiceResourceProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_regionalserviceresource.go b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_regionalserviceresource.go new file mode 100644 index 00000000000..7fbb64ab64b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_regionalserviceresource.go @@ -0,0 +1,10 @@ +package materializedviewsbuilder + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegionalServiceResource struct { + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Status *ServiceStatus `json:"status,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_serviceresource.go b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_serviceresource.go new file mode 100644 index 00000000000..38c3d7103d7 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_serviceresource.go @@ -0,0 +1,48 @@ +package materializedviewsbuilder + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties ServiceResourceProperties `json:"properties"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ServiceResource{} + +func (s *ServiceResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Id = decoded.Id + s.Name = decoded.Name + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ServiceResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalServiceResourcePropertiesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ServiceResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_serviceresourcecreateupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_serviceresourcecreateupdateparameters.go new file mode 100644 index 00000000000..98ebc6c0fe3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_serviceresourcecreateupdateparameters.go @@ -0,0 +1,33 @@ +package materializedviewsbuilder + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceResourceCreateUpdateParameters struct { + Properties ServiceResourceCreateUpdateProperties `json:"properties"` +} + +var _ json.Unmarshaler = &ServiceResourceCreateUpdateParameters{} + +func (s *ServiceResourceCreateUpdateParameters) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ServiceResourceCreateUpdateParameters into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalServiceResourceCreateUpdatePropertiesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ServiceResourceCreateUpdateParameters': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_serviceresourcecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_serviceresourcecreateupdateproperties.go new file mode 100644 index 00000000000..eea7b5e65c4 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_serviceresourcecreateupdateproperties.go @@ -0,0 +1,101 @@ +package materializedviewsbuilder + +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 ServiceResourceCreateUpdateProperties interface { + ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl +} + +var _ ServiceResourceCreateUpdateProperties = BaseServiceResourceCreateUpdatePropertiesImpl{} + +type BaseServiceResourceCreateUpdatePropertiesImpl struct { + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` +} + +func (s BaseServiceResourceCreateUpdatePropertiesImpl) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return s +} + +var _ ServiceResourceCreateUpdateProperties = RawServiceResourceCreateUpdatePropertiesImpl{} + +// RawServiceResourceCreateUpdatePropertiesImpl 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 RawServiceResourceCreateUpdatePropertiesImpl struct { + serviceResourceCreateUpdateProperties BaseServiceResourceCreateUpdatePropertiesImpl + Type string + Values map[string]interface{} +} + +func (s RawServiceResourceCreateUpdatePropertiesImpl) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return s.serviceResourceCreateUpdateProperties +} + +func UnmarshalServiceResourceCreateUpdatePropertiesImplementation(input []byte) (ServiceResourceCreateUpdateProperties, 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 ServiceResourceCreateUpdateProperties into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["serviceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "DataTransfer") { + var out DataTransferServiceResourceCreateUpdateProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DataTransferServiceResourceCreateUpdateProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GraphAPICompute") { + var out GraphAPIComputeServiceResourceCreateUpdateProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GraphAPIComputeServiceResourceCreateUpdateProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MaterializedViewsBuilder") { + var out MaterializedViewsBuilderServiceResourceCreateUpdateProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MaterializedViewsBuilderServiceResourceCreateUpdateProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SqlDedicatedGateway") { + var out SqlDedicatedGatewayServiceResourceCreateUpdateProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SqlDedicatedGatewayServiceResourceCreateUpdateProperties: %+v", err) + } + return out, nil + } + + var parent BaseServiceResourceCreateUpdatePropertiesImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseServiceResourceCreateUpdatePropertiesImpl: %+v", err) + } + + return RawServiceResourceCreateUpdatePropertiesImpl{ + serviceResourceCreateUpdateProperties: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_serviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_serviceresourceproperties.go new file mode 100644 index 00000000000..d5085a80470 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_serviceresourceproperties.go @@ -0,0 +1,103 @@ +package materializedviewsbuilder + +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 ServiceResourceProperties interface { + ServiceResourceProperties() BaseServiceResourcePropertiesImpl +} + +var _ ServiceResourceProperties = BaseServiceResourcePropertiesImpl{} + +type BaseServiceResourcePropertiesImpl struct { + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s BaseServiceResourcePropertiesImpl) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return s +} + +var _ ServiceResourceProperties = RawServiceResourcePropertiesImpl{} + +// RawServiceResourcePropertiesImpl 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 RawServiceResourcePropertiesImpl struct { + serviceResourceProperties BaseServiceResourcePropertiesImpl + Type string + Values map[string]interface{} +} + +func (s RawServiceResourcePropertiesImpl) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return s.serviceResourceProperties +} + +func UnmarshalServiceResourcePropertiesImplementation(input []byte) (ServiceResourceProperties, 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 ServiceResourceProperties into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["serviceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "DataTransfer") { + var out DataTransferServiceResourceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DataTransferServiceResourceProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GraphAPICompute") { + var out GraphAPIComputeServiceResourceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GraphAPIComputeServiceResourceProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MaterializedViewsBuilder") { + var out MaterializedViewsBuilderServiceResourceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MaterializedViewsBuilderServiceResourceProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SqlDedicatedGateway") { + var out SqlDedicatedGatewayServiceResourceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SqlDedicatedGatewayServiceResourceProperties: %+v", err) + } + return out, nil + } + + var parent BaseServiceResourcePropertiesImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseServiceResourcePropertiesImpl: %+v", err) + } + + return RawServiceResourcePropertiesImpl{ + serviceResourceProperties: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_sqldedicatedgatewayregionalserviceresource.go b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_sqldedicatedgatewayregionalserviceresource.go new file mode 100644 index 00000000000..a6312d724c0 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_sqldedicatedgatewayregionalserviceresource.go @@ -0,0 +1,11 @@ +package materializedviewsbuilder + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlDedicatedGatewayRegionalServiceResource struct { + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + SqlDedicatedGatewayEndpoint *string `json:"sqlDedicatedGatewayEndpoint,omitempty"` + Status *ServiceStatus `json:"status,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_sqldedicatedgatewayserviceresourcecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_sqldedicatedgatewayserviceresourcecreateupdateproperties.go new file mode 100644 index 00000000000..66ad106a698 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_sqldedicatedgatewayserviceresourcecreateupdateproperties.go @@ -0,0 +1,54 @@ +package materializedviewsbuilder + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServiceResourceCreateUpdateProperties = SqlDedicatedGatewayServiceResourceCreateUpdateProperties{} + +type SqlDedicatedGatewayServiceResourceCreateUpdateProperties struct { + DedicatedGatewayType *DedicatedGatewayType `json:"dedicatedGatewayType,omitempty"` + + // Fields inherited from ServiceResourceCreateUpdateProperties + + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` +} + +func (s SqlDedicatedGatewayServiceResourceCreateUpdateProperties) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return BaseServiceResourceCreateUpdatePropertiesImpl{ + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + } +} + +var _ json.Marshaler = SqlDedicatedGatewayServiceResourceCreateUpdateProperties{} + +func (s SqlDedicatedGatewayServiceResourceCreateUpdateProperties) MarshalJSON() ([]byte, error) { + type wrapper SqlDedicatedGatewayServiceResourceCreateUpdateProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SqlDedicatedGatewayServiceResourceCreateUpdateProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SqlDedicatedGatewayServiceResourceCreateUpdateProperties: %+v", err) + } + + decoded["serviceType"] = "SqlDedicatedGateway" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SqlDedicatedGatewayServiceResourceCreateUpdateProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_sqldedicatedgatewayserviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_sqldedicatedgatewayserviceresourceproperties.go new file mode 100644 index 00000000000..bfff4e5f726 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/model_sqldedicatedgatewayserviceresourceproperties.go @@ -0,0 +1,75 @@ +package materializedviewsbuilder + +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 _ ServiceResourceProperties = SqlDedicatedGatewayServiceResourceProperties{} + +type SqlDedicatedGatewayServiceResourceProperties struct { + DedicatedGatewayType *DedicatedGatewayType `json:"dedicatedGatewayType,omitempty"` + Locations *[]SqlDedicatedGatewayRegionalServiceResource `json:"locations,omitempty"` + SqlDedicatedGatewayEndpoint *string `json:"sqlDedicatedGatewayEndpoint,omitempty"` + + // Fields inherited from ServiceResourceProperties + + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s SqlDedicatedGatewayServiceResourceProperties) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return BaseServiceResourcePropertiesImpl{ + CreationTime: s.CreationTime, + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + Status: s.Status, + } +} + +func (o *SqlDedicatedGatewayServiceResourceProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SqlDedicatedGatewayServiceResourceProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +var _ json.Marshaler = SqlDedicatedGatewayServiceResourceProperties{} + +func (s SqlDedicatedGatewayServiceResourceProperties) MarshalJSON() ([]byte, error) { + type wrapper SqlDedicatedGatewayServiceResourceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SqlDedicatedGatewayServiceResourceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SqlDedicatedGatewayServiceResourceProperties: %+v", err) + } + + decoded["serviceType"] = "SqlDedicatedGateway" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SqlDedicatedGatewayServiceResourceProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/version.go b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/version.go new file mode 100644 index 00000000000..0e294293a74 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/materializedviewsbuilder/version.go @@ -0,0 +1,10 @@ +package materializedviewsbuilder + +// 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-11-15" + +func userAgent() string { + return "hashicorp/go-azure-sdk/materializedviewsbuilder/2024-11-15" +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/README.md b/resource-manager/cosmosdb/2024-11-15/mongorbacs/README.md new file mode 100644 index 00000000000..db4aeb72328 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/README.md @@ -0,0 +1,142 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/mongorbacs` Documentation + +The `mongorbacs` SDK allows for interaction with Azure Resource Manager `cosmosdb` (API Version `2024-11-15`). + +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/cosmosdb/2024-11-15/mongorbacs" +``` + + +### Client Initialization + +```go +client := mongorbacs.NewMongorbacsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `MongorbacsClient.MongoDBResourcesCreateUpdateMongoRoleDefinition` + +```go +ctx := context.TODO() +id := mongorbacs.NewMongodbRoleDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongoRoleDefinitionId") + +payload := mongorbacs.MongoRoleDefinitionCreateUpdateParameters{ + // ... +} + + +if err := client.MongoDBResourcesCreateUpdateMongoRoleDefinitionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `MongorbacsClient.MongoDBResourcesCreateUpdateMongoUserDefinition` + +```go +ctx := context.TODO() +id := mongorbacs.NewMongodbUserDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongoUserDefinitionId") + +payload := mongorbacs.MongoUserDefinitionCreateUpdateParameters{ + // ... +} + + +if err := client.MongoDBResourcesCreateUpdateMongoUserDefinitionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `MongorbacsClient.MongoDBResourcesDeleteMongoRoleDefinition` + +```go +ctx := context.TODO() +id := mongorbacs.NewMongodbRoleDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongoRoleDefinitionId") + +if err := client.MongoDBResourcesDeleteMongoRoleDefinitionThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `MongorbacsClient.MongoDBResourcesDeleteMongoUserDefinition` + +```go +ctx := context.TODO() +id := mongorbacs.NewMongodbUserDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongoUserDefinitionId") + +if err := client.MongoDBResourcesDeleteMongoUserDefinitionThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `MongorbacsClient.MongoDBResourcesGetMongoRoleDefinition` + +```go +ctx := context.TODO() +id := mongorbacs.NewMongodbRoleDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongoRoleDefinitionId") + +read, err := client.MongoDBResourcesGetMongoRoleDefinition(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `MongorbacsClient.MongoDBResourcesGetMongoUserDefinition` + +```go +ctx := context.TODO() +id := mongorbacs.NewMongodbUserDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongoUserDefinitionId") + +read, err := client.MongoDBResourcesGetMongoUserDefinition(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `MongorbacsClient.MongoDBResourcesListMongoRoleDefinitions` + +```go +ctx := context.TODO() +id := mongorbacs.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.MongoDBResourcesListMongoRoleDefinitions(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `MongorbacsClient.MongoDBResourcesListMongoUserDefinitions` + +```go +ctx := context.TODO() +id := mongorbacs.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.MongoDBResourcesListMongoUserDefinitions(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/client.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/client.go new file mode 100644 index 00000000000..1e50d8ed79a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/client.go @@ -0,0 +1,26 @@ +package mongorbacs + +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 MongorbacsClient struct { + Client *resourcemanager.Client +} + +func NewMongorbacsClientWithBaseURI(sdkApi sdkEnv.Api) (*MongorbacsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "mongorbacs", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating MongorbacsClient: %+v", err) + } + + return &MongorbacsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/constants.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/constants.go new file mode 100644 index 00000000000..260b51bbced --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/constants.go @@ -0,0 +1,51 @@ +package mongorbacs + +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 MongoRoleDefinitionType string + +const ( + MongoRoleDefinitionTypeBuiltInRole MongoRoleDefinitionType = "BuiltInRole" + MongoRoleDefinitionTypeCustomRole MongoRoleDefinitionType = "CustomRole" +) + +func PossibleValuesForMongoRoleDefinitionType() []string { + return []string{ + string(MongoRoleDefinitionTypeBuiltInRole), + string(MongoRoleDefinitionTypeCustomRole), + } +} + +func (s *MongoRoleDefinitionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMongoRoleDefinitionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMongoRoleDefinitionType(input string) (*MongoRoleDefinitionType, error) { + vals := map[string]MongoRoleDefinitionType{ + "builtinrole": MongoRoleDefinitionTypeBuiltInRole, + "customrole": MongoRoleDefinitionTypeCustomRole, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MongoRoleDefinitionType(input) + return &out, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/id_databaseaccount.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/id_databaseaccount.go new file mode 100644 index 00000000000..35b2f7f690f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/id_databaseaccount.go @@ -0,0 +1,130 @@ +package mongorbacs + +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(&DatabaseAccountId{}) +} + +var _ resourceids.ResourceId = &DatabaseAccountId{} + +// DatabaseAccountId is a struct representing the Resource ID for a Database Account +type DatabaseAccountId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string +} + +// NewDatabaseAccountID returns a new DatabaseAccountId struct +func NewDatabaseAccountID(subscriptionId string, resourceGroupName string, databaseAccountName string) DatabaseAccountId { + return DatabaseAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + } +} + +// ParseDatabaseAccountID parses 'input' into a DatabaseAccountId +func ParseDatabaseAccountID(input string) (*DatabaseAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDatabaseAccountIDInsensitively parses 'input' case-insensitively into a DatabaseAccountId +// note: this method should only be used for API response data and not user input +func ParseDatabaseAccountIDInsensitively(input string) (*DatabaseAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DatabaseAccountId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + return nil +} + +// ValidateDatabaseAccountID checks that 'input' can be parsed as a Database Account ID +func ValidateDatabaseAccountID(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 := ParseDatabaseAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Database Account ID +func (id DatabaseAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Database Account ID +func (id DatabaseAccountId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + } +} + +// String returns a human-readable description of this Database Account ID +func (id DatabaseAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + } + return fmt.Sprintf("Database Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/id_databaseaccount_test.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/id_databaseaccount_test.go new file mode 100644 index 00000000000..18a73206d20 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/id_databaseaccount_test.go @@ -0,0 +1,282 @@ +package mongorbacs + +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 = &DatabaseAccountId{} + +func TestNewDatabaseAccountID(t *testing.T) { + id := NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } +} + +func TestFormatDatabaseAccountID(t *testing.T) { + actual := NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDatabaseAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Expected: &DatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseAccountID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + } +} + +func TestParseDatabaseAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Expected: &DatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Expected: &DatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseAccountIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + } +} + +func TestSegmentsForDatabaseAccountId(t *testing.T) { + segments := DatabaseAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DatabaseAccountId 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/cosmosdb/2024-11-15/mongorbacs/id_mongodbroledefinition.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/id_mongodbroledefinition.go new file mode 100644 index 00000000000..859adbfb63f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/id_mongodbroledefinition.go @@ -0,0 +1,139 @@ +package mongorbacs + +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(&MongodbRoleDefinitionId{}) +} + +var _ resourceids.ResourceId = &MongodbRoleDefinitionId{} + +// MongodbRoleDefinitionId is a struct representing the Resource ID for a Mongodb Role Definition +type MongodbRoleDefinitionId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + MongoRoleDefinitionId string +} + +// NewMongodbRoleDefinitionID returns a new MongodbRoleDefinitionId struct +func NewMongodbRoleDefinitionID(subscriptionId string, resourceGroupName string, databaseAccountName string, mongoRoleDefinitionId string) MongodbRoleDefinitionId { + return MongodbRoleDefinitionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + MongoRoleDefinitionId: mongoRoleDefinitionId, + } +} + +// ParseMongodbRoleDefinitionID parses 'input' into a MongodbRoleDefinitionId +func ParseMongodbRoleDefinitionID(input string) (*MongodbRoleDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&MongodbRoleDefinitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MongodbRoleDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMongodbRoleDefinitionIDInsensitively parses 'input' case-insensitively into a MongodbRoleDefinitionId +// note: this method should only be used for API response data and not user input +func ParseMongodbRoleDefinitionIDInsensitively(input string) (*MongodbRoleDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&MongodbRoleDefinitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MongodbRoleDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MongodbRoleDefinitionId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.MongoRoleDefinitionId, ok = input.Parsed["mongoRoleDefinitionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "mongoRoleDefinitionId", input) + } + + return nil +} + +// ValidateMongodbRoleDefinitionID checks that 'input' can be parsed as a Mongodb Role Definition ID +func ValidateMongodbRoleDefinitionID(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 := ParseMongodbRoleDefinitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Mongodb Role Definition ID +func (id MongodbRoleDefinitionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/mongodbRoleDefinitions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.MongoRoleDefinitionId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Mongodb Role Definition ID +func (id MongodbRoleDefinitionId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticMongodbRoleDefinitions", "mongodbRoleDefinitions", "mongodbRoleDefinitions"), + resourceids.UserSpecifiedSegment("mongoRoleDefinitionId", "mongoRoleDefinitionId"), + } +} + +// String returns a human-readable description of this Mongodb Role Definition ID +func (id MongodbRoleDefinitionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Mongo Role Definition: %q", id.MongoRoleDefinitionId), + } + return fmt.Sprintf("Mongodb Role Definition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/id_mongodbroledefinition_test.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/id_mongodbroledefinition_test.go new file mode 100644 index 00000000000..667a0b36da3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/id_mongodbroledefinition_test.go @@ -0,0 +1,327 @@ +package mongorbacs + +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 = &MongodbRoleDefinitionId{} + +func TestNewMongodbRoleDefinitionID(t *testing.T) { + id := NewMongodbRoleDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongoRoleDefinitionId") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.MongoRoleDefinitionId != "mongoRoleDefinitionId" { + t.Fatalf("Expected %q but got %q for Segment 'MongoRoleDefinitionId'", id.MongoRoleDefinitionId, "mongoRoleDefinitionId") + } +} + +func TestFormatMongodbRoleDefinitionID(t *testing.T) { + actual := NewMongodbRoleDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongoRoleDefinitionId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbRoleDefinitions/mongoRoleDefinitionId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMongodbRoleDefinitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MongodbRoleDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbRoleDefinitions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbRoleDefinitions/mongoRoleDefinitionId", + Expected: &MongodbRoleDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + MongoRoleDefinitionId: "mongoRoleDefinitionId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbRoleDefinitions/mongoRoleDefinitionId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMongodbRoleDefinitionID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.MongoRoleDefinitionId != v.Expected.MongoRoleDefinitionId { + t.Fatalf("Expected %q but got %q for MongoRoleDefinitionId", v.Expected.MongoRoleDefinitionId, actual.MongoRoleDefinitionId) + } + + } +} + +func TestParseMongodbRoleDefinitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MongodbRoleDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbRoleDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/mOnGoDbRoLeDeFiNiTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbRoleDefinitions/mongoRoleDefinitionId", + Expected: &MongodbRoleDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + MongoRoleDefinitionId: "mongoRoleDefinitionId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbRoleDefinitions/mongoRoleDefinitionId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/mOnGoDbRoLeDeFiNiTiOnS/mOnGoRoLeDeFiNiTiOnId", + Expected: &MongodbRoleDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + MongoRoleDefinitionId: "mOnGoRoLeDeFiNiTiOnId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/mOnGoDbRoLeDeFiNiTiOnS/mOnGoRoLeDeFiNiTiOnId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMongodbRoleDefinitionIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.MongoRoleDefinitionId != v.Expected.MongoRoleDefinitionId { + t.Fatalf("Expected %q but got %q for MongoRoleDefinitionId", v.Expected.MongoRoleDefinitionId, actual.MongoRoleDefinitionId) + } + + } +} + +func TestSegmentsForMongodbRoleDefinitionId(t *testing.T) { + segments := MongodbRoleDefinitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MongodbRoleDefinitionId 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/cosmosdb/2024-11-15/mongorbacs/id_mongodbuserdefinition.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/id_mongodbuserdefinition.go new file mode 100644 index 00000000000..68a38ae9094 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/id_mongodbuserdefinition.go @@ -0,0 +1,139 @@ +package mongorbacs + +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(&MongodbUserDefinitionId{}) +} + +var _ resourceids.ResourceId = &MongodbUserDefinitionId{} + +// MongodbUserDefinitionId is a struct representing the Resource ID for a Mongodb User Definition +type MongodbUserDefinitionId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + MongoUserDefinitionId string +} + +// NewMongodbUserDefinitionID returns a new MongodbUserDefinitionId struct +func NewMongodbUserDefinitionID(subscriptionId string, resourceGroupName string, databaseAccountName string, mongoUserDefinitionId string) MongodbUserDefinitionId { + return MongodbUserDefinitionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + MongoUserDefinitionId: mongoUserDefinitionId, + } +} + +// ParseMongodbUserDefinitionID parses 'input' into a MongodbUserDefinitionId +func ParseMongodbUserDefinitionID(input string) (*MongodbUserDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&MongodbUserDefinitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MongodbUserDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMongodbUserDefinitionIDInsensitively parses 'input' case-insensitively into a MongodbUserDefinitionId +// note: this method should only be used for API response data and not user input +func ParseMongodbUserDefinitionIDInsensitively(input string) (*MongodbUserDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&MongodbUserDefinitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MongodbUserDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MongodbUserDefinitionId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.MongoUserDefinitionId, ok = input.Parsed["mongoUserDefinitionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "mongoUserDefinitionId", input) + } + + return nil +} + +// ValidateMongodbUserDefinitionID checks that 'input' can be parsed as a Mongodb User Definition ID +func ValidateMongodbUserDefinitionID(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 := ParseMongodbUserDefinitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Mongodb User Definition ID +func (id MongodbUserDefinitionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/mongodbUserDefinitions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.MongoUserDefinitionId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Mongodb User Definition ID +func (id MongodbUserDefinitionId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticMongodbUserDefinitions", "mongodbUserDefinitions", "mongodbUserDefinitions"), + resourceids.UserSpecifiedSegment("mongoUserDefinitionId", "mongoUserDefinitionId"), + } +} + +// String returns a human-readable description of this Mongodb User Definition ID +func (id MongodbUserDefinitionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Mongo User Definition: %q", id.MongoUserDefinitionId), + } + return fmt.Sprintf("Mongodb User Definition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/id_mongodbuserdefinition_test.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/id_mongodbuserdefinition_test.go new file mode 100644 index 00000000000..eb010d3045a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/id_mongodbuserdefinition_test.go @@ -0,0 +1,327 @@ +package mongorbacs + +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 = &MongodbUserDefinitionId{} + +func TestNewMongodbUserDefinitionID(t *testing.T) { + id := NewMongodbUserDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongoUserDefinitionId") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.MongoUserDefinitionId != "mongoUserDefinitionId" { + t.Fatalf("Expected %q but got %q for Segment 'MongoUserDefinitionId'", id.MongoUserDefinitionId, "mongoUserDefinitionId") + } +} + +func TestFormatMongodbUserDefinitionID(t *testing.T) { + actual := NewMongodbUserDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongoUserDefinitionId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbUserDefinitions/mongoUserDefinitionId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMongodbUserDefinitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MongodbUserDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbUserDefinitions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbUserDefinitions/mongoUserDefinitionId", + Expected: &MongodbUserDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + MongoUserDefinitionId: "mongoUserDefinitionId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbUserDefinitions/mongoUserDefinitionId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMongodbUserDefinitionID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.MongoUserDefinitionId != v.Expected.MongoUserDefinitionId { + t.Fatalf("Expected %q but got %q for MongoUserDefinitionId", v.Expected.MongoUserDefinitionId, actual.MongoUserDefinitionId) + } + + } +} + +func TestParseMongodbUserDefinitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MongodbUserDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbUserDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/mOnGoDbUsErDeFiNiTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbUserDefinitions/mongoUserDefinitionId", + Expected: &MongodbUserDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + MongoUserDefinitionId: "mongoUserDefinitionId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbUserDefinitions/mongoUserDefinitionId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/mOnGoDbUsErDeFiNiTiOnS/mOnGoUsErDeFiNiTiOnId", + Expected: &MongodbUserDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + MongoUserDefinitionId: "mOnGoUsErDeFiNiTiOnId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/mOnGoDbUsErDeFiNiTiOnS/mOnGoUsErDeFiNiTiOnId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMongodbUserDefinitionIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.MongoUserDefinitionId != v.Expected.MongoUserDefinitionId { + t.Fatalf("Expected %q but got %q for MongoUserDefinitionId", v.Expected.MongoUserDefinitionId, actual.MongoUserDefinitionId) + } + + } +} + +func TestSegmentsForMongodbUserDefinitionId(t *testing.T) { + segments := MongodbUserDefinitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MongodbUserDefinitionId 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/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourcescreateupdatemongoroledefinition.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourcescreateupdatemongoroledefinition.go new file mode 100644 index 00000000000..11afe4faf5c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourcescreateupdatemongoroledefinition.go @@ -0,0 +1,75 @@ +package mongorbacs + +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 MongoDBResourcesCreateUpdateMongoRoleDefinitionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MongoRoleDefinitionGetResults +} + +// MongoDBResourcesCreateUpdateMongoRoleDefinition ... +func (c MongorbacsClient) MongoDBResourcesCreateUpdateMongoRoleDefinition(ctx context.Context, id MongodbRoleDefinitionId, input MongoRoleDefinitionCreateUpdateParameters) (result MongoDBResourcesCreateUpdateMongoRoleDefinitionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// MongoDBResourcesCreateUpdateMongoRoleDefinitionThenPoll performs MongoDBResourcesCreateUpdateMongoRoleDefinition then polls until it's completed +func (c MongorbacsClient) MongoDBResourcesCreateUpdateMongoRoleDefinitionThenPoll(ctx context.Context, id MongodbRoleDefinitionId, input MongoRoleDefinitionCreateUpdateParameters) error { + result, err := c.MongoDBResourcesCreateUpdateMongoRoleDefinition(ctx, id, input) + if err != nil { + return fmt.Errorf("performing MongoDBResourcesCreateUpdateMongoRoleDefinition: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MongoDBResourcesCreateUpdateMongoRoleDefinition: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourcescreateupdatemongouserdefinition.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourcescreateupdatemongouserdefinition.go new file mode 100644 index 00000000000..32a9a0a1a4f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourcescreateupdatemongouserdefinition.go @@ -0,0 +1,75 @@ +package mongorbacs + +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 MongoDBResourcesCreateUpdateMongoUserDefinitionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MongoUserDefinitionGetResults +} + +// MongoDBResourcesCreateUpdateMongoUserDefinition ... +func (c MongorbacsClient) MongoDBResourcesCreateUpdateMongoUserDefinition(ctx context.Context, id MongodbUserDefinitionId, input MongoUserDefinitionCreateUpdateParameters) (result MongoDBResourcesCreateUpdateMongoUserDefinitionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// MongoDBResourcesCreateUpdateMongoUserDefinitionThenPoll performs MongoDBResourcesCreateUpdateMongoUserDefinition then polls until it's completed +func (c MongorbacsClient) MongoDBResourcesCreateUpdateMongoUserDefinitionThenPoll(ctx context.Context, id MongodbUserDefinitionId, input MongoUserDefinitionCreateUpdateParameters) error { + result, err := c.MongoDBResourcesCreateUpdateMongoUserDefinition(ctx, id, input) + if err != nil { + return fmt.Errorf("performing MongoDBResourcesCreateUpdateMongoUserDefinition: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MongoDBResourcesCreateUpdateMongoUserDefinition: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourcesdeletemongoroledefinition.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourcesdeletemongoroledefinition.go new file mode 100644 index 00000000000..af6bfba7bb3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourcesdeletemongoroledefinition.go @@ -0,0 +1,71 @@ +package mongorbacs + +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 MongoDBResourcesDeleteMongoRoleDefinitionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// MongoDBResourcesDeleteMongoRoleDefinition ... +func (c MongorbacsClient) MongoDBResourcesDeleteMongoRoleDefinition(ctx context.Context, id MongodbRoleDefinitionId) (result MongoDBResourcesDeleteMongoRoleDefinitionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// MongoDBResourcesDeleteMongoRoleDefinitionThenPoll performs MongoDBResourcesDeleteMongoRoleDefinition then polls until it's completed +func (c MongorbacsClient) MongoDBResourcesDeleteMongoRoleDefinitionThenPoll(ctx context.Context, id MongodbRoleDefinitionId) error { + result, err := c.MongoDBResourcesDeleteMongoRoleDefinition(ctx, id) + if err != nil { + return fmt.Errorf("performing MongoDBResourcesDeleteMongoRoleDefinition: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MongoDBResourcesDeleteMongoRoleDefinition: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourcesdeletemongouserdefinition.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourcesdeletemongouserdefinition.go new file mode 100644 index 00000000000..4d1a35b0735 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourcesdeletemongouserdefinition.go @@ -0,0 +1,71 @@ +package mongorbacs + +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 MongoDBResourcesDeleteMongoUserDefinitionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// MongoDBResourcesDeleteMongoUserDefinition ... +func (c MongorbacsClient) MongoDBResourcesDeleteMongoUserDefinition(ctx context.Context, id MongodbUserDefinitionId) (result MongoDBResourcesDeleteMongoUserDefinitionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// MongoDBResourcesDeleteMongoUserDefinitionThenPoll performs MongoDBResourcesDeleteMongoUserDefinition then polls until it's completed +func (c MongorbacsClient) MongoDBResourcesDeleteMongoUserDefinitionThenPoll(ctx context.Context, id MongodbUserDefinitionId) error { + result, err := c.MongoDBResourcesDeleteMongoUserDefinition(ctx, id) + if err != nil { + return fmt.Errorf("performing MongoDBResourcesDeleteMongoUserDefinition: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MongoDBResourcesDeleteMongoUserDefinition: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourcesgetmongoroledefinition.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourcesgetmongoroledefinition.go new file mode 100644 index 00000000000..1e7c9e694dd --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourcesgetmongoroledefinition.go @@ -0,0 +1,53 @@ +package mongorbacs + +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 MongoDBResourcesGetMongoRoleDefinitionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MongoRoleDefinitionGetResults +} + +// MongoDBResourcesGetMongoRoleDefinition ... +func (c MongorbacsClient) MongoDBResourcesGetMongoRoleDefinition(ctx context.Context, id MongodbRoleDefinitionId) (result MongoDBResourcesGetMongoRoleDefinitionOperationResponse, 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 MongoRoleDefinitionGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourcesgetmongouserdefinition.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourcesgetmongouserdefinition.go new file mode 100644 index 00000000000..718e65a3110 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourcesgetmongouserdefinition.go @@ -0,0 +1,53 @@ +package mongorbacs + +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 MongoDBResourcesGetMongoUserDefinitionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MongoUserDefinitionGetResults +} + +// MongoDBResourcesGetMongoUserDefinition ... +func (c MongorbacsClient) MongoDBResourcesGetMongoUserDefinition(ctx context.Context, id MongodbUserDefinitionId) (result MongoDBResourcesGetMongoUserDefinitionOperationResponse, 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 MongoUserDefinitionGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourceslistmongoroledefinitions.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourceslistmongoroledefinitions.go new file mode 100644 index 00000000000..2992b8305b8 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourceslistmongoroledefinitions.go @@ -0,0 +1,54 @@ +package mongorbacs + +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 MongoDBResourcesListMongoRoleDefinitionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MongoRoleDefinitionListResult +} + +// MongoDBResourcesListMongoRoleDefinitions ... +func (c MongorbacsClient) MongoDBResourcesListMongoRoleDefinitions(ctx context.Context, id DatabaseAccountId) (result MongoDBResourcesListMongoRoleDefinitionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/mongodbRoleDefinitions", 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 MongoRoleDefinitionListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourceslistmongouserdefinitions.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourceslistmongouserdefinitions.go new file mode 100644 index 00000000000..cb49b606573 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/method_mongodbresourceslistmongouserdefinitions.go @@ -0,0 +1,54 @@ +package mongorbacs + +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 MongoDBResourcesListMongoUserDefinitionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MongoUserDefinitionListResult +} + +// MongoDBResourcesListMongoUserDefinitions ... +func (c MongorbacsClient) MongoDBResourcesListMongoUserDefinitions(ctx context.Context, id DatabaseAccountId) (result MongoDBResourcesListMongoUserDefinitionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/mongodbUserDefinitions", 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 MongoUserDefinitionListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongoroledefinitioncreateupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongoroledefinitioncreateupdateparameters.go new file mode 100644 index 00000000000..ad2fe42c88c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongoroledefinitioncreateupdateparameters.go @@ -0,0 +1,8 @@ +package mongorbacs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoRoleDefinitionCreateUpdateParameters struct { + Properties *MongoRoleDefinitionResource `json:"properties,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongoroledefinitiongetresults.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongoroledefinitiongetresults.go new file mode 100644 index 00000000000..8986ce78e6c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongoroledefinitiongetresults.go @@ -0,0 +1,11 @@ +package mongorbacs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoRoleDefinitionGetResults struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MongoRoleDefinitionResource `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongoroledefinitionlistresult.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongoroledefinitionlistresult.go new file mode 100644 index 00000000000..8b542dfedd6 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongoroledefinitionlistresult.go @@ -0,0 +1,8 @@ +package mongorbacs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoRoleDefinitionListResult struct { + Value *[]MongoRoleDefinitionGetResults `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongoroledefinitionresource.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongoroledefinitionresource.go new file mode 100644 index 00000000000..e55975c07c7 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongoroledefinitionresource.go @@ -0,0 +1,12 @@ +package mongorbacs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoRoleDefinitionResource struct { + DatabaseName *string `json:"databaseName,omitempty"` + Privileges *[]Privilege `json:"privileges,omitempty"` + RoleName *string `json:"roleName,omitempty"` + Roles *[]Role `json:"roles,omitempty"` + Type *MongoRoleDefinitionType `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongouserdefinitioncreateupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongouserdefinitioncreateupdateparameters.go new file mode 100644 index 00000000000..4430399a6f8 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongouserdefinitioncreateupdateparameters.go @@ -0,0 +1,8 @@ +package mongorbacs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoUserDefinitionCreateUpdateParameters struct { + Properties *MongoUserDefinitionResource `json:"properties,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongouserdefinitiongetresults.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongouserdefinitiongetresults.go new file mode 100644 index 00000000000..498a8ec3455 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongouserdefinitiongetresults.go @@ -0,0 +1,11 @@ +package mongorbacs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoUserDefinitionGetResults struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MongoUserDefinitionResource `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongouserdefinitionlistresult.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongouserdefinitionlistresult.go new file mode 100644 index 00000000000..ccc763d54ad --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongouserdefinitionlistresult.go @@ -0,0 +1,8 @@ +package mongorbacs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoUserDefinitionListResult struct { + Value *[]MongoUserDefinitionGetResults `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongouserdefinitionresource.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongouserdefinitionresource.go new file mode 100644 index 00000000000..c5eb08adadb --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_mongouserdefinitionresource.go @@ -0,0 +1,13 @@ +package mongorbacs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MongoUserDefinitionResource struct { + CustomData *string `json:"customData,omitempty"` + DatabaseName *string `json:"databaseName,omitempty"` + Mechanisms *string `json:"mechanisms,omitempty"` + Password *string `json:"password,omitempty"` + Roles *[]Role `json:"roles,omitempty"` + UserName *string `json:"userName,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_privilege.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_privilege.go new file mode 100644 index 00000000000..d80b1fb82c5 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_privilege.go @@ -0,0 +1,9 @@ +package mongorbacs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Privilege struct { + Actions *[]string `json:"actions,omitempty"` + Resource *PrivilegeResource `json:"resource,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_privilegeresource.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_privilegeresource.go new file mode 100644 index 00000000000..49dacb847d4 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_privilegeresource.go @@ -0,0 +1,9 @@ +package mongorbacs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivilegeResource struct { + Collection *string `json:"collection,omitempty"` + Db *string `json:"db,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_role.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_role.go new file mode 100644 index 00000000000..7152b8c9aa6 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/model_role.go @@ -0,0 +1,9 @@ +package mongorbacs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Role struct { + Db *string `json:"db,omitempty"` + Role *string `json:"role,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/mongorbacs/version.go b/resource-manager/cosmosdb/2024-11-15/mongorbacs/version.go new file mode 100644 index 00000000000..987570faadd --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/mongorbacs/version.go @@ -0,0 +1,10 @@ +package mongorbacs + +// 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-11-15" + +func userAgent() string { + return "hashicorp/go-azure-sdk/mongorbacs/2024-11-15" +} diff --git a/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/README.md b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/README.md new file mode 100644 index 00000000000..f4ebb983df5 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource` Documentation + +The `notebookworkspacesresource` SDK allows for interaction with Azure Resource Manager `cosmosdb` (API Version `2024-11-15`). + +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/cosmosdb/2024-11-15/notebookworkspacesresource" +``` + + +### Client Initialization + +```go +client := notebookworkspacesresource.NewNotebookWorkspacesResourceClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NotebookWorkspacesResourceClient.NotebookWorkspacesCreateOrUpdate` + +```go +ctx := context.TODO() +id := notebookworkspacesresource.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +payload := notebookworkspacesresource.ARMProxyResource{ + // ... +} + + +if err := client.NotebookWorkspacesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NotebookWorkspacesResourceClient.NotebookWorkspacesDelete` + +```go +ctx := context.TODO() +id := notebookworkspacesresource.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +if err := client.NotebookWorkspacesDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NotebookWorkspacesResourceClient.NotebookWorkspacesGet` + +```go +ctx := context.TODO() +id := notebookworkspacesresource.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.NotebookWorkspacesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NotebookWorkspacesResourceClient.NotebookWorkspacesListByDatabaseAccount` + +```go +ctx := context.TODO() +id := notebookworkspacesresource.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.NotebookWorkspacesListByDatabaseAccount(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NotebookWorkspacesResourceClient.NotebookWorkspacesListConnectionInfo` + +```go +ctx := context.TODO() +id := notebookworkspacesresource.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.NotebookWorkspacesListConnectionInfo(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NotebookWorkspacesResourceClient.NotebookWorkspacesRegenerateAuthToken` + +```go +ctx := context.TODO() +id := notebookworkspacesresource.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +if err := client.NotebookWorkspacesRegenerateAuthTokenThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NotebookWorkspacesResourceClient.NotebookWorkspacesStart` + +```go +ctx := context.TODO() +id := notebookworkspacesresource.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +if err := client.NotebookWorkspacesStartThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/client.go b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/client.go new file mode 100644 index 00000000000..b14ff9f0d18 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/client.go @@ -0,0 +1,26 @@ +package notebookworkspacesresource + +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 NotebookWorkspacesResourceClient struct { + Client *resourcemanager.Client +} + +func NewNotebookWorkspacesResourceClientWithBaseURI(sdkApi sdkEnv.Api) (*NotebookWorkspacesResourceClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "notebookworkspacesresource", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NotebookWorkspacesResourceClient: %+v", err) + } + + return &NotebookWorkspacesResourceClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/id_databaseaccount.go b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/id_databaseaccount.go new file mode 100644 index 00000000000..48f82ab040b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/id_databaseaccount.go @@ -0,0 +1,130 @@ +package notebookworkspacesresource + +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(&DatabaseAccountId{}) +} + +var _ resourceids.ResourceId = &DatabaseAccountId{} + +// DatabaseAccountId is a struct representing the Resource ID for a Database Account +type DatabaseAccountId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string +} + +// NewDatabaseAccountID returns a new DatabaseAccountId struct +func NewDatabaseAccountID(subscriptionId string, resourceGroupName string, databaseAccountName string) DatabaseAccountId { + return DatabaseAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + } +} + +// ParseDatabaseAccountID parses 'input' into a DatabaseAccountId +func ParseDatabaseAccountID(input string) (*DatabaseAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDatabaseAccountIDInsensitively parses 'input' case-insensitively into a DatabaseAccountId +// note: this method should only be used for API response data and not user input +func ParseDatabaseAccountIDInsensitively(input string) (*DatabaseAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DatabaseAccountId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + return nil +} + +// ValidateDatabaseAccountID checks that 'input' can be parsed as a Database Account ID +func ValidateDatabaseAccountID(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 := ParseDatabaseAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Database Account ID +func (id DatabaseAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Database Account ID +func (id DatabaseAccountId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + } +} + +// String returns a human-readable description of this Database Account ID +func (id DatabaseAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + } + return fmt.Sprintf("Database Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/id_databaseaccount_test.go b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/id_databaseaccount_test.go new file mode 100644 index 00000000000..4b238cf57bd --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/id_databaseaccount_test.go @@ -0,0 +1,282 @@ +package notebookworkspacesresource + +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 = &DatabaseAccountId{} + +func TestNewDatabaseAccountID(t *testing.T) { + id := NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } +} + +func TestFormatDatabaseAccountID(t *testing.T) { + actual := NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDatabaseAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Expected: &DatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseAccountID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + } +} + +func TestParseDatabaseAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Expected: &DatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Expected: &DatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseAccountIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + } +} + +func TestSegmentsForDatabaseAccountId(t *testing.T) { + segments := DatabaseAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DatabaseAccountId 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/cosmosdb/2024-11-15/notebookworkspacesresource/method_notebookworkspacescreateorupdate.go b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/method_notebookworkspacescreateorupdate.go new file mode 100644 index 00000000000..cd09baed5c2 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/method_notebookworkspacescreateorupdate.go @@ -0,0 +1,74 @@ +package notebookworkspacesresource + +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 NotebookWorkspacesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NotebookWorkspace +} + +// NotebookWorkspacesCreateOrUpdate ... +func (c NotebookWorkspacesResourceClient) NotebookWorkspacesCreateOrUpdate(ctx context.Context, id DatabaseAccountId, input ARMProxyResource) (result NotebookWorkspacesCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/notebookWorkspaces/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 +} + +// NotebookWorkspacesCreateOrUpdateThenPoll performs NotebookWorkspacesCreateOrUpdate then polls until it's completed +func (c NotebookWorkspacesResourceClient) NotebookWorkspacesCreateOrUpdateThenPoll(ctx context.Context, id DatabaseAccountId, input ARMProxyResource) error { + result, err := c.NotebookWorkspacesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing NotebookWorkspacesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after NotebookWorkspacesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/method_notebookworkspacesdelete.go b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/method_notebookworkspacesdelete.go new file mode 100644 index 00000000000..7e8978a6c1e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/method_notebookworkspacesdelete.go @@ -0,0 +1,70 @@ +package notebookworkspacesresource + +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 NotebookWorkspacesDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// NotebookWorkspacesDelete ... +func (c NotebookWorkspacesResourceClient) NotebookWorkspacesDelete(ctx context.Context, id DatabaseAccountId) (result NotebookWorkspacesDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/notebookWorkspaces/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 +} + +// NotebookWorkspacesDeleteThenPoll performs NotebookWorkspacesDelete then polls until it's completed +func (c NotebookWorkspacesResourceClient) NotebookWorkspacesDeleteThenPoll(ctx context.Context, id DatabaseAccountId) error { + result, err := c.NotebookWorkspacesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing NotebookWorkspacesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after NotebookWorkspacesDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/method_notebookworkspacesget.go b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/method_notebookworkspacesget.go new file mode 100644 index 00000000000..1d735eaef17 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/method_notebookworkspacesget.go @@ -0,0 +1,54 @@ +package notebookworkspacesresource + +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 NotebookWorkspacesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NotebookWorkspace +} + +// NotebookWorkspacesGet ... +func (c NotebookWorkspacesResourceClient) NotebookWorkspacesGet(ctx context.Context, id DatabaseAccountId) (result NotebookWorkspacesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/notebookWorkspaces/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 NotebookWorkspace + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/method_notebookworkspaceslistbydatabaseaccount.go b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/method_notebookworkspaceslistbydatabaseaccount.go new file mode 100644 index 00000000000..31991adb685 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/method_notebookworkspaceslistbydatabaseaccount.go @@ -0,0 +1,54 @@ +package notebookworkspacesresource + +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 NotebookWorkspacesListByDatabaseAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NotebookWorkspaceListResult +} + +// NotebookWorkspacesListByDatabaseAccount ... +func (c NotebookWorkspacesResourceClient) NotebookWorkspacesListByDatabaseAccount(ctx context.Context, id DatabaseAccountId) (result NotebookWorkspacesListByDatabaseAccountOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/notebookWorkspaces", 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 NotebookWorkspaceListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/method_notebookworkspaceslistconnectioninfo.go b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/method_notebookworkspaceslistconnectioninfo.go new file mode 100644 index 00000000000..178c432112d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/method_notebookworkspaceslistconnectioninfo.go @@ -0,0 +1,54 @@ +package notebookworkspacesresource + +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 NotebookWorkspacesListConnectionInfoOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NotebookWorkspaceConnectionInfoResult +} + +// NotebookWorkspacesListConnectionInfo ... +func (c NotebookWorkspacesResourceClient) NotebookWorkspacesListConnectionInfo(ctx context.Context, id DatabaseAccountId) (result NotebookWorkspacesListConnectionInfoOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/notebookWorkspaces/default/listConnectionInfo", 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 NotebookWorkspaceConnectionInfoResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/method_notebookworkspacesregenerateauthtoken.go b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/method_notebookworkspacesregenerateauthtoken.go new file mode 100644 index 00000000000..76ddbbbd59f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/method_notebookworkspacesregenerateauthtoken.go @@ -0,0 +1,70 @@ +package notebookworkspacesresource + +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 NotebookWorkspacesRegenerateAuthTokenOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// NotebookWorkspacesRegenerateAuthToken ... +func (c NotebookWorkspacesResourceClient) NotebookWorkspacesRegenerateAuthToken(ctx context.Context, id DatabaseAccountId) (result NotebookWorkspacesRegenerateAuthTokenOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/notebookWorkspaces/default/regenerateAuthToken", 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 +} + +// NotebookWorkspacesRegenerateAuthTokenThenPoll performs NotebookWorkspacesRegenerateAuthToken then polls until it's completed +func (c NotebookWorkspacesResourceClient) NotebookWorkspacesRegenerateAuthTokenThenPoll(ctx context.Context, id DatabaseAccountId) error { + result, err := c.NotebookWorkspacesRegenerateAuthToken(ctx, id) + if err != nil { + return fmt.Errorf("performing NotebookWorkspacesRegenerateAuthToken: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after NotebookWorkspacesRegenerateAuthToken: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/method_notebookworkspacesstart.go b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/method_notebookworkspacesstart.go new file mode 100644 index 00000000000..c9e893b0a2c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/method_notebookworkspacesstart.go @@ -0,0 +1,70 @@ +package notebookworkspacesresource + +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 NotebookWorkspacesStartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// NotebookWorkspacesStart ... +func (c NotebookWorkspacesResourceClient) NotebookWorkspacesStart(ctx context.Context, id DatabaseAccountId) (result NotebookWorkspacesStartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/notebookWorkspaces/default/start", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// NotebookWorkspacesStartThenPoll performs NotebookWorkspacesStart then polls until it's completed +func (c NotebookWorkspacesResourceClient) NotebookWorkspacesStartThenPoll(ctx context.Context, id DatabaseAccountId) error { + result, err := c.NotebookWorkspacesStart(ctx, id) + if err != nil { + return fmt.Errorf("performing NotebookWorkspacesStart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after NotebookWorkspacesStart: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/model_armproxyresource.go b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/model_armproxyresource.go new file mode 100644 index 00000000000..f0d50a87561 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/model_armproxyresource.go @@ -0,0 +1,10 @@ +package notebookworkspacesresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ARMProxyResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/model_notebookworkspace.go b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/model_notebookworkspace.go new file mode 100644 index 00000000000..e1a88f7f5e1 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/model_notebookworkspace.go @@ -0,0 +1,11 @@ +package notebookworkspacesresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NotebookWorkspace struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NotebookWorkspaceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/model_notebookworkspaceconnectioninforesult.go b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/model_notebookworkspaceconnectioninforesult.go new file mode 100644 index 00000000000..075a0e3eca2 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/model_notebookworkspaceconnectioninforesult.go @@ -0,0 +1,9 @@ +package notebookworkspacesresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NotebookWorkspaceConnectionInfoResult struct { + AuthToken *string `json:"authToken,omitempty"` + NotebookServerEndpoint *string `json:"notebookServerEndpoint,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/model_notebookworkspacelistresult.go b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/model_notebookworkspacelistresult.go new file mode 100644 index 00000000000..aa3644443b8 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/model_notebookworkspacelistresult.go @@ -0,0 +1,8 @@ +package notebookworkspacesresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NotebookWorkspaceListResult struct { + Value *[]NotebookWorkspace `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/model_notebookworkspaceproperties.go b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/model_notebookworkspaceproperties.go new file mode 100644 index 00000000000..812d5a6d55a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/model_notebookworkspaceproperties.go @@ -0,0 +1,9 @@ +package notebookworkspacesresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NotebookWorkspaceProperties struct { + NotebookServerEndpoint *string `json:"notebookServerEndpoint,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/version.go b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/version.go new file mode 100644 index 00000000000..2a05550e644 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/notebookworkspacesresource/version.go @@ -0,0 +1,10 @@ +package notebookworkspacesresource + +// 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-11-15" + +func userAgent() string { + return "hashicorp/go-azure-sdk/notebookworkspacesresource/2024-11-15" +} diff --git a/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/README.md b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/README.md new file mode 100644 index 00000000000..e8bfa8adbc0 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/README.md @@ -0,0 +1,81 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/privateendpointconnections` Documentation + +The `privateendpointconnections` SDK allows for interaction with Azure Resource Manager `cosmosdb` (API Version `2024-11-15`). + +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/cosmosdb/2024-11-15/privateendpointconnections" +``` + + +### Client Initialization + +```go +client := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "privateEndpointConnectionName") + +payload := privateendpointconnections.PrivateEndpointConnection{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.Delete` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "privateEndpointConnectionName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.Get` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "privateEndpointConnectionName") + +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: `PrivateEndpointConnectionsClient.ListByDatabaseAccount` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.ListByDatabaseAccount(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/client.go b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/client.go new file mode 100644 index 00000000000..50eaf09dcce --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/client.go @@ -0,0 +1,26 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionsClient struct { + Client *resourcemanager.Client +} + +func NewPrivateEndpointConnectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*PrivateEndpointConnectionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "privateendpointconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateEndpointConnectionsClient: %+v", err) + } + + return &PrivateEndpointConnectionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/id_databaseaccount.go b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/id_databaseaccount.go new file mode 100644 index 00000000000..0ef32fef9c1 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/id_databaseaccount.go @@ -0,0 +1,130 @@ +package privateendpointconnections + +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(&DatabaseAccountId{}) +} + +var _ resourceids.ResourceId = &DatabaseAccountId{} + +// DatabaseAccountId is a struct representing the Resource ID for a Database Account +type DatabaseAccountId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string +} + +// NewDatabaseAccountID returns a new DatabaseAccountId struct +func NewDatabaseAccountID(subscriptionId string, resourceGroupName string, databaseAccountName string) DatabaseAccountId { + return DatabaseAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + } +} + +// ParseDatabaseAccountID parses 'input' into a DatabaseAccountId +func ParseDatabaseAccountID(input string) (*DatabaseAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDatabaseAccountIDInsensitively parses 'input' case-insensitively into a DatabaseAccountId +// note: this method should only be used for API response data and not user input +func ParseDatabaseAccountIDInsensitively(input string) (*DatabaseAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DatabaseAccountId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + return nil +} + +// ValidateDatabaseAccountID checks that 'input' can be parsed as a Database Account ID +func ValidateDatabaseAccountID(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 := ParseDatabaseAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Database Account ID +func (id DatabaseAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Database Account ID +func (id DatabaseAccountId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + } +} + +// String returns a human-readable description of this Database Account ID +func (id DatabaseAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + } + return fmt.Sprintf("Database Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/id_databaseaccount_test.go b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/id_databaseaccount_test.go new file mode 100644 index 00000000000..fe0be2f9ad1 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/id_databaseaccount_test.go @@ -0,0 +1,282 @@ +package privateendpointconnections + +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 = &DatabaseAccountId{} + +func TestNewDatabaseAccountID(t *testing.T) { + id := NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } +} + +func TestFormatDatabaseAccountID(t *testing.T) { + actual := NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDatabaseAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Expected: &DatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseAccountID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + } +} + +func TestParseDatabaseAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Expected: &DatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Expected: &DatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseAccountIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + } +} + +func TestSegmentsForDatabaseAccountId(t *testing.T) { + segments := DatabaseAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DatabaseAccountId 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/cosmosdb/2024-11-15/privateendpointconnections/id_privateendpointconnection.go b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/id_privateendpointconnection.go new file mode 100644 index 00000000000..ad4cd96d133 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/id_privateendpointconnection.go @@ -0,0 +1,139 @@ +package privateendpointconnections + +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(&PrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection +type PrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, databaseAccountName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId +func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateEndpointConnectionId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID +func ValidatePrivateEndpointConnectionID(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 := ParsePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionName"), + } +} + +// String returns a human-readable description of this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/id_privateendpointconnection_test.go b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..6f7f6251e0b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/id_privateendpointconnection_test.go @@ -0,0 +1,327 @@ +package privateendpointconnections + +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 = &PrivateEndpointConnectionId{} + +func TestNewPrivateEndpointConnectionID(t *testing.T) { + id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "privateEndpointConnectionName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionName") + } +} + +func TestFormatPrivateEndpointConnectionID(t *testing.T) { + actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "privateEndpointConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/privateEndpointConnections/privateEndpointConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParsePrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { + segments := PrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateEndpointConnectionId 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/cosmosdb/2024-11-15/privateendpointconnections/method_createorupdate.go b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/method_createorupdate.go new file mode 100644 index 00000000000..943007e4641 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/method_createorupdate.go @@ -0,0 +1,75 @@ +package privateendpointconnections + +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 *PrivateEndpointConnection +} + +// CreateOrUpdate ... +func (c PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 PrivateEndpointConnectionsClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) 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/cosmosdb/2024-11-15/privateendpointconnections/method_delete.go b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/method_delete.go new file mode 100644 index 00000000000..c80136ed33a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/method_delete.go @@ -0,0 +1,70 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionsClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (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 PrivateEndpointConnectionsClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) 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/cosmosdb/2024-11-15/privateendpointconnections/method_get.go b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/method_get.go new file mode 100644 index 00000000000..351242746d4 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/method_get.go @@ -0,0 +1,53 @@ +package privateendpointconnections + +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 *PrivateEndpointConnection +} + +// Get ... +func (c PrivateEndpointConnectionsClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (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 PrivateEndpointConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/method_listbydatabaseaccount.go b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/method_listbydatabaseaccount.go new file mode 100644 index 00000000000..a1df4f311aa --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/method_listbydatabaseaccount.go @@ -0,0 +1,54 @@ +package privateendpointconnections + +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 ListByDatabaseAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnectionListResult +} + +// ListByDatabaseAccount ... +func (c PrivateEndpointConnectionsClient) ListByDatabaseAccount(ctx context.Context, id DatabaseAccountId) (result ListByDatabaseAccountOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", 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 PrivateEndpointConnectionListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/model_privateendpointconnection.go b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/model_privateendpointconnection.go new file mode 100644 index 00000000000..fde7f4db0fc --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/model_privateendpointconnection.go @@ -0,0 +1,11 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/model_privateendpointconnectionlistresult.go b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/model_privateendpointconnectionlistresult.go new file mode 100644 index 00000000000..92a9ecb105a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/model_privateendpointconnectionlistresult.go @@ -0,0 +1,8 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionListResult struct { + Value *[]PrivateEndpointConnection `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/model_privateendpointconnectionproperties.go b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..32d0841076e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupId *string `json:"groupId,omitempty"` + PrivateEndpoint *PrivateEndpointProperty `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionStateProperty `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/model_privateendpointproperty.go b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/model_privateendpointproperty.go new file mode 100644 index 00000000000..b0b0ff18482 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/model_privateendpointproperty.go @@ -0,0 +1,8 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperty struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/model_privatelinkserviceconnectionstateproperty.go b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/model_privatelinkserviceconnectionstateproperty.go new file mode 100644 index 00000000000..7f85d6bf04f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/model_privatelinkserviceconnectionstateproperty.go @@ -0,0 +1,10 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionStateProperty struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/version.go b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/version.go new file mode 100644 index 00000000000..799a21e9ca1 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privateendpointconnections/version.go @@ -0,0 +1,10 @@ +package privateendpointconnections + +// 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-11-15" + +func userAgent() string { + return "hashicorp/go-azure-sdk/privateendpointconnections/2024-11-15" +} diff --git a/resource-manager/cosmosdb/2024-11-15/privatelinkresources/README.md b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/README.md new file mode 100644 index 00000000000..b7c5e627165 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/README.md @@ -0,0 +1,52 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/privatelinkresources` Documentation + +The `privatelinkresources` SDK allows for interaction with Azure Resource Manager `cosmosdb` (API Version `2024-11-15`). + +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/cosmosdb/2024-11-15/privatelinkresources" +``` + + +### Client Initialization + +```go +client := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateLinkResourcesClient.Get` + +```go +ctx := context.TODO() +id := privatelinkresources.NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "privateLinkResourceName") + +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: `PrivateLinkResourcesClient.ListByDatabaseAccount` + +```go +ctx := context.TODO() +id := privatelinkresources.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.ListByDatabaseAccount(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/cosmosdb/2024-11-15/privatelinkresources/client.go b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/client.go new file mode 100644 index 00000000000..28c00b21f03 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/client.go @@ -0,0 +1,26 @@ +package privatelinkresources + +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 PrivateLinkResourcesClient struct { + Client *resourcemanager.Client +} + +func NewPrivateLinkResourcesClientWithBaseURI(sdkApi sdkEnv.Api) (*PrivateLinkResourcesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "privatelinkresources", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateLinkResourcesClient: %+v", err) + } + + return &PrivateLinkResourcesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/privatelinkresources/id_databaseaccount.go b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/id_databaseaccount.go new file mode 100644 index 00000000000..09df5d78d9d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/id_databaseaccount.go @@ -0,0 +1,130 @@ +package privatelinkresources + +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(&DatabaseAccountId{}) +} + +var _ resourceids.ResourceId = &DatabaseAccountId{} + +// DatabaseAccountId is a struct representing the Resource ID for a Database Account +type DatabaseAccountId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string +} + +// NewDatabaseAccountID returns a new DatabaseAccountId struct +func NewDatabaseAccountID(subscriptionId string, resourceGroupName string, databaseAccountName string) DatabaseAccountId { + return DatabaseAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + } +} + +// ParseDatabaseAccountID parses 'input' into a DatabaseAccountId +func ParseDatabaseAccountID(input string) (*DatabaseAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDatabaseAccountIDInsensitively parses 'input' case-insensitively into a DatabaseAccountId +// note: this method should only be used for API response data and not user input +func ParseDatabaseAccountIDInsensitively(input string) (*DatabaseAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DatabaseAccountId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + return nil +} + +// ValidateDatabaseAccountID checks that 'input' can be parsed as a Database Account ID +func ValidateDatabaseAccountID(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 := ParseDatabaseAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Database Account ID +func (id DatabaseAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Database Account ID +func (id DatabaseAccountId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + } +} + +// String returns a human-readable description of this Database Account ID +func (id DatabaseAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + } + return fmt.Sprintf("Database Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/privatelinkresources/id_databaseaccount_test.go b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/id_databaseaccount_test.go new file mode 100644 index 00000000000..aa4eb501a97 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/id_databaseaccount_test.go @@ -0,0 +1,282 @@ +package privatelinkresources + +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 = &DatabaseAccountId{} + +func TestNewDatabaseAccountID(t *testing.T) { + id := NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } +} + +func TestFormatDatabaseAccountID(t *testing.T) { + actual := NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDatabaseAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Expected: &DatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseAccountID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + } +} + +func TestParseDatabaseAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Expected: &DatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Expected: &DatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseAccountIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + } +} + +func TestSegmentsForDatabaseAccountId(t *testing.T) { + segments := DatabaseAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DatabaseAccountId 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/cosmosdb/2024-11-15/privatelinkresources/id_privatelinkresource.go b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/id_privatelinkresource.go new file mode 100644 index 00000000000..22240869721 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/id_privatelinkresource.go @@ -0,0 +1,139 @@ +package privatelinkresources + +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(&PrivateLinkResourceId{}) +} + +var _ resourceids.ResourceId = &PrivateLinkResourceId{} + +// PrivateLinkResourceId is a struct representing the Resource ID for a Private Link Resource +type PrivateLinkResourceId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + PrivateLinkResourceName string +} + +// NewPrivateLinkResourceID returns a new PrivateLinkResourceId struct +func NewPrivateLinkResourceID(subscriptionId string, resourceGroupName string, databaseAccountName string, privateLinkResourceName string) PrivateLinkResourceId { + return PrivateLinkResourceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + PrivateLinkResourceName: privateLinkResourceName, + } +} + +// ParsePrivateLinkResourceID parses 'input' into a PrivateLinkResourceId +func ParsePrivateLinkResourceID(input string) (*PrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateLinkResourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateLinkResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateLinkResourceIDInsensitively parses 'input' case-insensitively into a PrivateLinkResourceId +// note: this method should only be used for API response data and not user input +func ParsePrivateLinkResourceIDInsensitively(input string) (*PrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateLinkResourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateLinkResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateLinkResourceId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.PrivateLinkResourceName, ok = input.Parsed["privateLinkResourceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateLinkResourceName", input) + } + + return nil +} + +// ValidatePrivateLinkResourceID checks that 'input' can be parsed as a Private Link Resource ID +func ValidatePrivateLinkResourceID(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 := ParsePrivateLinkResourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Link Resource ID +func (id PrivateLinkResourceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/privateLinkResources/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.PrivateLinkResourceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Link Resource ID +func (id PrivateLinkResourceId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticPrivateLinkResources", "privateLinkResources", "privateLinkResources"), + resourceids.UserSpecifiedSegment("privateLinkResourceName", "privateLinkResourceName"), + } +} + +// String returns a human-readable description of this Private Link Resource ID +func (id PrivateLinkResourceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Private Link Resource Name: %q", id.PrivateLinkResourceName), + } + return fmt.Sprintf("Private Link Resource (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/privatelinkresources/id_privatelinkresource_test.go b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/id_privatelinkresource_test.go new file mode 100644 index 00000000000..8994ca6277c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/id_privatelinkresource_test.go @@ -0,0 +1,327 @@ +package privatelinkresources + +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 = &PrivateLinkResourceId{} + +func TestNewPrivateLinkResourceID(t *testing.T) { + id := NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "privateLinkResourceName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.PrivateLinkResourceName != "privateLinkResourceName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateLinkResourceName'", id.PrivateLinkResourceName, "privateLinkResourceName") + } +} + +func TestFormatPrivateLinkResourceID(t *testing.T) { + actual := NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "privateLinkResourceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/privateLinkResources/privateLinkResourceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateLinkResourceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateLinkResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/privateLinkResources", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/privateLinkResources/privateLinkResourceName", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + PrivateLinkResourceName: "privateLinkResourceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/privateLinkResources/privateLinkResourceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateLinkResourceID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.PrivateLinkResourceName != v.Expected.PrivateLinkResourceName { + t.Fatalf("Expected %q but got %q for PrivateLinkResourceName", v.Expected.PrivateLinkResourceName, actual.PrivateLinkResourceName) + } + + } +} + +func TestParsePrivateLinkResourceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateLinkResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/privateLinkResources", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/pRiVaTeLiNkReSoUrCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/privateLinkResources/privateLinkResourceName", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + PrivateLinkResourceName: "privateLinkResourceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/privateLinkResources/privateLinkResourceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/pRiVaTeLiNkReSoUrCeS/pRiVaTeLiNkReSoUrCeNaMe", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + PrivateLinkResourceName: "pRiVaTeLiNkReSoUrCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/pRiVaTeLiNkReSoUrCeS/pRiVaTeLiNkReSoUrCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateLinkResourceIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.PrivateLinkResourceName != v.Expected.PrivateLinkResourceName { + t.Fatalf("Expected %q but got %q for PrivateLinkResourceName", v.Expected.PrivateLinkResourceName, actual.PrivateLinkResourceName) + } + + } +} + +func TestSegmentsForPrivateLinkResourceId(t *testing.T) { + segments := PrivateLinkResourceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateLinkResourceId 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/cosmosdb/2024-11-15/privatelinkresources/method_get.go b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/method_get.go new file mode 100644 index 00000000000..4fe26146181 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/method_get.go @@ -0,0 +1,53 @@ +package privatelinkresources + +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 *PrivateLinkResource +} + +// Get ... +func (c PrivateLinkResourcesClient) Get(ctx context.Context, id PrivateLinkResourceId) (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 PrivateLinkResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/privatelinkresources/method_listbydatabaseaccount.go b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/method_listbydatabaseaccount.go new file mode 100644 index 00000000000..3d60391808b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/method_listbydatabaseaccount.go @@ -0,0 +1,54 @@ +package privatelinkresources + +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 ListByDatabaseAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourceListResult +} + +// ListByDatabaseAccount ... +func (c PrivateLinkResourcesClient) ListByDatabaseAccount(ctx context.Context, id DatabaseAccountId) (result ListByDatabaseAccountOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", 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 PrivateLinkResourceListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/privatelinkresources/model_privatelinkresource.go b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/model_privatelinkresource.go new file mode 100644 index 00000000000..69e8ae0e57a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/model_privatelinkresource.go @@ -0,0 +1,11 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/privatelinkresources/model_privatelinkresourcelistresult.go b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/model_privatelinkresourcelistresult.go new file mode 100644 index 00000000000..fa950217c47 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/model_privatelinkresourcelistresult.go @@ -0,0 +1,8 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceListResult struct { + Value *[]PrivateLinkResource `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/privatelinkresources/model_privatelinkresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..3c98012cdd1 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/model_privatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/privatelinkresources/version.go b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/version.go new file mode 100644 index 00000000000..64a025673fc --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/privatelinkresources/version.go @@ -0,0 +1,10 @@ +package privatelinkresources + +// 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-11-15" + +func userAgent() string { + return "hashicorp/go-azure-sdk/privatelinkresources/2024-11-15" +} diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/README.md b/resource-manager/cosmosdb/2024-11-15/rbacs/README.md new file mode 100644 index 00000000000..8cf36e4bf49 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/README.md @@ -0,0 +1,142 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/rbacs` Documentation + +The `rbacs` SDK allows for interaction with Azure Resource Manager `cosmosdb` (API Version `2024-11-15`). + +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/cosmosdb/2024-11-15/rbacs" +``` + + +### Client Initialization + +```go +client := rbacs.NewRbacsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RbacsClient.SqlResourcesCreateUpdateSqlRoleAssignment` + +```go +ctx := context.TODO() +id := rbacs.NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +payload := rbacs.SqlRoleAssignmentCreateUpdateParameters{ + // ... +} + + +if err := client.SqlResourcesCreateUpdateSqlRoleAssignmentThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `RbacsClient.SqlResourcesCreateUpdateSqlRoleDefinition` + +```go +ctx := context.TODO() +id := rbacs.NewSqlRoleDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "roleDefinitionId") + +payload := rbacs.SqlRoleDefinitionCreateUpdateParameters{ + // ... +} + + +if err := client.SqlResourcesCreateUpdateSqlRoleDefinitionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `RbacsClient.SqlResourcesDeleteSqlRoleAssignment` + +```go +ctx := context.TODO() +id := rbacs.NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +if err := client.SqlResourcesDeleteSqlRoleAssignmentThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `RbacsClient.SqlResourcesDeleteSqlRoleDefinition` + +```go +ctx := context.TODO() +id := rbacs.NewSqlRoleDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "roleDefinitionId") + +if err := client.SqlResourcesDeleteSqlRoleDefinitionThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `RbacsClient.SqlResourcesGetSqlRoleAssignment` + +```go +ctx := context.TODO() +id := rbacs.NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +read, err := client.SqlResourcesGetSqlRoleAssignment(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RbacsClient.SqlResourcesGetSqlRoleDefinition` + +```go +ctx := context.TODO() +id := rbacs.NewSqlRoleDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "roleDefinitionId") + +read, err := client.SqlResourcesGetSqlRoleDefinition(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RbacsClient.SqlResourcesListSqlRoleAssignments` + +```go +ctx := context.TODO() +id := rbacs.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.SqlResourcesListSqlRoleAssignments(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RbacsClient.SqlResourcesListSqlRoleDefinitions` + +```go +ctx := context.TODO() +id := rbacs.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.SqlResourcesListSqlRoleDefinitions(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/client.go b/resource-manager/cosmosdb/2024-11-15/rbacs/client.go new file mode 100644 index 00000000000..9cefbe649f1 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/client.go @@ -0,0 +1,26 @@ +package rbacs + +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 RbacsClient struct { + Client *resourcemanager.Client +} + +func NewRbacsClientWithBaseURI(sdkApi sdkEnv.Api) (*RbacsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "rbacs", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RbacsClient: %+v", err) + } + + return &RbacsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/constants.go b/resource-manager/cosmosdb/2024-11-15/rbacs/constants.go new file mode 100644 index 00000000000..cd3d7b42489 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/constants.go @@ -0,0 +1,51 @@ +package rbacs + +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 RoleDefinitionType string + +const ( + RoleDefinitionTypeBuiltInRole RoleDefinitionType = "BuiltInRole" + RoleDefinitionTypeCustomRole RoleDefinitionType = "CustomRole" +) + +func PossibleValuesForRoleDefinitionType() []string { + return []string{ + string(RoleDefinitionTypeBuiltInRole), + string(RoleDefinitionTypeCustomRole), + } +} + +func (s *RoleDefinitionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRoleDefinitionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRoleDefinitionType(input string) (*RoleDefinitionType, error) { + vals := map[string]RoleDefinitionType{ + "builtinrole": RoleDefinitionTypeBuiltInRole, + "customrole": RoleDefinitionTypeCustomRole, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RoleDefinitionType(input) + return &out, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/id_account.go b/resource-manager/cosmosdb/2024-11-15/rbacs/id_account.go new file mode 100644 index 00000000000..2fd416725b1 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/id_account.go @@ -0,0 +1,139 @@ +package rbacs + +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(&AccountId{}) +} + +var _ resourceids.ResourceId = &AccountId{} + +// AccountId is a struct representing the Resource ID for a Account +type AccountId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + RoleAssignmentId string +} + +// NewAccountID returns a new AccountId struct +func NewAccountID(subscriptionId string, resourceGroupName string, databaseAccountName string, roleAssignmentId string) AccountId { + return AccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + RoleAssignmentId: roleAssignmentId, + } +} + +// ParseAccountID parses 'input' into a AccountId +func ParseAccountID(input string) (*AccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&AccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAccountIDInsensitively parses 'input' case-insensitively into a AccountId +// note: this method should only be used for API response data and not user input +func ParseAccountIDInsensitively(input string) (*AccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&AccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AccountId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.RoleAssignmentId, ok = input.Parsed["roleAssignmentId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "roleAssignmentId", input) + } + + return nil +} + +// ValidateAccountID checks that 'input' can be parsed as a Account ID +func ValidateAccountID(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 := ParseAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Account ID +func (id AccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/sqlRoleAssignments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, strings.TrimPrefix(id.RoleAssignmentId, "/")) +} + +// Segments returns a slice of Resource ID Segments which comprise this Account ID +func (id AccountId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticSqlRoleAssignments", "sqlRoleAssignments", "sqlRoleAssignments"), + resourceids.ScopeSegment("roleAssignmentId", "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group"), + } +} + +// String returns a human-readable description of this Account ID +func (id AccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Role Assignment: %q", id.RoleAssignmentId), + } + return fmt.Sprintf("Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/id_account_test.go b/resource-manager/cosmosdb/2024-11-15/rbacs/id_account_test.go new file mode 100644 index 00000000000..ad2c1bacfd4 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/id_account_test.go @@ -0,0 +1,312 @@ +package rbacs + +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 = &AccountId{} + +func TestNewAccountID(t *testing.T) { + id := NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.RoleAssignmentId != "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'RoleAssignmentId'", id.RoleAssignmentId, "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + } +} + +func TestFormatAccountID(t *testing.T) { + actual := NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlRoleAssignments/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlRoleAssignments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlRoleAssignments/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + Expected: &AccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + RoleAssignmentId: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + }, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAccountID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.RoleAssignmentId != v.Expected.RoleAssignmentId { + t.Fatalf("Expected %q but got %q for RoleAssignmentId", v.Expected.RoleAssignmentId, actual.RoleAssignmentId) + } + + } +} + +func TestParseAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlRoleAssignments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlRoLeAsSiGnMeNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlRoleAssignments/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + Expected: &AccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + RoleAssignmentId: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + }, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlRoLeAsSiGnMeNtS/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp", + Expected: &AccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + RoleAssignmentId: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp", + }, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAccountIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.RoleAssignmentId != v.Expected.RoleAssignmentId { + t.Fatalf("Expected %q but got %q for RoleAssignmentId", v.Expected.RoleAssignmentId, actual.RoleAssignmentId) + } + + } +} + +func TestSegmentsForAccountId(t *testing.T) { + segments := AccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AccountId 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/cosmosdb/2024-11-15/rbacs/id_databaseaccount.go b/resource-manager/cosmosdb/2024-11-15/rbacs/id_databaseaccount.go new file mode 100644 index 00000000000..eea55d3e517 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/id_databaseaccount.go @@ -0,0 +1,130 @@ +package rbacs + +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(&DatabaseAccountId{}) +} + +var _ resourceids.ResourceId = &DatabaseAccountId{} + +// DatabaseAccountId is a struct representing the Resource ID for a Database Account +type DatabaseAccountId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string +} + +// NewDatabaseAccountID returns a new DatabaseAccountId struct +func NewDatabaseAccountID(subscriptionId string, resourceGroupName string, databaseAccountName string) DatabaseAccountId { + return DatabaseAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + } +} + +// ParseDatabaseAccountID parses 'input' into a DatabaseAccountId +func ParseDatabaseAccountID(input string) (*DatabaseAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDatabaseAccountIDInsensitively parses 'input' case-insensitively into a DatabaseAccountId +// note: this method should only be used for API response data and not user input +func ParseDatabaseAccountIDInsensitively(input string) (*DatabaseAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DatabaseAccountId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + return nil +} + +// ValidateDatabaseAccountID checks that 'input' can be parsed as a Database Account ID +func ValidateDatabaseAccountID(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 := ParseDatabaseAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Database Account ID +func (id DatabaseAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Database Account ID +func (id DatabaseAccountId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + } +} + +// String returns a human-readable description of this Database Account ID +func (id DatabaseAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + } + return fmt.Sprintf("Database Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/id_databaseaccount_test.go b/resource-manager/cosmosdb/2024-11-15/rbacs/id_databaseaccount_test.go new file mode 100644 index 00000000000..85257d9182a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/id_databaseaccount_test.go @@ -0,0 +1,282 @@ +package rbacs + +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 = &DatabaseAccountId{} + +func TestNewDatabaseAccountID(t *testing.T) { + id := NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } +} + +func TestFormatDatabaseAccountID(t *testing.T) { + actual := NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDatabaseAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Expected: &DatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseAccountID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + } +} + +func TestParseDatabaseAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Expected: &DatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Expected: &DatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseAccountIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + } +} + +func TestSegmentsForDatabaseAccountId(t *testing.T) { + segments := DatabaseAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DatabaseAccountId 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/cosmosdb/2024-11-15/rbacs/id_sqlroledefinition.go b/resource-manager/cosmosdb/2024-11-15/rbacs/id_sqlroledefinition.go new file mode 100644 index 00000000000..fb415467ab6 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/id_sqlroledefinition.go @@ -0,0 +1,139 @@ +package rbacs + +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(&SqlRoleDefinitionId{}) +} + +var _ resourceids.ResourceId = &SqlRoleDefinitionId{} + +// SqlRoleDefinitionId is a struct representing the Resource ID for a Sql Role Definition +type SqlRoleDefinitionId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + RoleDefinitionId string +} + +// NewSqlRoleDefinitionID returns a new SqlRoleDefinitionId struct +func NewSqlRoleDefinitionID(subscriptionId string, resourceGroupName string, databaseAccountName string, roleDefinitionId string) SqlRoleDefinitionId { + return SqlRoleDefinitionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + RoleDefinitionId: roleDefinitionId, + } +} + +// ParseSqlRoleDefinitionID parses 'input' into a SqlRoleDefinitionId +func ParseSqlRoleDefinitionID(input string) (*SqlRoleDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SqlRoleDefinitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SqlRoleDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSqlRoleDefinitionIDInsensitively parses 'input' case-insensitively into a SqlRoleDefinitionId +// note: this method should only be used for API response data and not user input +func ParseSqlRoleDefinitionIDInsensitively(input string) (*SqlRoleDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SqlRoleDefinitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SqlRoleDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SqlRoleDefinitionId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.RoleDefinitionId, ok = input.Parsed["roleDefinitionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "roleDefinitionId", input) + } + + return nil +} + +// ValidateSqlRoleDefinitionID checks that 'input' can be parsed as a Sql Role Definition ID +func ValidateSqlRoleDefinitionID(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 := ParseSqlRoleDefinitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sql Role Definition ID +func (id SqlRoleDefinitionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/sqlRoleDefinitions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.RoleDefinitionId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sql Role Definition ID +func (id SqlRoleDefinitionId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticSqlRoleDefinitions", "sqlRoleDefinitions", "sqlRoleDefinitions"), + resourceids.UserSpecifiedSegment("roleDefinitionId", "roleDefinitionId"), + } +} + +// String returns a human-readable description of this Sql Role Definition ID +func (id SqlRoleDefinitionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Role Definition: %q", id.RoleDefinitionId), + } + return fmt.Sprintf("Sql Role Definition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/id_sqlroledefinition_test.go b/resource-manager/cosmosdb/2024-11-15/rbacs/id_sqlroledefinition_test.go new file mode 100644 index 00000000000..d5f64dcc134 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/id_sqlroledefinition_test.go @@ -0,0 +1,327 @@ +package rbacs + +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 = &SqlRoleDefinitionId{} + +func TestNewSqlRoleDefinitionID(t *testing.T) { + id := NewSqlRoleDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "roleDefinitionId") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.RoleDefinitionId != "roleDefinitionId" { + t.Fatalf("Expected %q but got %q for Segment 'RoleDefinitionId'", id.RoleDefinitionId, "roleDefinitionId") + } +} + +func TestFormatSqlRoleDefinitionID(t *testing.T) { + actual := NewSqlRoleDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "roleDefinitionId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlRoleDefinitions/roleDefinitionId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSqlRoleDefinitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SqlRoleDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlRoleDefinitions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlRoleDefinitions/roleDefinitionId", + Expected: &SqlRoleDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + RoleDefinitionId: "roleDefinitionId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlRoleDefinitions/roleDefinitionId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSqlRoleDefinitionID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.RoleDefinitionId != v.Expected.RoleDefinitionId { + t.Fatalf("Expected %q but got %q for RoleDefinitionId", v.Expected.RoleDefinitionId, actual.RoleDefinitionId) + } + + } +} + +func TestParseSqlRoleDefinitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SqlRoleDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlRoleDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlRoLeDeFiNiTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlRoleDefinitions/roleDefinitionId", + Expected: &SqlRoleDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + RoleDefinitionId: "roleDefinitionId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlRoleDefinitions/roleDefinitionId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlRoLeDeFiNiTiOnS/rOlEdEfInItIoNiD", + Expected: &SqlRoleDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + RoleDefinitionId: "rOlEdEfInItIoNiD", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlRoLeDeFiNiTiOnS/rOlEdEfInItIoNiD/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSqlRoleDefinitionIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.RoleDefinitionId != v.Expected.RoleDefinitionId { + t.Fatalf("Expected %q but got %q for RoleDefinitionId", v.Expected.RoleDefinitionId, actual.RoleDefinitionId) + } + + } +} + +func TestSegmentsForSqlRoleDefinitionId(t *testing.T) { + segments := SqlRoleDefinitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SqlRoleDefinitionId 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/cosmosdb/2024-11-15/rbacs/method_sqlresourcescreateupdatesqlroleassignment.go b/resource-manager/cosmosdb/2024-11-15/rbacs/method_sqlresourcescreateupdatesqlroleassignment.go new file mode 100644 index 00000000000..661fe68a256 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/method_sqlresourcescreateupdatesqlroleassignment.go @@ -0,0 +1,75 @@ +package rbacs + +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 SqlResourcesCreateUpdateSqlRoleAssignmentOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SqlRoleAssignmentGetResults +} + +// SqlResourcesCreateUpdateSqlRoleAssignment ... +func (c RbacsClient) SqlResourcesCreateUpdateSqlRoleAssignment(ctx context.Context, id AccountId, input SqlRoleAssignmentCreateUpdateParameters) (result SqlResourcesCreateUpdateSqlRoleAssignmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// SqlResourcesCreateUpdateSqlRoleAssignmentThenPoll performs SqlResourcesCreateUpdateSqlRoleAssignment then polls until it's completed +func (c RbacsClient) SqlResourcesCreateUpdateSqlRoleAssignmentThenPoll(ctx context.Context, id AccountId, input SqlRoleAssignmentCreateUpdateParameters) error { + result, err := c.SqlResourcesCreateUpdateSqlRoleAssignment(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SqlResourcesCreateUpdateSqlRoleAssignment: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SqlResourcesCreateUpdateSqlRoleAssignment: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/method_sqlresourcescreateupdatesqlroledefinition.go b/resource-manager/cosmosdb/2024-11-15/rbacs/method_sqlresourcescreateupdatesqlroledefinition.go new file mode 100644 index 00000000000..417071a8e0f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/method_sqlresourcescreateupdatesqlroledefinition.go @@ -0,0 +1,75 @@ +package rbacs + +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 SqlResourcesCreateUpdateSqlRoleDefinitionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SqlRoleDefinitionGetResults +} + +// SqlResourcesCreateUpdateSqlRoleDefinition ... +func (c RbacsClient) SqlResourcesCreateUpdateSqlRoleDefinition(ctx context.Context, id SqlRoleDefinitionId, input SqlRoleDefinitionCreateUpdateParameters) (result SqlResourcesCreateUpdateSqlRoleDefinitionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// SqlResourcesCreateUpdateSqlRoleDefinitionThenPoll performs SqlResourcesCreateUpdateSqlRoleDefinition then polls until it's completed +func (c RbacsClient) SqlResourcesCreateUpdateSqlRoleDefinitionThenPoll(ctx context.Context, id SqlRoleDefinitionId, input SqlRoleDefinitionCreateUpdateParameters) error { + result, err := c.SqlResourcesCreateUpdateSqlRoleDefinition(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SqlResourcesCreateUpdateSqlRoleDefinition: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SqlResourcesCreateUpdateSqlRoleDefinition: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/method_sqlresourcesdeletesqlroleassignment.go b/resource-manager/cosmosdb/2024-11-15/rbacs/method_sqlresourcesdeletesqlroleassignment.go new file mode 100644 index 00000000000..4e82837391d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/method_sqlresourcesdeletesqlroleassignment.go @@ -0,0 +1,71 @@ +package rbacs + +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 SqlResourcesDeleteSqlRoleAssignmentOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SqlResourcesDeleteSqlRoleAssignment ... +func (c RbacsClient) SqlResourcesDeleteSqlRoleAssignment(ctx context.Context, id AccountId) (result SqlResourcesDeleteSqlRoleAssignmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SqlResourcesDeleteSqlRoleAssignmentThenPoll performs SqlResourcesDeleteSqlRoleAssignment then polls until it's completed +func (c RbacsClient) SqlResourcesDeleteSqlRoleAssignmentThenPoll(ctx context.Context, id AccountId) error { + result, err := c.SqlResourcesDeleteSqlRoleAssignment(ctx, id) + if err != nil { + return fmt.Errorf("performing SqlResourcesDeleteSqlRoleAssignment: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SqlResourcesDeleteSqlRoleAssignment: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/method_sqlresourcesdeletesqlroledefinition.go b/resource-manager/cosmosdb/2024-11-15/rbacs/method_sqlresourcesdeletesqlroledefinition.go new file mode 100644 index 00000000000..f20835ad9d1 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/method_sqlresourcesdeletesqlroledefinition.go @@ -0,0 +1,71 @@ +package rbacs + +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 SqlResourcesDeleteSqlRoleDefinitionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SqlResourcesDeleteSqlRoleDefinition ... +func (c RbacsClient) SqlResourcesDeleteSqlRoleDefinition(ctx context.Context, id SqlRoleDefinitionId) (result SqlResourcesDeleteSqlRoleDefinitionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SqlResourcesDeleteSqlRoleDefinitionThenPoll performs SqlResourcesDeleteSqlRoleDefinition then polls until it's completed +func (c RbacsClient) SqlResourcesDeleteSqlRoleDefinitionThenPoll(ctx context.Context, id SqlRoleDefinitionId) error { + result, err := c.SqlResourcesDeleteSqlRoleDefinition(ctx, id) + if err != nil { + return fmt.Errorf("performing SqlResourcesDeleteSqlRoleDefinition: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SqlResourcesDeleteSqlRoleDefinition: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/method_sqlresourcesgetsqlroleassignment.go b/resource-manager/cosmosdb/2024-11-15/rbacs/method_sqlresourcesgetsqlroleassignment.go new file mode 100644 index 00000000000..1efc15a0de1 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/method_sqlresourcesgetsqlroleassignment.go @@ -0,0 +1,53 @@ +package rbacs + +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 SqlResourcesGetSqlRoleAssignmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SqlRoleAssignmentGetResults +} + +// SqlResourcesGetSqlRoleAssignment ... +func (c RbacsClient) SqlResourcesGetSqlRoleAssignment(ctx context.Context, id AccountId) (result SqlResourcesGetSqlRoleAssignmentOperationResponse, 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 SqlRoleAssignmentGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/method_sqlresourcesgetsqlroledefinition.go b/resource-manager/cosmosdb/2024-11-15/rbacs/method_sqlresourcesgetsqlroledefinition.go new file mode 100644 index 00000000000..b666f08154d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/method_sqlresourcesgetsqlroledefinition.go @@ -0,0 +1,53 @@ +package rbacs + +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 SqlResourcesGetSqlRoleDefinitionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SqlRoleDefinitionGetResults +} + +// SqlResourcesGetSqlRoleDefinition ... +func (c RbacsClient) SqlResourcesGetSqlRoleDefinition(ctx context.Context, id SqlRoleDefinitionId) (result SqlResourcesGetSqlRoleDefinitionOperationResponse, 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 SqlRoleDefinitionGetResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/method_sqlresourceslistsqlroleassignments.go b/resource-manager/cosmosdb/2024-11-15/rbacs/method_sqlresourceslistsqlroleassignments.go new file mode 100644 index 00000000000..9eb8653b0c6 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/method_sqlresourceslistsqlroleassignments.go @@ -0,0 +1,54 @@ +package rbacs + +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 SqlResourcesListSqlRoleAssignmentsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SqlRoleAssignmentListResult +} + +// SqlResourcesListSqlRoleAssignments ... +func (c RbacsClient) SqlResourcesListSqlRoleAssignments(ctx context.Context, id DatabaseAccountId) (result SqlResourcesListSqlRoleAssignmentsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sqlRoleAssignments", 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 SqlRoleAssignmentListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/method_sqlresourceslistsqlroledefinitions.go b/resource-manager/cosmosdb/2024-11-15/rbacs/method_sqlresourceslistsqlroledefinitions.go new file mode 100644 index 00000000000..7bb5cae75cd --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/method_sqlresourceslistsqlroledefinitions.go @@ -0,0 +1,54 @@ +package rbacs + +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 SqlResourcesListSqlRoleDefinitionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SqlRoleDefinitionListResult +} + +// SqlResourcesListSqlRoleDefinitions ... +func (c RbacsClient) SqlResourcesListSqlRoleDefinitions(ctx context.Context, id DatabaseAccountId) (result SqlResourcesListSqlRoleDefinitionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sqlRoleDefinitions", 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 SqlRoleDefinitionListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/model_permission.go b/resource-manager/cosmosdb/2024-11-15/rbacs/model_permission.go new file mode 100644 index 00000000000..24d9bca3c0a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/model_permission.go @@ -0,0 +1,9 @@ +package rbacs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Permission struct { + DataActions *[]string `json:"dataActions,omitempty"` + NotDataActions *[]string `json:"notDataActions,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroleassignmentcreateupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroleassignmentcreateupdateparameters.go new file mode 100644 index 00000000000..47669dad1e1 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroleassignmentcreateupdateparameters.go @@ -0,0 +1,8 @@ +package rbacs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlRoleAssignmentCreateUpdateParameters struct { + Properties *SqlRoleAssignmentResource `json:"properties,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroleassignmentgetresults.go b/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroleassignmentgetresults.go new file mode 100644 index 00000000000..0e5ca69111e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroleassignmentgetresults.go @@ -0,0 +1,11 @@ +package rbacs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlRoleAssignmentGetResults struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SqlRoleAssignmentResource `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroleassignmentlistresult.go b/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroleassignmentlistresult.go new file mode 100644 index 00000000000..2c06d7a8b6b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroleassignmentlistresult.go @@ -0,0 +1,8 @@ +package rbacs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlRoleAssignmentListResult struct { + Value *[]SqlRoleAssignmentGetResults `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroleassignmentresource.go b/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroleassignmentresource.go new file mode 100644 index 00000000000..d0fd52b9eba --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroleassignmentresource.go @@ -0,0 +1,10 @@ +package rbacs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlRoleAssignmentResource struct { + PrincipalId *string `json:"principalId,omitempty"` + RoleDefinitionId *string `json:"roleDefinitionId,omitempty"` + Scope *string `json:"scope,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroledefinitioncreateupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroledefinitioncreateupdateparameters.go new file mode 100644 index 00000000000..8730b9d84c2 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroledefinitioncreateupdateparameters.go @@ -0,0 +1,8 @@ +package rbacs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlRoleDefinitionCreateUpdateParameters struct { + Properties *SqlRoleDefinitionResource `json:"properties,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroledefinitiongetresults.go b/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroledefinitiongetresults.go new file mode 100644 index 00000000000..a4a1075a9d4 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroledefinitiongetresults.go @@ -0,0 +1,11 @@ +package rbacs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlRoleDefinitionGetResults struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SqlRoleDefinitionResource `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroledefinitionlistresult.go b/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroledefinitionlistresult.go new file mode 100644 index 00000000000..1ed45a2fbed --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroledefinitionlistresult.go @@ -0,0 +1,8 @@ +package rbacs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlRoleDefinitionListResult struct { + Value *[]SqlRoleDefinitionGetResults `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroledefinitionresource.go b/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroledefinitionresource.go new file mode 100644 index 00000000000..9cb98e76faa --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/model_sqlroledefinitionresource.go @@ -0,0 +1,11 @@ +package rbacs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlRoleDefinitionResource struct { + AssignableScopes *[]string `json:"assignableScopes,omitempty"` + Permissions *[]Permission `json:"permissions,omitempty"` + RoleName *string `json:"roleName,omitempty"` + Type *RoleDefinitionType `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/rbacs/version.go b/resource-manager/cosmosdb/2024-11-15/rbacs/version.go new file mode 100644 index 00000000000..3a7b36400b3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/rbacs/version.go @@ -0,0 +1,10 @@ +package rbacs + +// 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-11-15" + +func userAgent() string { + return "hashicorp/go-azure-sdk/rbacs/2024-11-15" +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/README.md b/resource-manager/cosmosdb/2024-11-15/restorables/README.md new file mode 100644 index 00000000000..10c7f4ac274 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/README.md @@ -0,0 +1,313 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/restorables` Documentation + +The `restorables` SDK allows for interaction with Azure Resource Manager `cosmosdb` (API Version `2024-11-15`). + +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/cosmosdb/2024-11-15/restorables" +``` + + +### Client Initialization + +```go +client := restorables.NewRestorablesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RestorablesClient.GremlinResourcesRetrieveContinuousBackupInformation` + +```go +ctx := context.TODO() +id := restorables.NewGraphID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "gremlinDatabaseName", "graphName") + +payload := restorables.ContinuousBackupRestoreLocation{ + // ... +} + + +if err := client.GremlinResourcesRetrieveContinuousBackupInformationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `RestorablesClient.MongoDBResourcesRetrieveContinuousBackupInformation` + +```go +ctx := context.TODO() +id := restorables.NewMongodbDatabaseCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongodbDatabaseName", "collectionName") + +payload := restorables.ContinuousBackupRestoreLocation{ + // ... +} + + +if err := client.MongoDBResourcesRetrieveContinuousBackupInformationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `RestorablesClient.RestorableDatabaseAccountsGetByLocation` + +```go +ctx := context.TODO() +id := restorables.NewRestorableDatabaseAccountID("12345678-1234-9876-4563-123456789012", "locationName", "instanceId") + +read, err := client.RestorableDatabaseAccountsGetByLocation(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RestorablesClient.RestorableDatabaseAccountsList` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.RestorableDatabaseAccountsList(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RestorablesClient.RestorableDatabaseAccountsListByLocation` + +```go +ctx := context.TODO() +id := restorables.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +read, err := client.RestorableDatabaseAccountsListByLocation(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RestorablesClient.RestorableGremlinDatabasesList` + +```go +ctx := context.TODO() +id := restorables.NewRestorableDatabaseAccountID("12345678-1234-9876-4563-123456789012", "locationName", "instanceId") + +read, err := client.RestorableGremlinDatabasesList(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RestorablesClient.RestorableGremlinGraphsList` + +```go +ctx := context.TODO() +id := restorables.NewRestorableDatabaseAccountID("12345678-1234-9876-4563-123456789012", "locationName", "instanceId") + +read, err := client.RestorableGremlinGraphsList(ctx, id, restorables.DefaultRestorableGremlinGraphsListOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RestorablesClient.RestorableGremlinResourcesList` + +```go +ctx := context.TODO() +id := restorables.NewRestorableDatabaseAccountID("12345678-1234-9876-4563-123456789012", "locationName", "instanceId") + +read, err := client.RestorableGremlinResourcesList(ctx, id, restorables.DefaultRestorableGremlinResourcesListOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RestorablesClient.RestorableMongodbCollectionsList` + +```go +ctx := context.TODO() +id := restorables.NewRestorableDatabaseAccountID("12345678-1234-9876-4563-123456789012", "locationName", "instanceId") + +read, err := client.RestorableMongodbCollectionsList(ctx, id, restorables.DefaultRestorableMongodbCollectionsListOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RestorablesClient.RestorableMongodbDatabasesList` + +```go +ctx := context.TODO() +id := restorables.NewRestorableDatabaseAccountID("12345678-1234-9876-4563-123456789012", "locationName", "instanceId") + +read, err := client.RestorableMongodbDatabasesList(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RestorablesClient.RestorableMongodbResourcesList` + +```go +ctx := context.TODO() +id := restorables.NewRestorableDatabaseAccountID("12345678-1234-9876-4563-123456789012", "locationName", "instanceId") + +read, err := client.RestorableMongodbResourcesList(ctx, id, restorables.DefaultRestorableMongodbResourcesListOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RestorablesClient.RestorableSqlContainersList` + +```go +ctx := context.TODO() +id := restorables.NewRestorableDatabaseAccountID("12345678-1234-9876-4563-123456789012", "locationName", "instanceId") + +read, err := client.RestorableSqlContainersList(ctx, id, restorables.DefaultRestorableSqlContainersListOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RestorablesClient.RestorableSqlDatabasesList` + +```go +ctx := context.TODO() +id := restorables.NewRestorableDatabaseAccountID("12345678-1234-9876-4563-123456789012", "locationName", "instanceId") + +read, err := client.RestorableSqlDatabasesList(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RestorablesClient.RestorableSqlResourcesList` + +```go +ctx := context.TODO() +id := restorables.NewRestorableDatabaseAccountID("12345678-1234-9876-4563-123456789012", "locationName", "instanceId") + +read, err := client.RestorableSqlResourcesList(ctx, id, restorables.DefaultRestorableSqlResourcesListOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RestorablesClient.RestorableTableResourcesList` + +```go +ctx := context.TODO() +id := restorables.NewRestorableDatabaseAccountID("12345678-1234-9876-4563-123456789012", "locationName", "instanceId") + +read, err := client.RestorableTableResourcesList(ctx, id, restorables.DefaultRestorableTableResourcesListOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RestorablesClient.RestorableTablesList` + +```go +ctx := context.TODO() +id := restorables.NewRestorableDatabaseAccountID("12345678-1234-9876-4563-123456789012", "locationName", "instanceId") + +read, err := client.RestorableTablesList(ctx, id, restorables.DefaultRestorableTablesListOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RestorablesClient.SqlResourcesRetrieveContinuousBackupInformation` + +```go +ctx := context.TODO() +id := restorables.NewContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName") + +payload := restorables.ContinuousBackupRestoreLocation{ + // ... +} + + +if err := client.SqlResourcesRetrieveContinuousBackupInformationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `RestorablesClient.TableResourcesRetrieveContinuousBackupInformation` + +```go +ctx := context.TODO() +id := restorables.NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "tableName") + +payload := restorables.ContinuousBackupRestoreLocation{ + // ... +} + + +if err := client.TableResourcesRetrieveContinuousBackupInformationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/client.go b/resource-manager/cosmosdb/2024-11-15/restorables/client.go new file mode 100644 index 00000000000..9192fc9307e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/client.go @@ -0,0 +1,26 @@ +package restorables + +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 RestorablesClient struct { + Client *resourcemanager.Client +} + +func NewRestorablesClientWithBaseURI(sdkApi sdkEnv.Api) (*RestorablesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "restorables", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RestorablesClient: %+v", err) + } + + return &RestorablesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/constants.go b/resource-manager/cosmosdb/2024-11-15/restorables/constants.go new file mode 100644 index 00000000000..45f9ca2abfb --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/constants.go @@ -0,0 +1,600 @@ +package restorables + +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 ApiType string + +const ( + ApiTypeCassandra ApiType = "Cassandra" + ApiTypeGremlin ApiType = "Gremlin" + ApiTypeGremlinVTwo ApiType = "GremlinV2" + ApiTypeMongoDB ApiType = "MongoDB" + ApiTypeSql ApiType = "Sql" + ApiTypeTable ApiType = "Table" +) + +func PossibleValuesForApiType() []string { + return []string{ + string(ApiTypeCassandra), + string(ApiTypeGremlin), + string(ApiTypeGremlinVTwo), + string(ApiTypeMongoDB), + string(ApiTypeSql), + string(ApiTypeTable), + } +} + +func (s *ApiType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApiType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApiType(input string) (*ApiType, error) { + vals := map[string]ApiType{ + "cassandra": ApiTypeCassandra, + "gremlin": ApiTypeGremlin, + "gremlinv2": ApiTypeGremlinVTwo, + "mongodb": ApiTypeMongoDB, + "sql": ApiTypeSql, + "table": ApiTypeTable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApiType(input) + return &out, nil +} + +type CompositePathSortOrder string + +const ( + CompositePathSortOrderAscending CompositePathSortOrder = "ascending" + CompositePathSortOrderDescending CompositePathSortOrder = "descending" +) + +func PossibleValuesForCompositePathSortOrder() []string { + return []string{ + string(CompositePathSortOrderAscending), + string(CompositePathSortOrderDescending), + } +} + +func (s *CompositePathSortOrder) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCompositePathSortOrder(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCompositePathSortOrder(input string) (*CompositePathSortOrder, error) { + vals := map[string]CompositePathSortOrder{ + "ascending": CompositePathSortOrderAscending, + "descending": CompositePathSortOrderDescending, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CompositePathSortOrder(input) + return &out, nil +} + +type ConflictResolutionMode string + +const ( + ConflictResolutionModeCustom ConflictResolutionMode = "Custom" + ConflictResolutionModeLastWriterWins ConflictResolutionMode = "LastWriterWins" +) + +func PossibleValuesForConflictResolutionMode() []string { + return []string{ + string(ConflictResolutionModeCustom), + string(ConflictResolutionModeLastWriterWins), + } +} + +func (s *ConflictResolutionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConflictResolutionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConflictResolutionMode(input string) (*ConflictResolutionMode, error) { + vals := map[string]ConflictResolutionMode{ + "custom": ConflictResolutionModeCustom, + "lastwriterwins": ConflictResolutionModeLastWriterWins, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConflictResolutionMode(input) + return &out, nil +} + +type CreateMode string + +const ( + CreateModeDefault CreateMode = "Default" + CreateModeRestore CreateMode = "Restore" +) + +func PossibleValuesForCreateMode() []string { + return []string{ + string(CreateModeDefault), + string(CreateModeRestore), + } +} + +func (s *CreateMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCreateMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCreateMode(input string) (*CreateMode, error) { + vals := map[string]CreateMode{ + "default": CreateModeDefault, + "restore": CreateModeRestore, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreateMode(input) + return &out, nil +} + +type DataType string + +const ( + DataTypeLineString DataType = "LineString" + DataTypeMultiPolygon DataType = "MultiPolygon" + DataTypeNumber DataType = "Number" + DataTypePoint DataType = "Point" + DataTypePolygon DataType = "Polygon" + DataTypeString DataType = "String" +) + +func PossibleValuesForDataType() []string { + return []string{ + string(DataTypeLineString), + string(DataTypeMultiPolygon), + string(DataTypeNumber), + string(DataTypePoint), + string(DataTypePolygon), + string(DataTypeString), + } +} + +func (s *DataType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataType(input string) (*DataType, error) { + vals := map[string]DataType{ + "linestring": DataTypeLineString, + "multipolygon": DataTypeMultiPolygon, + "number": DataTypeNumber, + "point": DataTypePoint, + "polygon": DataTypePolygon, + "string": DataTypeString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataType(input) + return &out, nil +} + +type DistanceFunction string + +const ( + DistanceFunctionCosine DistanceFunction = "cosine" + DistanceFunctionDotproduct DistanceFunction = "dotproduct" + DistanceFunctionEuclidean DistanceFunction = "euclidean" +) + +func PossibleValuesForDistanceFunction() []string { + return []string{ + string(DistanceFunctionCosine), + string(DistanceFunctionDotproduct), + string(DistanceFunctionEuclidean), + } +} + +func (s *DistanceFunction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDistanceFunction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDistanceFunction(input string) (*DistanceFunction, error) { + vals := map[string]DistanceFunction{ + "cosine": DistanceFunctionCosine, + "dotproduct": DistanceFunctionDotproduct, + "euclidean": DistanceFunctionEuclidean, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DistanceFunction(input) + return &out, nil +} + +type IndexKind string + +const ( + IndexKindHash IndexKind = "Hash" + IndexKindRange IndexKind = "Range" + IndexKindSpatial IndexKind = "Spatial" +) + +func PossibleValuesForIndexKind() []string { + return []string{ + string(IndexKindHash), + string(IndexKindRange), + string(IndexKindSpatial), + } +} + +func (s *IndexKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIndexKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIndexKind(input string) (*IndexKind, error) { + vals := map[string]IndexKind{ + "hash": IndexKindHash, + "range": IndexKindRange, + "spatial": IndexKindSpatial, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IndexKind(input) + return &out, nil +} + +type IndexingMode string + +const ( + IndexingModeConsistent IndexingMode = "consistent" + IndexingModeLazy IndexingMode = "lazy" + IndexingModeNone IndexingMode = "none" +) + +func PossibleValuesForIndexingMode() []string { + return []string{ + string(IndexingModeConsistent), + string(IndexingModeLazy), + string(IndexingModeNone), + } +} + +func (s *IndexingMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIndexingMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIndexingMode(input string) (*IndexingMode, error) { + vals := map[string]IndexingMode{ + "consistent": IndexingModeConsistent, + "lazy": IndexingModeLazy, + "none": IndexingModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IndexingMode(input) + return &out, nil +} + +type OperationType string + +const ( + OperationTypeCreate OperationType = "Create" + OperationTypeDelete OperationType = "Delete" + OperationTypeRecreate OperationType = "Recreate" + OperationTypeReplace OperationType = "Replace" + OperationTypeSystemOperation OperationType = "SystemOperation" +) + +func PossibleValuesForOperationType() []string { + return []string{ + string(OperationTypeCreate), + string(OperationTypeDelete), + string(OperationTypeRecreate), + string(OperationTypeReplace), + string(OperationTypeSystemOperation), + } +} + +func (s *OperationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOperationType(input string) (*OperationType, error) { + vals := map[string]OperationType{ + "create": OperationTypeCreate, + "delete": OperationTypeDelete, + "recreate": OperationTypeRecreate, + "replace": OperationTypeReplace, + "systemoperation": OperationTypeSystemOperation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OperationType(input) + return &out, nil +} + +type PartitionKind string + +const ( + PartitionKindHash PartitionKind = "Hash" + PartitionKindMultiHash PartitionKind = "MultiHash" + PartitionKindRange PartitionKind = "Range" +) + +func PossibleValuesForPartitionKind() []string { + return []string{ + string(PartitionKindHash), + string(PartitionKindMultiHash), + string(PartitionKindRange), + } +} + +func (s *PartitionKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePartitionKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePartitionKind(input string) (*PartitionKind, error) { + vals := map[string]PartitionKind{ + "hash": PartitionKindHash, + "multihash": PartitionKindMultiHash, + "range": PartitionKindRange, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PartitionKind(input) + return &out, nil +} + +type SpatialType string + +const ( + SpatialTypeLineString SpatialType = "LineString" + SpatialTypeMultiPolygon SpatialType = "MultiPolygon" + SpatialTypePoint SpatialType = "Point" + SpatialTypePolygon SpatialType = "Polygon" +) + +func PossibleValuesForSpatialType() []string { + return []string{ + string(SpatialTypeLineString), + string(SpatialTypeMultiPolygon), + string(SpatialTypePoint), + string(SpatialTypePolygon), + } +} + +func (s *SpatialType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSpatialType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSpatialType(input string) (*SpatialType, error) { + vals := map[string]SpatialType{ + "linestring": SpatialTypeLineString, + "multipolygon": SpatialTypeMultiPolygon, + "point": SpatialTypePoint, + "polygon": SpatialTypePolygon, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SpatialType(input) + return &out, nil +} + +type VectorDataType string + +const ( + VectorDataTypeFloatThreeTwo VectorDataType = "float32" + VectorDataTypeIntEight VectorDataType = "int8" + VectorDataTypeUintEight VectorDataType = "uint8" +) + +func PossibleValuesForVectorDataType() []string { + return []string{ + string(VectorDataTypeFloatThreeTwo), + string(VectorDataTypeIntEight), + string(VectorDataTypeUintEight), + } +} + +func (s *VectorDataType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVectorDataType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVectorDataType(input string) (*VectorDataType, error) { + vals := map[string]VectorDataType{ + "float32": VectorDataTypeFloatThreeTwo, + "int8": VectorDataTypeIntEight, + "uint8": VectorDataTypeUintEight, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VectorDataType(input) + return &out, nil +} + +type VectorIndexType string + +const ( + VectorIndexTypeDiskANN VectorIndexType = "diskANN" + VectorIndexTypeFlat VectorIndexType = "flat" + VectorIndexTypeQuantizedFlat VectorIndexType = "quantizedFlat" +) + +func PossibleValuesForVectorIndexType() []string { + return []string{ + string(VectorIndexTypeDiskANN), + string(VectorIndexTypeFlat), + string(VectorIndexTypeQuantizedFlat), + } +} + +func (s *VectorIndexType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVectorIndexType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVectorIndexType(input string) (*VectorIndexType, error) { + vals := map[string]VectorIndexType{ + "diskann": VectorIndexTypeDiskANN, + "flat": VectorIndexTypeFlat, + "quantizedflat": VectorIndexTypeQuantizedFlat, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VectorIndexType(input) + return &out, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/id_container.go b/resource-manager/cosmosdb/2024-11-15/restorables/id_container.go new file mode 100644 index 00000000000..cc01b7113aa --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/id_container.go @@ -0,0 +1,148 @@ +package restorables + +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(&ContainerId{}) +} + +var _ resourceids.ResourceId = &ContainerId{} + +// ContainerId is a struct representing the Resource ID for a Container +type ContainerId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + SqlDatabaseName string + ContainerName string +} + +// NewContainerID returns a new ContainerId struct +func NewContainerID(subscriptionId string, resourceGroupName string, databaseAccountName string, sqlDatabaseName string, containerName string) ContainerId { + return ContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + SqlDatabaseName: sqlDatabaseName, + ContainerName: containerName, + } +} + +// ParseContainerID parses 'input' into a ContainerId +func ParseContainerID(input string) (*ContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseContainerIDInsensitively parses 'input' case-insensitively into a ContainerId +// note: this method should only be used for API response data and not user input +func ParseContainerIDInsensitively(input string) (*ContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ContainerId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.SqlDatabaseName, ok = input.Parsed["sqlDatabaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sqlDatabaseName", input) + } + + if id.ContainerName, ok = input.Parsed["containerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerName", input) + } + + return nil +} + +// ValidateContainerID checks that 'input' can be parsed as a Container ID +func ValidateContainerID(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 := ParseContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Container ID +func (id ContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/sqlDatabases/%s/containers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Container ID +func (id ContainerId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticSqlDatabases", "sqlDatabases", "sqlDatabases"), + resourceids.UserSpecifiedSegment("sqlDatabaseName", "sqlDatabaseName"), + resourceids.StaticSegment("staticContainers", "containers", "containers"), + resourceids.UserSpecifiedSegment("containerName", "containerName"), + } +} + +// String returns a human-readable description of this Container ID +func (id ContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Sql Database Name: %q", id.SqlDatabaseName), + fmt.Sprintf("Container Name: %q", id.ContainerName), + } + return fmt.Sprintf("Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/id_container_test.go b/resource-manager/cosmosdb/2024-11-15/restorables/id_container_test.go new file mode 100644 index 00000000000..97675cfd2b9 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/id_container_test.go @@ -0,0 +1,372 @@ +package restorables + +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 = &ContainerId{} + +func TestNewContainerID(t *testing.T) { + id := NewContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.SqlDatabaseName != "sqlDatabaseName" { + t.Fatalf("Expected %q but got %q for Segment 'SqlDatabaseName'", id.SqlDatabaseName, "sqlDatabaseName") + } + + if id.ContainerName != "containerName" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerName'", id.ContainerName, "containerName") + } +} + +func TestFormatContainerID(t *testing.T) { + actual := NewContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "sqlDatabaseName", "containerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName", + Expected: &ContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + SqlDatabaseName: "sqlDatabaseName", + ContainerName: "containerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContainerID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.SqlDatabaseName != v.Expected.SqlDatabaseName { + t.Fatalf("Expected %q but got %q for SqlDatabaseName", v.Expected.SqlDatabaseName, actual.SqlDatabaseName) + } + + if actual.ContainerName != v.Expected.ContainerName { + t.Fatalf("Expected %q but got %q for ContainerName", v.Expected.ContainerName, actual.ContainerName) + } + + } +} + +func TestParseContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cOnTaInErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName", + Expected: &ContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + SqlDatabaseName: "sqlDatabaseName", + ContainerName: "containerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/sqlDatabases/sqlDatabaseName/containers/containerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cOnTaInErS/cOnTaInErNaMe", + Expected: &ContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + SqlDatabaseName: "sQlDaTaBaSeNaMe", + ContainerName: "cOnTaInErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sQlDaTaBaSeS/sQlDaTaBaSeNaMe/cOnTaInErS/cOnTaInErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContainerIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.SqlDatabaseName != v.Expected.SqlDatabaseName { + t.Fatalf("Expected %q but got %q for SqlDatabaseName", v.Expected.SqlDatabaseName, actual.SqlDatabaseName) + } + + if actual.ContainerName != v.Expected.ContainerName { + t.Fatalf("Expected %q but got %q for ContainerName", v.Expected.ContainerName, actual.ContainerName) + } + + } +} + +func TestSegmentsForContainerId(t *testing.T) { + segments := ContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ContainerId 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/cosmosdb/2024-11-15/restorables/id_graph.go b/resource-manager/cosmosdb/2024-11-15/restorables/id_graph.go new file mode 100644 index 00000000000..b5c11de6742 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/id_graph.go @@ -0,0 +1,148 @@ +package restorables + +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(&GraphId{}) +} + +var _ resourceids.ResourceId = &GraphId{} + +// GraphId is a struct representing the Resource ID for a Graph +type GraphId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + GremlinDatabaseName string + GraphName string +} + +// NewGraphID returns a new GraphId struct +func NewGraphID(subscriptionId string, resourceGroupName string, databaseAccountName string, gremlinDatabaseName string, graphName string) GraphId { + return GraphId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + GremlinDatabaseName: gremlinDatabaseName, + GraphName: graphName, + } +} + +// ParseGraphID parses 'input' into a GraphId +func ParseGraphID(input string) (*GraphId, error) { + parser := resourceids.NewParserFromResourceIdType(&GraphId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GraphId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseGraphIDInsensitively parses 'input' case-insensitively into a GraphId +// note: this method should only be used for API response data and not user input +func ParseGraphIDInsensitively(input string) (*GraphId, error) { + parser := resourceids.NewParserFromResourceIdType(&GraphId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GraphId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *GraphId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.GremlinDatabaseName, ok = input.Parsed["gremlinDatabaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "gremlinDatabaseName", input) + } + + if id.GraphName, ok = input.Parsed["graphName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "graphName", input) + } + + return nil +} + +// ValidateGraphID checks that 'input' can be parsed as a Graph ID +func ValidateGraphID(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 := ParseGraphID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Graph ID +func (id GraphId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/gremlinDatabases/%s/graphs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.GremlinDatabaseName, id.GraphName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Graph ID +func (id GraphId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticGremlinDatabases", "gremlinDatabases", "gremlinDatabases"), + resourceids.UserSpecifiedSegment("gremlinDatabaseName", "gremlinDatabaseName"), + resourceids.StaticSegment("staticGraphs", "graphs", "graphs"), + resourceids.UserSpecifiedSegment("graphName", "graphName"), + } +} + +// String returns a human-readable description of this Graph ID +func (id GraphId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Gremlin Database Name: %q", id.GremlinDatabaseName), + fmt.Sprintf("Graph Name: %q", id.GraphName), + } + return fmt.Sprintf("Graph (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/id_graph_test.go b/resource-manager/cosmosdb/2024-11-15/restorables/id_graph_test.go new file mode 100644 index 00000000000..633f0c50588 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/id_graph_test.go @@ -0,0 +1,372 @@ +package restorables + +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 = &GraphId{} + +func TestNewGraphID(t *testing.T) { + id := NewGraphID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "gremlinDatabaseName", "graphName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.GremlinDatabaseName != "gremlinDatabaseName" { + t.Fatalf("Expected %q but got %q for Segment 'GremlinDatabaseName'", id.GremlinDatabaseName, "gremlinDatabaseName") + } + + if id.GraphName != "graphName" { + t.Fatalf("Expected %q but got %q for Segment 'GraphName'", id.GraphName, "graphName") + } +} + +func TestFormatGraphID(t *testing.T) { + actual := NewGraphID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "gremlinDatabaseName", "graphName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases/gremlinDatabaseName/graphs/graphName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseGraphID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GraphId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases/gremlinDatabaseName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases/gremlinDatabaseName/graphs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases/gremlinDatabaseName/graphs/graphName", + Expected: &GraphId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + GremlinDatabaseName: "gremlinDatabaseName", + GraphName: "graphName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases/gremlinDatabaseName/graphs/graphName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGraphID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.GremlinDatabaseName != v.Expected.GremlinDatabaseName { + t.Fatalf("Expected %q but got %q for GremlinDatabaseName", v.Expected.GremlinDatabaseName, actual.GremlinDatabaseName) + } + + if actual.GraphName != v.Expected.GraphName { + t.Fatalf("Expected %q but got %q for GraphName", v.Expected.GraphName, actual.GraphName) + } + + } +} + +func TestParseGraphIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GraphId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/gReMlInDaTaBaSeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases/gremlinDatabaseName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/gReMlInDaTaBaSeS/gReMlInDaTaBaSeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases/gremlinDatabaseName/graphs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/gReMlInDaTaBaSeS/gReMlInDaTaBaSeNaMe/gRaPhS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases/gremlinDatabaseName/graphs/graphName", + Expected: &GraphId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + GremlinDatabaseName: "gremlinDatabaseName", + GraphName: "graphName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/gremlinDatabases/gremlinDatabaseName/graphs/graphName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/gReMlInDaTaBaSeS/gReMlInDaTaBaSeNaMe/gRaPhS/gRaPhNaMe", + Expected: &GraphId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + GremlinDatabaseName: "gReMlInDaTaBaSeNaMe", + GraphName: "gRaPhNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/gReMlInDaTaBaSeS/gReMlInDaTaBaSeNaMe/gRaPhS/gRaPhNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGraphIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.GremlinDatabaseName != v.Expected.GremlinDatabaseName { + t.Fatalf("Expected %q but got %q for GremlinDatabaseName", v.Expected.GremlinDatabaseName, actual.GremlinDatabaseName) + } + + if actual.GraphName != v.Expected.GraphName { + t.Fatalf("Expected %q but got %q for GraphName", v.Expected.GraphName, actual.GraphName) + } + + } +} + +func TestSegmentsForGraphId(t *testing.T) { + segments := GraphId{}.Segments() + if len(segments) == 0 { + t.Fatalf("GraphId 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/cosmosdb/2024-11-15/restorables/id_location.go b/resource-manager/cosmosdb/2024-11-15/restorables/id_location.go new file mode 100644 index 00000000000..c7c3d4a6d23 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/id_location.go @@ -0,0 +1,121 @@ +package restorables + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.DocumentDB/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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// 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/cosmosdb/2024-11-15/restorables/id_location_test.go b/resource-manager/cosmosdb/2024-11-15/restorables/id_location_test.go new file mode 100644 index 00000000000..08c58d5f34f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/id_location_test.go @@ -0,0 +1,237 @@ +package restorables + +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", "locationName") + + 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 != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/lOcAtIoNs/lOcAtIoNnAmE/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/cosmosdb/2024-11-15/restorables/id_mongodbdatabasecollection.go b/resource-manager/cosmosdb/2024-11-15/restorables/id_mongodbdatabasecollection.go new file mode 100644 index 00000000000..863a29287de --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/id_mongodbdatabasecollection.go @@ -0,0 +1,148 @@ +package restorables + +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(&MongodbDatabaseCollectionId{}) +} + +var _ resourceids.ResourceId = &MongodbDatabaseCollectionId{} + +// MongodbDatabaseCollectionId is a struct representing the Resource ID for a Mongodb Database Collection +type MongodbDatabaseCollectionId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + MongodbDatabaseName string + CollectionName string +} + +// NewMongodbDatabaseCollectionID returns a new MongodbDatabaseCollectionId struct +func NewMongodbDatabaseCollectionID(subscriptionId string, resourceGroupName string, databaseAccountName string, mongodbDatabaseName string, collectionName string) MongodbDatabaseCollectionId { + return MongodbDatabaseCollectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + MongodbDatabaseName: mongodbDatabaseName, + CollectionName: collectionName, + } +} + +// ParseMongodbDatabaseCollectionID parses 'input' into a MongodbDatabaseCollectionId +func ParseMongodbDatabaseCollectionID(input string) (*MongodbDatabaseCollectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&MongodbDatabaseCollectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MongodbDatabaseCollectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMongodbDatabaseCollectionIDInsensitively parses 'input' case-insensitively into a MongodbDatabaseCollectionId +// note: this method should only be used for API response data and not user input +func ParseMongodbDatabaseCollectionIDInsensitively(input string) (*MongodbDatabaseCollectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&MongodbDatabaseCollectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MongodbDatabaseCollectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MongodbDatabaseCollectionId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.MongodbDatabaseName, ok = input.Parsed["mongodbDatabaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "mongodbDatabaseName", input) + } + + if id.CollectionName, ok = input.Parsed["collectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "collectionName", input) + } + + return nil +} + +// ValidateMongodbDatabaseCollectionID checks that 'input' can be parsed as a Mongodb Database Collection ID +func ValidateMongodbDatabaseCollectionID(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 := ParseMongodbDatabaseCollectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Mongodb Database Collection ID +func (id MongodbDatabaseCollectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/mongodbDatabases/%s/collections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.MongodbDatabaseName, id.CollectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Mongodb Database Collection ID +func (id MongodbDatabaseCollectionId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticMongodbDatabases", "mongodbDatabases", "mongodbDatabases"), + resourceids.UserSpecifiedSegment("mongodbDatabaseName", "mongodbDatabaseName"), + resourceids.StaticSegment("staticCollections", "collections", "collections"), + resourceids.UserSpecifiedSegment("collectionName", "collectionName"), + } +} + +// String returns a human-readable description of this Mongodb Database Collection ID +func (id MongodbDatabaseCollectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Mongodb Database Name: %q", id.MongodbDatabaseName), + fmt.Sprintf("Collection Name: %q", id.CollectionName), + } + return fmt.Sprintf("Mongodb Database Collection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/id_mongodbdatabasecollection_test.go b/resource-manager/cosmosdb/2024-11-15/restorables/id_mongodbdatabasecollection_test.go new file mode 100644 index 00000000000..77437dc2f70 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/id_mongodbdatabasecollection_test.go @@ -0,0 +1,372 @@ +package restorables + +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 = &MongodbDatabaseCollectionId{} + +func TestNewMongodbDatabaseCollectionID(t *testing.T) { + id := NewMongodbDatabaseCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongodbDatabaseName", "collectionName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.MongodbDatabaseName != "mongodbDatabaseName" { + t.Fatalf("Expected %q but got %q for Segment 'MongodbDatabaseName'", id.MongodbDatabaseName, "mongodbDatabaseName") + } + + if id.CollectionName != "collectionName" { + t.Fatalf("Expected %q but got %q for Segment 'CollectionName'", id.CollectionName, "collectionName") + } +} + +func TestFormatMongodbDatabaseCollectionID(t *testing.T) { + actual := NewMongodbDatabaseCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "mongodbDatabaseName", "collectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases/mongodbDatabaseName/collections/collectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMongodbDatabaseCollectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MongodbDatabaseCollectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases/mongodbDatabaseName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases/mongodbDatabaseName/collections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases/mongodbDatabaseName/collections/collectionName", + Expected: &MongodbDatabaseCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + MongodbDatabaseName: "mongodbDatabaseName", + CollectionName: "collectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases/mongodbDatabaseName/collections/collectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMongodbDatabaseCollectionID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.MongodbDatabaseName != v.Expected.MongodbDatabaseName { + t.Fatalf("Expected %q but got %q for MongodbDatabaseName", v.Expected.MongodbDatabaseName, actual.MongodbDatabaseName) + } + + if actual.CollectionName != v.Expected.CollectionName { + t.Fatalf("Expected %q but got %q for CollectionName", v.Expected.CollectionName, actual.CollectionName) + } + + } +} + +func TestParseMongodbDatabaseCollectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MongodbDatabaseCollectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/mOnGoDbDaTaBaSeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases/mongodbDatabaseName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/mOnGoDbDaTaBaSeS/mOnGoDbDaTaBaSeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases/mongodbDatabaseName/collections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/mOnGoDbDaTaBaSeS/mOnGoDbDaTaBaSeNaMe/cOlLeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases/mongodbDatabaseName/collections/collectionName", + Expected: &MongodbDatabaseCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + MongodbDatabaseName: "mongodbDatabaseName", + CollectionName: "collectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/mongodbDatabases/mongodbDatabaseName/collections/collectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/mOnGoDbDaTaBaSeS/mOnGoDbDaTaBaSeNaMe/cOlLeCtIoNs/cOlLeCtIoNnAmE", + Expected: &MongodbDatabaseCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + MongodbDatabaseName: "mOnGoDbDaTaBaSeNaMe", + CollectionName: "cOlLeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/mOnGoDbDaTaBaSeS/mOnGoDbDaTaBaSeNaMe/cOlLeCtIoNs/cOlLeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMongodbDatabaseCollectionIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.MongodbDatabaseName != v.Expected.MongodbDatabaseName { + t.Fatalf("Expected %q but got %q for MongodbDatabaseName", v.Expected.MongodbDatabaseName, actual.MongodbDatabaseName) + } + + if actual.CollectionName != v.Expected.CollectionName { + t.Fatalf("Expected %q but got %q for CollectionName", v.Expected.CollectionName, actual.CollectionName) + } + + } +} + +func TestSegmentsForMongodbDatabaseCollectionId(t *testing.T) { + segments := MongodbDatabaseCollectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MongodbDatabaseCollectionId 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/cosmosdb/2024-11-15/restorables/id_restorabledatabaseaccount.go b/resource-manager/cosmosdb/2024-11-15/restorables/id_restorabledatabaseaccount.go new file mode 100644 index 00000000000..712ea35cfc0 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/id_restorabledatabaseaccount.go @@ -0,0 +1,130 @@ +package restorables + +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(&RestorableDatabaseAccountId{}) +} + +var _ resourceids.ResourceId = &RestorableDatabaseAccountId{} + +// RestorableDatabaseAccountId is a struct representing the Resource ID for a Restorable Database Account +type RestorableDatabaseAccountId struct { + SubscriptionId string + LocationName string + InstanceId string +} + +// NewRestorableDatabaseAccountID returns a new RestorableDatabaseAccountId struct +func NewRestorableDatabaseAccountID(subscriptionId string, locationName string, instanceId string) RestorableDatabaseAccountId { + return RestorableDatabaseAccountId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + InstanceId: instanceId, + } +} + +// ParseRestorableDatabaseAccountID parses 'input' into a RestorableDatabaseAccountId +func ParseRestorableDatabaseAccountID(input string) (*RestorableDatabaseAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&RestorableDatabaseAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RestorableDatabaseAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRestorableDatabaseAccountIDInsensitively parses 'input' case-insensitively into a RestorableDatabaseAccountId +// note: this method should only be used for API response data and not user input +func ParseRestorableDatabaseAccountIDInsensitively(input string) (*RestorableDatabaseAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&RestorableDatabaseAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RestorableDatabaseAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RestorableDatabaseAccountId) 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.InstanceId, ok = input.Parsed["instanceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceId", input) + } + + return nil +} + +// ValidateRestorableDatabaseAccountID checks that 'input' can be parsed as a Restorable Database Account ID +func ValidateRestorableDatabaseAccountID(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 := ParseRestorableDatabaseAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Restorable Database Account ID +func (id RestorableDatabaseAccountId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.DocumentDB/locations/%s/restorableDatabaseAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.InstanceId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Restorable Database Account ID +func (id RestorableDatabaseAccountId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + resourceids.StaticSegment("staticRestorableDatabaseAccounts", "restorableDatabaseAccounts", "restorableDatabaseAccounts"), + resourceids.UserSpecifiedSegment("instanceId", "instanceId"), + } +} + +// String returns a human-readable description of this Restorable Database Account ID +func (id RestorableDatabaseAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + fmt.Sprintf("Instance: %q", id.InstanceId), + } + return fmt.Sprintf("Restorable Database Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/id_restorabledatabaseaccount_test.go b/resource-manager/cosmosdb/2024-11-15/restorables/id_restorabledatabaseaccount_test.go new file mode 100644 index 00000000000..9a42672ab61 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/id_restorabledatabaseaccount_test.go @@ -0,0 +1,282 @@ +package restorables + +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 = &RestorableDatabaseAccountId{} + +func TestNewRestorableDatabaseAccountID(t *testing.T) { + id := NewRestorableDatabaseAccountID("12345678-1234-9876-4563-123456789012", "locationName", "instanceId") + + 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 != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } + + if id.InstanceId != "instanceId" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceId'", id.InstanceId, "instanceId") + } +} + +func TestFormatRestorableDatabaseAccountID(t *testing.T) { + actual := NewRestorableDatabaseAccountID("12345678-1234-9876-4563-123456789012", "locationName", "instanceId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/locationName/restorableDatabaseAccounts/instanceId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRestorableDatabaseAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RestorableDatabaseAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/locationName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/locationName/restorableDatabaseAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/locationName/restorableDatabaseAccounts/instanceId", + Expected: &RestorableDatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + InstanceId: "instanceId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/locationName/restorableDatabaseAccounts/instanceId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRestorableDatabaseAccountID(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.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + } +} + +func TestParseRestorableDatabaseAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RestorableDatabaseAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/lOcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/locationName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/lOcAtIoNs/lOcAtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/locationName/restorableDatabaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/lOcAtIoNs/lOcAtIoNnAmE/rEsToRaBlEdAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/locationName/restorableDatabaseAccounts/instanceId", + Expected: &RestorableDatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + InstanceId: "instanceId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/locationName/restorableDatabaseAccounts/instanceId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/lOcAtIoNs/lOcAtIoNnAmE/rEsToRaBlEdAtAbAsEaCcOuNtS/iNsTaNcEiD", + Expected: &RestorableDatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + InstanceId: "iNsTaNcEiD", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/lOcAtIoNs/lOcAtIoNnAmE/rEsToRaBlEdAtAbAsEaCcOuNtS/iNsTaNcEiD/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRestorableDatabaseAccountIDInsensitively(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.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + } +} + +func TestSegmentsForRestorableDatabaseAccountId(t *testing.T) { + segments := RestorableDatabaseAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RestorableDatabaseAccountId 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/cosmosdb/2024-11-15/restorables/id_table.go b/resource-manager/cosmosdb/2024-11-15/restorables/id_table.go new file mode 100644 index 00000000000..6b9e3c73fa6 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/id_table.go @@ -0,0 +1,139 @@ +package restorables + +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(&TableId{}) +} + +var _ resourceids.ResourceId = &TableId{} + +// TableId is a struct representing the Resource ID for a Table +type TableId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + TableName string +} + +// NewTableID returns a new TableId struct +func NewTableID(subscriptionId string, resourceGroupName string, databaseAccountName string, tableName string) TableId { + return TableId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + TableName: tableName, + } +} + +// ParseTableID parses 'input' into a TableId +func ParseTableID(input string) (*TableId, error) { + parser := resourceids.NewParserFromResourceIdType(&TableId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTableIDInsensitively parses 'input' case-insensitively into a TableId +// note: this method should only be used for API response data and not user input +func ParseTableIDInsensitively(input string) (*TableId, error) { + parser := resourceids.NewParserFromResourceIdType(&TableId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TableId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.TableName, ok = input.Parsed["tableName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "tableName", input) + } + + return nil +} + +// ValidateTableID checks that 'input' can be parsed as a Table ID +func ValidateTableID(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 := ParseTableID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Table ID +func (id TableId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/tables/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.TableName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Table ID +func (id TableId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticTables", "tables", "tables"), + resourceids.UserSpecifiedSegment("tableName", "tableName"), + } +} + +// String returns a human-readable description of this Table ID +func (id TableId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Table Name: %q", id.TableName), + } + return fmt.Sprintf("Table (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/id_table_test.go b/resource-manager/cosmosdb/2024-11-15/restorables/id_table_test.go new file mode 100644 index 00000000000..432623c34aa --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/id_table_test.go @@ -0,0 +1,327 @@ +package restorables + +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 = &TableId{} + +func TestNewTableID(t *testing.T) { + id := NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "tableName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.TableName != "tableName" { + t.Fatalf("Expected %q but got %q for Segment 'TableName'", id.TableName, "tableName") + } +} + +func TestFormatTableID(t *testing.T) { + actual := NewTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "tableName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/tables/tableName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTableID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/tables", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/tables/tableName", + Expected: &TableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + TableName: "tableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/tables/tableName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTableID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.TableName != v.Expected.TableName { + t.Fatalf("Expected %q but got %q for TableName", v.Expected.TableName, actual.TableName) + } + + } +} + +func TestParseTableIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/tables", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/tAbLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/tables/tableName", + Expected: &TableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + TableName: "tableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/tables/tableName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/tAbLeS/tAbLeNaMe", + Expected: &TableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + TableName: "tAbLeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/tAbLeS/tAbLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTableIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.TableName != v.Expected.TableName { + t.Fatalf("Expected %q but got %q for TableName", v.Expected.TableName, actual.TableName) + } + + } +} + +func TestSegmentsForTableId(t *testing.T) { + segments := TableId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TableId 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/cosmosdb/2024-11-15/restorables/method_gremlinresourcesretrievecontinuousbackupinformation.go b/resource-manager/cosmosdb/2024-11-15/restorables/method_gremlinresourcesretrievecontinuousbackupinformation.go new file mode 100644 index 00000000000..3b539897d94 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/method_gremlinresourcesretrievecontinuousbackupinformation.go @@ -0,0 +1,75 @@ +package restorables + +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 GremlinResourcesRetrieveContinuousBackupInformationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BackupInformation +} + +// GremlinResourcesRetrieveContinuousBackupInformation ... +func (c RestorablesClient) GremlinResourcesRetrieveContinuousBackupInformation(ctx context.Context, id GraphId, input ContinuousBackupRestoreLocation) (result GremlinResourcesRetrieveContinuousBackupInformationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retrieveContinuousBackupInformation", 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 +} + +// GremlinResourcesRetrieveContinuousBackupInformationThenPoll performs GremlinResourcesRetrieveContinuousBackupInformation then polls until it's completed +func (c RestorablesClient) GremlinResourcesRetrieveContinuousBackupInformationThenPoll(ctx context.Context, id GraphId, input ContinuousBackupRestoreLocation) error { + result, err := c.GremlinResourcesRetrieveContinuousBackupInformation(ctx, id, input) + if err != nil { + return fmt.Errorf("performing GremlinResourcesRetrieveContinuousBackupInformation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GremlinResourcesRetrieveContinuousBackupInformation: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/method_mongodbresourcesretrievecontinuousbackupinformation.go b/resource-manager/cosmosdb/2024-11-15/restorables/method_mongodbresourcesretrievecontinuousbackupinformation.go new file mode 100644 index 00000000000..dda7adc24cb --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/method_mongodbresourcesretrievecontinuousbackupinformation.go @@ -0,0 +1,75 @@ +package restorables + +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 MongoDBResourcesRetrieveContinuousBackupInformationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BackupInformation +} + +// MongoDBResourcesRetrieveContinuousBackupInformation ... +func (c RestorablesClient) MongoDBResourcesRetrieveContinuousBackupInformation(ctx context.Context, id MongodbDatabaseCollectionId, input ContinuousBackupRestoreLocation) (result MongoDBResourcesRetrieveContinuousBackupInformationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retrieveContinuousBackupInformation", 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 +} + +// MongoDBResourcesRetrieveContinuousBackupInformationThenPoll performs MongoDBResourcesRetrieveContinuousBackupInformation then polls until it's completed +func (c RestorablesClient) MongoDBResourcesRetrieveContinuousBackupInformationThenPoll(ctx context.Context, id MongodbDatabaseCollectionId, input ContinuousBackupRestoreLocation) error { + result, err := c.MongoDBResourcesRetrieveContinuousBackupInformation(ctx, id, input) + if err != nil { + return fmt.Errorf("performing MongoDBResourcesRetrieveContinuousBackupInformation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MongoDBResourcesRetrieveContinuousBackupInformation: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/method_restorabledatabaseaccountsgetbylocation.go b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorabledatabaseaccountsgetbylocation.go new file mode 100644 index 00000000000..536ceceb108 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorabledatabaseaccountsgetbylocation.go @@ -0,0 +1,53 @@ +package restorables + +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 RestorableDatabaseAccountsGetByLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestorableDatabaseAccountGetResult +} + +// RestorableDatabaseAccountsGetByLocation ... +func (c RestorablesClient) RestorableDatabaseAccountsGetByLocation(ctx context.Context, id RestorableDatabaseAccountId) (result RestorableDatabaseAccountsGetByLocationOperationResponse, 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 RestorableDatabaseAccountGetResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/method_restorabledatabaseaccountslist.go b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorabledatabaseaccountslist.go new file mode 100644 index 00000000000..874c2df23eb --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorabledatabaseaccountslist.go @@ -0,0 +1,55 @@ +package restorables + +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 RestorableDatabaseAccountsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestorableDatabaseAccountsListResult +} + +// RestorableDatabaseAccountsList ... +func (c RestorablesClient) RestorableDatabaseAccountsList(ctx context.Context, id commonids.SubscriptionId) (result RestorableDatabaseAccountsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DocumentDB/restorableDatabaseAccounts", 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 RestorableDatabaseAccountsListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/method_restorabledatabaseaccountslistbylocation.go b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorabledatabaseaccountslistbylocation.go new file mode 100644 index 00000000000..b3d00c3082d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorabledatabaseaccountslistbylocation.go @@ -0,0 +1,54 @@ +package restorables + +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 RestorableDatabaseAccountsListByLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestorableDatabaseAccountsListResult +} + +// RestorableDatabaseAccountsListByLocation ... +func (c RestorablesClient) RestorableDatabaseAccountsListByLocation(ctx context.Context, id LocationId) (result RestorableDatabaseAccountsListByLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/restorableDatabaseAccounts", 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 RestorableDatabaseAccountsListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablegremlindatabaseslist.go b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablegremlindatabaseslist.go new file mode 100644 index 00000000000..1de1530f1c5 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablegremlindatabaseslist.go @@ -0,0 +1,54 @@ +package restorables + +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 RestorableGremlinDatabasesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestorableGremlinDatabasesListResult +} + +// RestorableGremlinDatabasesList ... +func (c RestorablesClient) RestorableGremlinDatabasesList(ctx context.Context, id RestorableDatabaseAccountId) (result RestorableGremlinDatabasesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/restorableGremlinDatabases", 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 RestorableGremlinDatabasesListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablegremlingraphslist.go b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablegremlingraphslist.go new file mode 100644 index 00000000000..8c1c9bcc1c8 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablegremlingraphslist.go @@ -0,0 +1,91 @@ +package restorables + +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 RestorableGremlinGraphsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestorableGremlinGraphsListResult +} + +type RestorableGremlinGraphsListOperationOptions struct { + EndTime *string + RestorableGremlinDatabaseRid *string + StartTime *string +} + +func DefaultRestorableGremlinGraphsListOperationOptions() RestorableGremlinGraphsListOperationOptions { + return RestorableGremlinGraphsListOperationOptions{} +} + +func (o RestorableGremlinGraphsListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RestorableGremlinGraphsListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RestorableGremlinGraphsListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.RestorableGremlinDatabaseRid != nil { + out.Append("restorableGremlinDatabaseRid", fmt.Sprintf("%v", *o.RestorableGremlinDatabaseRid)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + return &out +} + +// RestorableGremlinGraphsList ... +func (c RestorablesClient) RestorableGremlinGraphsList(ctx context.Context, id RestorableDatabaseAccountId, options RestorableGremlinGraphsListOperationOptions) (result RestorableGremlinGraphsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/restorableGraphs", 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 RestorableGremlinGraphsListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablegremlinresourceslist.go b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablegremlinresourceslist.go new file mode 100644 index 00000000000..ed88ce785d0 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablegremlinresourceslist.go @@ -0,0 +1,87 @@ +package restorables + +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 RestorableGremlinResourcesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestorableGremlinResourcesListResult +} + +type RestorableGremlinResourcesListOperationOptions struct { + RestoreLocation *string + RestoreTimestampInUtc *string +} + +func DefaultRestorableGremlinResourcesListOperationOptions() RestorableGremlinResourcesListOperationOptions { + return RestorableGremlinResourcesListOperationOptions{} +} + +func (o RestorableGremlinResourcesListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RestorableGremlinResourcesListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RestorableGremlinResourcesListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.RestoreLocation != nil { + out.Append("restoreLocation", fmt.Sprintf("%v", *o.RestoreLocation)) + } + if o.RestoreTimestampInUtc != nil { + out.Append("restoreTimestampInUtc", fmt.Sprintf("%v", *o.RestoreTimestampInUtc)) + } + return &out +} + +// RestorableGremlinResourcesList ... +func (c RestorablesClient) RestorableGremlinResourcesList(ctx context.Context, id RestorableDatabaseAccountId, options RestorableGremlinResourcesListOperationOptions) (result RestorableGremlinResourcesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/restorableGremlinResources", 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 RestorableGremlinResourcesListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablemongodbcollectionslist.go b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablemongodbcollectionslist.go new file mode 100644 index 00000000000..634d30fb9b6 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablemongodbcollectionslist.go @@ -0,0 +1,91 @@ +package restorables + +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 RestorableMongodbCollectionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestorableMongodbCollectionsListResult +} + +type RestorableMongodbCollectionsListOperationOptions struct { + EndTime *string + RestorableMongodbDatabaseRid *string + StartTime *string +} + +func DefaultRestorableMongodbCollectionsListOperationOptions() RestorableMongodbCollectionsListOperationOptions { + return RestorableMongodbCollectionsListOperationOptions{} +} + +func (o RestorableMongodbCollectionsListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RestorableMongodbCollectionsListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RestorableMongodbCollectionsListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.RestorableMongodbDatabaseRid != nil { + out.Append("restorableMongodbDatabaseRid", fmt.Sprintf("%v", *o.RestorableMongodbDatabaseRid)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + return &out +} + +// RestorableMongodbCollectionsList ... +func (c RestorablesClient) RestorableMongodbCollectionsList(ctx context.Context, id RestorableDatabaseAccountId, options RestorableMongodbCollectionsListOperationOptions) (result RestorableMongodbCollectionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/restorableMongodbCollections", 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 RestorableMongodbCollectionsListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablemongodbdatabaseslist.go b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablemongodbdatabaseslist.go new file mode 100644 index 00000000000..70bff11cfac --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablemongodbdatabaseslist.go @@ -0,0 +1,54 @@ +package restorables + +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 RestorableMongodbDatabasesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestorableMongodbDatabasesListResult +} + +// RestorableMongodbDatabasesList ... +func (c RestorablesClient) RestorableMongodbDatabasesList(ctx context.Context, id RestorableDatabaseAccountId) (result RestorableMongodbDatabasesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/restorableMongodbDatabases", 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 RestorableMongodbDatabasesListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablemongodbresourceslist.go b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablemongodbresourceslist.go new file mode 100644 index 00000000000..b9c7d94bfd8 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablemongodbresourceslist.go @@ -0,0 +1,87 @@ +package restorables + +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 RestorableMongodbResourcesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestorableMongodbResourcesListResult +} + +type RestorableMongodbResourcesListOperationOptions struct { + RestoreLocation *string + RestoreTimestampInUtc *string +} + +func DefaultRestorableMongodbResourcesListOperationOptions() RestorableMongodbResourcesListOperationOptions { + return RestorableMongodbResourcesListOperationOptions{} +} + +func (o RestorableMongodbResourcesListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RestorableMongodbResourcesListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RestorableMongodbResourcesListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.RestoreLocation != nil { + out.Append("restoreLocation", fmt.Sprintf("%v", *o.RestoreLocation)) + } + if o.RestoreTimestampInUtc != nil { + out.Append("restoreTimestampInUtc", fmt.Sprintf("%v", *o.RestoreTimestampInUtc)) + } + return &out +} + +// RestorableMongodbResourcesList ... +func (c RestorablesClient) RestorableMongodbResourcesList(ctx context.Context, id RestorableDatabaseAccountId, options RestorableMongodbResourcesListOperationOptions) (result RestorableMongodbResourcesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/restorableMongodbResources", 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 RestorableMongodbResourcesListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablesqlcontainerslist.go b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablesqlcontainerslist.go new file mode 100644 index 00000000000..c2c8624e6a3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablesqlcontainerslist.go @@ -0,0 +1,91 @@ +package restorables + +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 RestorableSqlContainersListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestorableSqlContainersListResult +} + +type RestorableSqlContainersListOperationOptions struct { + EndTime *string + RestorableSqlDatabaseRid *string + StartTime *string +} + +func DefaultRestorableSqlContainersListOperationOptions() RestorableSqlContainersListOperationOptions { + return RestorableSqlContainersListOperationOptions{} +} + +func (o RestorableSqlContainersListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RestorableSqlContainersListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RestorableSqlContainersListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.RestorableSqlDatabaseRid != nil { + out.Append("restorableSqlDatabaseRid", fmt.Sprintf("%v", *o.RestorableSqlDatabaseRid)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + return &out +} + +// RestorableSqlContainersList ... +func (c RestorablesClient) RestorableSqlContainersList(ctx context.Context, id RestorableDatabaseAccountId, options RestorableSqlContainersListOperationOptions) (result RestorableSqlContainersListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/restorableSqlContainers", 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 RestorableSqlContainersListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablesqldatabaseslist.go b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablesqldatabaseslist.go new file mode 100644 index 00000000000..7b15c2d9b25 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablesqldatabaseslist.go @@ -0,0 +1,54 @@ +package restorables + +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 RestorableSqlDatabasesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestorableSqlDatabasesListResult +} + +// RestorableSqlDatabasesList ... +func (c RestorablesClient) RestorableSqlDatabasesList(ctx context.Context, id RestorableDatabaseAccountId) (result RestorableSqlDatabasesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/restorableSqlDatabases", 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 RestorableSqlDatabasesListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablesqlresourceslist.go b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablesqlresourceslist.go new file mode 100644 index 00000000000..e326137bb93 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorablesqlresourceslist.go @@ -0,0 +1,87 @@ +package restorables + +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 RestorableSqlResourcesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestorableSqlResourcesListResult +} + +type RestorableSqlResourcesListOperationOptions struct { + RestoreLocation *string + RestoreTimestampInUtc *string +} + +func DefaultRestorableSqlResourcesListOperationOptions() RestorableSqlResourcesListOperationOptions { + return RestorableSqlResourcesListOperationOptions{} +} + +func (o RestorableSqlResourcesListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RestorableSqlResourcesListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RestorableSqlResourcesListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.RestoreLocation != nil { + out.Append("restoreLocation", fmt.Sprintf("%v", *o.RestoreLocation)) + } + if o.RestoreTimestampInUtc != nil { + out.Append("restoreTimestampInUtc", fmt.Sprintf("%v", *o.RestoreTimestampInUtc)) + } + return &out +} + +// RestorableSqlResourcesList ... +func (c RestorablesClient) RestorableSqlResourcesList(ctx context.Context, id RestorableDatabaseAccountId, options RestorableSqlResourcesListOperationOptions) (result RestorableSqlResourcesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/restorableSqlResources", 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 RestorableSqlResourcesListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/method_restorabletableresourceslist.go b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorabletableresourceslist.go new file mode 100644 index 00000000000..9fb261ac67c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorabletableresourceslist.go @@ -0,0 +1,87 @@ +package restorables + +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 RestorableTableResourcesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestorableTableResourcesListResult +} + +type RestorableTableResourcesListOperationOptions struct { + RestoreLocation *string + RestoreTimestampInUtc *string +} + +func DefaultRestorableTableResourcesListOperationOptions() RestorableTableResourcesListOperationOptions { + return RestorableTableResourcesListOperationOptions{} +} + +func (o RestorableTableResourcesListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RestorableTableResourcesListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RestorableTableResourcesListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.RestoreLocation != nil { + out.Append("restoreLocation", fmt.Sprintf("%v", *o.RestoreLocation)) + } + if o.RestoreTimestampInUtc != nil { + out.Append("restoreTimestampInUtc", fmt.Sprintf("%v", *o.RestoreTimestampInUtc)) + } + return &out +} + +// RestorableTableResourcesList ... +func (c RestorablesClient) RestorableTableResourcesList(ctx context.Context, id RestorableDatabaseAccountId, options RestorableTableResourcesListOperationOptions) (result RestorableTableResourcesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/restorableTableResources", 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 RestorableTableResourcesListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/method_restorabletableslist.go b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorabletableslist.go new file mode 100644 index 00000000000..fd4c0a4039d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/method_restorabletableslist.go @@ -0,0 +1,87 @@ +package restorables + +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 RestorableTablesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestorableTablesListResult +} + +type RestorableTablesListOperationOptions struct { + EndTime *string + StartTime *string +} + +func DefaultRestorableTablesListOperationOptions() RestorableTablesListOperationOptions { + return RestorableTablesListOperationOptions{} +} + +func (o RestorableTablesListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RestorableTablesListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RestorableTablesListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + return &out +} + +// RestorableTablesList ... +func (c RestorablesClient) RestorableTablesList(ctx context.Context, id RestorableDatabaseAccountId, options RestorableTablesListOperationOptions) (result RestorableTablesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/restorableTables", 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 RestorableTablesListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/method_sqlresourcesretrievecontinuousbackupinformation.go b/resource-manager/cosmosdb/2024-11-15/restorables/method_sqlresourcesretrievecontinuousbackupinformation.go new file mode 100644 index 00000000000..4cca46834e3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/method_sqlresourcesretrievecontinuousbackupinformation.go @@ -0,0 +1,75 @@ +package restorables + +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 SqlResourcesRetrieveContinuousBackupInformationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BackupInformation +} + +// SqlResourcesRetrieveContinuousBackupInformation ... +func (c RestorablesClient) SqlResourcesRetrieveContinuousBackupInformation(ctx context.Context, id ContainerId, input ContinuousBackupRestoreLocation) (result SqlResourcesRetrieveContinuousBackupInformationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retrieveContinuousBackupInformation", 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 +} + +// SqlResourcesRetrieveContinuousBackupInformationThenPoll performs SqlResourcesRetrieveContinuousBackupInformation then polls until it's completed +func (c RestorablesClient) SqlResourcesRetrieveContinuousBackupInformationThenPoll(ctx context.Context, id ContainerId, input ContinuousBackupRestoreLocation) error { + result, err := c.SqlResourcesRetrieveContinuousBackupInformation(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SqlResourcesRetrieveContinuousBackupInformation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SqlResourcesRetrieveContinuousBackupInformation: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/method_tableresourcesretrievecontinuousbackupinformation.go b/resource-manager/cosmosdb/2024-11-15/restorables/method_tableresourcesretrievecontinuousbackupinformation.go new file mode 100644 index 00000000000..ef4959d98fc --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/method_tableresourcesretrievecontinuousbackupinformation.go @@ -0,0 +1,75 @@ +package restorables + +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 TableResourcesRetrieveContinuousBackupInformationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BackupInformation +} + +// TableResourcesRetrieveContinuousBackupInformation ... +func (c RestorablesClient) TableResourcesRetrieveContinuousBackupInformation(ctx context.Context, id TableId, input ContinuousBackupRestoreLocation) (result TableResourcesRetrieveContinuousBackupInformationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retrieveContinuousBackupInformation", 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 +} + +// TableResourcesRetrieveContinuousBackupInformationThenPoll performs TableResourcesRetrieveContinuousBackupInformation then polls until it's completed +func (c RestorablesClient) TableResourcesRetrieveContinuousBackupInformationThenPoll(ctx context.Context, id TableId, input ContinuousBackupRestoreLocation) error { + result, err := c.TableResourcesRetrieveContinuousBackupInformation(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TableResourcesRetrieveContinuousBackupInformation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TableResourcesRetrieveContinuousBackupInformation: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_backupinformation.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_backupinformation.go new file mode 100644 index 00000000000..252b355762b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_backupinformation.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupInformation struct { + ContinuousBackupInformation *ContinuousBackupInformation `json:"continuousBackupInformation,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_clientencryptionincludedpath.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_clientencryptionincludedpath.go new file mode 100644 index 00000000000..fde02d2b667 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_clientencryptionincludedpath.go @@ -0,0 +1,11 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClientEncryptionIncludedPath struct { + ClientEncryptionKeyId string `json:"clientEncryptionKeyId"` + EncryptionAlgorithm string `json:"encryptionAlgorithm"` + EncryptionType string `json:"encryptionType"` + Path string `json:"path"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_clientencryptionpolicy.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_clientencryptionpolicy.go new file mode 100644 index 00000000000..1abcb79f2f9 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_clientencryptionpolicy.go @@ -0,0 +1,9 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClientEncryptionPolicy struct { + IncludedPaths []ClientEncryptionIncludedPath `json:"includedPaths"` + PolicyFormatVersion int64 `json:"policyFormatVersion"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_compositepath.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_compositepath.go new file mode 100644 index 00000000000..1e5f31a060d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_compositepath.go @@ -0,0 +1,9 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CompositePath struct { + Order *CompositePathSortOrder `json:"order,omitempty"` + Path *string `json:"path,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_computedproperty.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_computedproperty.go new file mode 100644 index 00000000000..972c6499d79 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_computedproperty.go @@ -0,0 +1,9 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputedProperty struct { + Name *string `json:"name,omitempty"` + Query *string `json:"query,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_conflictresolutionpolicy.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_conflictresolutionpolicy.go new file mode 100644 index 00000000000..49e2f60f055 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_conflictresolutionpolicy.go @@ -0,0 +1,10 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConflictResolutionPolicy struct { + ConflictResolutionPath *string `json:"conflictResolutionPath,omitempty"` + ConflictResolutionProcedure *string `json:"conflictResolutionProcedure,omitempty"` + Mode *ConflictResolutionMode `json:"mode,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_containerpartitionkey.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_containerpartitionkey.go new file mode 100644 index 00000000000..40b9f6fa57c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_containerpartitionkey.go @@ -0,0 +1,11 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerPartitionKey struct { + Kind *PartitionKind `json:"kind,omitempty"` + Paths *[]string `json:"paths,omitempty"` + SystemKey *bool `json:"systemKey,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_continuousbackupinformation.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_continuousbackupinformation.go new file mode 100644 index 00000000000..08f4cd99cb0 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_continuousbackupinformation.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContinuousBackupInformation struct { + LatestRestorableTimestamp *string `json:"latestRestorableTimestamp,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_continuousbackuprestorelocation.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_continuousbackuprestorelocation.go new file mode 100644 index 00000000000..81af64b3859 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_continuousbackuprestorelocation.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContinuousBackupRestoreLocation struct { + Location *string `json:"location,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_excludedpath.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_excludedpath.go new file mode 100644 index 00000000000..9a23b963049 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_excludedpath.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExcludedPath struct { + Path *string `json:"path,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_includedpath.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_includedpath.go new file mode 100644 index 00000000000..a39913bd1f7 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_includedpath.go @@ -0,0 +1,9 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IncludedPath struct { + Indexes *[]Indexes `json:"indexes,omitempty"` + Path *string `json:"path,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_indexes.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_indexes.go new file mode 100644 index 00000000000..7e5f75bfb35 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_indexes.go @@ -0,0 +1,10 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Indexes struct { + DataType *DataType `json:"dataType,omitempty"` + Kind *IndexKind `json:"kind,omitempty"` + Precision *int64 `json:"precision,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_indexingpolicy.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_indexingpolicy.go new file mode 100644 index 00000000000..00d9ce00e02 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_indexingpolicy.go @@ -0,0 +1,14 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IndexingPolicy struct { + Automatic *bool `json:"automatic,omitempty"` + CompositeIndexes *[][]CompositePath `json:"compositeIndexes,omitempty"` + ExcludedPaths *[]ExcludedPath `json:"excludedPaths,omitempty"` + IncludedPaths *[]IncludedPath `json:"includedPaths,omitempty"` + IndexingMode *IndexingMode `json:"indexingMode,omitempty"` + SpatialIndexes *[]SpatialSpec `json:"spatialIndexes,omitempty"` + VectorIndexes *[]VectorIndex `json:"vectorIndexes,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabledatabaseaccountgetresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabledatabaseaccountgetresult.go new file mode 100644 index 00000000000..d0bc6d5723c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabledatabaseaccountgetresult.go @@ -0,0 +1,12 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableDatabaseAccountGetResult struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RestorableDatabaseAccountProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabledatabaseaccountproperties.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabledatabaseaccountproperties.go new file mode 100644 index 00000000000..84d357fa180 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabledatabaseaccountproperties.go @@ -0,0 +1,55 @@ +package restorables + +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 RestorableDatabaseAccountProperties struct { + AccountName *string `json:"accountName,omitempty"` + ApiType *ApiType `json:"apiType,omitempty"` + CreationTime *string `json:"creationTime,omitempty"` + DeletionTime *string `json:"deletionTime,omitempty"` + OldestRestorableTime *string `json:"oldestRestorableTime,omitempty"` + RestorableLocations *[]RestorableLocationResource `json:"restorableLocations,omitempty"` +} + +func (o *RestorableDatabaseAccountProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RestorableDatabaseAccountProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +func (o *RestorableDatabaseAccountProperties) GetDeletionTimeAsTime() (*time.Time, error) { + if o.DeletionTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeletionTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RestorableDatabaseAccountProperties) SetDeletionTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeletionTime = &formatted +} + +func (o *RestorableDatabaseAccountProperties) GetOldestRestorableTimeAsTime() (*time.Time, error) { + if o.OldestRestorableTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRestorableTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RestorableDatabaseAccountProperties) SetOldestRestorableTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRestorableTime = &formatted +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabledatabaseaccountslistresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabledatabaseaccountslistresult.go new file mode 100644 index 00000000000..011fe15450f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabledatabaseaccountslistresult.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableDatabaseAccountsListResult struct { + Value *[]RestorableDatabaseAccountGetResult `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlindatabasegetresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlindatabasegetresult.go new file mode 100644 index 00000000000..052f580229e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlindatabasegetresult.go @@ -0,0 +1,11 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableGremlinDatabaseGetResult struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RestorableGremlinDatabaseProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlindatabaseproperties.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlindatabaseproperties.go new file mode 100644 index 00000000000..7a6154a26a3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlindatabaseproperties.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableGremlinDatabaseProperties struct { + Resource *RestorableGremlinDatabasePropertiesResource `json:"resource,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlindatabasepropertiesresource.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlindatabasepropertiesresource.go new file mode 100644 index 00000000000..997401db696 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlindatabasepropertiesresource.go @@ -0,0 +1,14 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableGremlinDatabasePropertiesResource struct { + CanUndelete *string `json:"canUndelete,omitempty"` + CanUndeleteReason *string `json:"canUndeleteReason,omitempty"` + EventTimestamp *string `json:"eventTimestamp,omitempty"` + OperationType *OperationType `json:"operationType,omitempty"` + OwnerId *string `json:"ownerId,omitempty"` + OwnerResourceId *string `json:"ownerResourceId,omitempty"` + Rid *string `json:"_rid,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlindatabaseslistresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlindatabaseslistresult.go new file mode 100644 index 00000000000..4f34856779c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlindatabaseslistresult.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableGremlinDatabasesListResult struct { + Value *[]RestorableGremlinDatabaseGetResult `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlingraphgetresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlingraphgetresult.go new file mode 100644 index 00000000000..e43546d5cd0 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlingraphgetresult.go @@ -0,0 +1,11 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableGremlinGraphGetResult struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RestorableGremlinGraphProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlingraphproperties.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlingraphproperties.go new file mode 100644 index 00000000000..c1c934d20c7 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlingraphproperties.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableGremlinGraphProperties struct { + Resource *RestorableGremlinGraphPropertiesResource `json:"resource,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlingraphpropertiesresource.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlingraphpropertiesresource.go new file mode 100644 index 00000000000..ad79d792d5d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlingraphpropertiesresource.go @@ -0,0 +1,14 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableGremlinGraphPropertiesResource struct { + CanUndelete *string `json:"canUndelete,omitempty"` + CanUndeleteReason *string `json:"canUndeleteReason,omitempty"` + EventTimestamp *string `json:"eventTimestamp,omitempty"` + OperationType *OperationType `json:"operationType,omitempty"` + OwnerId *string `json:"ownerId,omitempty"` + OwnerResourceId *string `json:"ownerResourceId,omitempty"` + Rid *string `json:"_rid,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlingraphslistresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlingraphslistresult.go new file mode 100644 index 00000000000..e70760618f3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlingraphslistresult.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableGremlinGraphsListResult struct { + Value *[]RestorableGremlinGraphGetResult `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlinresourcesgetresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlinresourcesgetresult.go new file mode 100644 index 00000000000..6675d26da5a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlinresourcesgetresult.go @@ -0,0 +1,12 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableGremlinResourcesGetResult struct { + DatabaseName *string `json:"databaseName,omitempty"` + GraphNames *[]string `json:"graphNames,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlinresourceslistresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlinresourceslistresult.go new file mode 100644 index 00000000000..8f395217fdd --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablegremlinresourceslistresult.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableGremlinResourcesListResult struct { + Value *[]RestorableGremlinResourcesGetResult `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablelocationresource.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablelocationresource.go new file mode 100644 index 00000000000..46fbc7b9554 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablelocationresource.go @@ -0,0 +1,41 @@ +package restorables + +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 RestorableLocationResource struct { + CreationTime *string `json:"creationTime,omitempty"` + DeletionTime *string `json:"deletionTime,omitempty"` + LocationName *string `json:"locationName,omitempty"` + RegionalDatabaseAccountInstanceId *string `json:"regionalDatabaseAccountInstanceId,omitempty"` +} + +func (o *RestorableLocationResource) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RestorableLocationResource) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +func (o *RestorableLocationResource) GetDeletionTimeAsTime() (*time.Time, error) { + if o.DeletionTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeletionTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RestorableLocationResource) SetDeletionTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeletionTime = &formatted +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbcollectiongetresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbcollectiongetresult.go new file mode 100644 index 00000000000..aa03383b64f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbcollectiongetresult.go @@ -0,0 +1,11 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableMongodbCollectionGetResult struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RestorableMongodbCollectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbcollectionproperties.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbcollectionproperties.go new file mode 100644 index 00000000000..64d6647f780 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbcollectionproperties.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableMongodbCollectionProperties struct { + Resource *RestorableMongodbCollectionPropertiesResource `json:"resource,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbcollectionpropertiesresource.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbcollectionpropertiesresource.go new file mode 100644 index 00000000000..456acc7c3a8 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbcollectionpropertiesresource.go @@ -0,0 +1,14 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableMongodbCollectionPropertiesResource struct { + CanUndelete *string `json:"canUndelete,omitempty"` + CanUndeleteReason *string `json:"canUndeleteReason,omitempty"` + EventTimestamp *string `json:"eventTimestamp,omitempty"` + OperationType *OperationType `json:"operationType,omitempty"` + OwnerId *string `json:"ownerId,omitempty"` + OwnerResourceId *string `json:"ownerResourceId,omitempty"` + Rid *string `json:"_rid,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbcollectionslistresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbcollectionslistresult.go new file mode 100644 index 00000000000..960b7afb530 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbcollectionslistresult.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableMongodbCollectionsListResult struct { + Value *[]RestorableMongodbCollectionGetResult `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbdatabasegetresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbdatabasegetresult.go new file mode 100644 index 00000000000..8c46448769f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbdatabasegetresult.go @@ -0,0 +1,11 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableMongodbDatabaseGetResult struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RestorableMongodbDatabaseProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbdatabaseproperties.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbdatabaseproperties.go new file mode 100644 index 00000000000..867e6d3526e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbdatabaseproperties.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableMongodbDatabaseProperties struct { + Resource *RestorableMongodbDatabasePropertiesResource `json:"resource,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbdatabasepropertiesresource.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbdatabasepropertiesresource.go new file mode 100644 index 00000000000..3c020336b2b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbdatabasepropertiesresource.go @@ -0,0 +1,14 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableMongodbDatabasePropertiesResource struct { + CanUndelete *string `json:"canUndelete,omitempty"` + CanUndeleteReason *string `json:"canUndeleteReason,omitempty"` + EventTimestamp *string `json:"eventTimestamp,omitempty"` + OperationType *OperationType `json:"operationType,omitempty"` + OwnerId *string `json:"ownerId,omitempty"` + OwnerResourceId *string `json:"ownerResourceId,omitempty"` + Rid *string `json:"_rid,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbdatabaseslistresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbdatabaseslistresult.go new file mode 100644 index 00000000000..70b6395d786 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbdatabaseslistresult.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableMongodbDatabasesListResult struct { + Value *[]RestorableMongodbDatabaseGetResult `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbresourcesgetresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbresourcesgetresult.go new file mode 100644 index 00000000000..6c028f2a915 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbresourcesgetresult.go @@ -0,0 +1,12 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableMongodbResourcesGetResult struct { + CollectionNames *[]string `json:"collectionNames,omitempty"` + DatabaseName *string `json:"databaseName,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbresourceslistresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbresourceslistresult.go new file mode 100644 index 00000000000..aad5dab17f1 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablemongodbresourceslistresult.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableMongodbResourcesListResult struct { + Value *[]RestorableMongodbResourcesGetResult `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqlcontainergetresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqlcontainergetresult.go new file mode 100644 index 00000000000..a12b19b4d30 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqlcontainergetresult.go @@ -0,0 +1,11 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableSqlContainerGetResult struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RestorableSqlContainerProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqlcontainerproperties.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqlcontainerproperties.go new file mode 100644 index 00000000000..c8edea82873 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqlcontainerproperties.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableSqlContainerProperties struct { + Resource *RestorableSqlContainerPropertiesResource `json:"resource,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqlcontainerpropertiesresource.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqlcontainerpropertiesresource.go new file mode 100644 index 00000000000..a21a5337cab --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqlcontainerpropertiesresource.go @@ -0,0 +1,15 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableSqlContainerPropertiesResource struct { + CanUndelete *string `json:"canUndelete,omitempty"` + CanUndeleteReason *string `json:"canUndeleteReason,omitempty"` + Container *RestorableSqlContainerPropertiesResourceContainer `json:"container,omitempty"` + EventTimestamp *string `json:"eventTimestamp,omitempty"` + OperationType *OperationType `json:"operationType,omitempty"` + OwnerId *string `json:"ownerId,omitempty"` + OwnerResourceId *string `json:"ownerResourceId,omitempty"` + Rid *string `json:"_rid,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqlcontainerpropertiesresourcecontainer.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqlcontainerpropertiesresourcecontainer.go new file mode 100644 index 00000000000..9b648667a71 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqlcontainerpropertiesresourcecontainer.go @@ -0,0 +1,23 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableSqlContainerPropertiesResourceContainer struct { + AnalyticalStorageTtl *int64 `json:"analyticalStorageTtl,omitempty"` + ClientEncryptionPolicy *ClientEncryptionPolicy `json:"clientEncryptionPolicy,omitempty"` + ComputedProperties *[]ComputedProperty `json:"computedProperties,omitempty"` + ConflictResolutionPolicy *ConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DefaultTtl *int64 `json:"defaultTtl,omitempty"` + Etag *string `json:"_etag,omitempty"` + Id *string `json:"id,omitempty"` + IndexingPolicy *IndexingPolicy `json:"indexingPolicy,omitempty"` + PartitionKey *ContainerPartitionKey `json:"partitionKey,omitempty"` + RestoreParameters *RestoreParametersBase `json:"restoreParameters,omitempty"` + Rid *string `json:"_rid,omitempty"` + Self *string `json:"_self,omitempty"` + Ts *float64 `json:"_ts,omitempty"` + UniqueKeyPolicy *UniqueKeyPolicy `json:"uniqueKeyPolicy,omitempty"` + VectorEmbeddingPolicy *VectorEmbeddingPolicy `json:"vectorEmbeddingPolicy,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqlcontainerslistresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqlcontainerslistresult.go new file mode 100644 index 00000000000..8c2421f9df2 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqlcontainerslistresult.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableSqlContainersListResult struct { + Value *[]RestorableSqlContainerGetResult `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqldatabasegetresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqldatabasegetresult.go new file mode 100644 index 00000000000..c3d4c8d2857 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqldatabasegetresult.go @@ -0,0 +1,11 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableSqlDatabaseGetResult struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RestorableSqlDatabaseProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqldatabaseproperties.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqldatabaseproperties.go new file mode 100644 index 00000000000..38b12712216 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqldatabaseproperties.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableSqlDatabaseProperties struct { + Resource *RestorableSqlDatabasePropertiesResource `json:"resource,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqldatabasepropertiesresource.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqldatabasepropertiesresource.go new file mode 100644 index 00000000000..7ac70fc326e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqldatabasepropertiesresource.go @@ -0,0 +1,15 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableSqlDatabasePropertiesResource struct { + CanUndelete *string `json:"canUndelete,omitempty"` + CanUndeleteReason *string `json:"canUndeleteReason,omitempty"` + Database *RestorableSqlDatabasePropertiesResourceDatabase `json:"database,omitempty"` + EventTimestamp *string `json:"eventTimestamp,omitempty"` + OperationType *OperationType `json:"operationType,omitempty"` + OwnerId *string `json:"ownerId,omitempty"` + OwnerResourceId *string `json:"ownerResourceId,omitempty"` + Rid *string `json:"_rid,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqldatabasepropertiesresourcedatabase.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqldatabasepropertiesresourcedatabase.go new file mode 100644 index 00000000000..ff04d5b2e51 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqldatabasepropertiesresourcedatabase.go @@ -0,0 +1,16 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableSqlDatabasePropertiesResourceDatabase struct { + Colls *string `json:"_colls,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + Etag *string `json:"_etag,omitempty"` + Id *string `json:"id,omitempty"` + RestoreParameters *RestoreParametersBase `json:"restoreParameters,omitempty"` + Rid *string `json:"_rid,omitempty"` + Self *string `json:"_self,omitempty"` + Ts *float64 `json:"_ts,omitempty"` + Users *string `json:"_users,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqldatabaseslistresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqldatabaseslistresult.go new file mode 100644 index 00000000000..a536abebab5 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqldatabaseslistresult.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableSqlDatabasesListResult struct { + Value *[]RestorableSqlDatabaseGetResult `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqlresourcesgetresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqlresourcesgetresult.go new file mode 100644 index 00000000000..9b75a032338 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqlresourcesgetresult.go @@ -0,0 +1,12 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableSqlResourcesGetResult struct { + CollectionNames *[]string `json:"collectionNames,omitempty"` + DatabaseName *string `json:"databaseName,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqlresourceslistresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqlresourceslistresult.go new file mode 100644 index 00000000000..30f82c4ee4b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorablesqlresourceslistresult.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableSqlResourcesListResult struct { + Value *[]RestorableSqlResourcesGetResult `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabletablegetresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabletablegetresult.go new file mode 100644 index 00000000000..d1ae1330d7f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabletablegetresult.go @@ -0,0 +1,11 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableTableGetResult struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RestorableTableProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabletableproperties.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabletableproperties.go new file mode 100644 index 00000000000..982ec6b4b2a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabletableproperties.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableTableProperties struct { + Resource *RestorableTablePropertiesResource `json:"resource,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabletablepropertiesresource.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabletablepropertiesresource.go new file mode 100644 index 00000000000..637c198c239 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabletablepropertiesresource.go @@ -0,0 +1,14 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableTablePropertiesResource struct { + CanUndelete *string `json:"canUndelete,omitempty"` + CanUndeleteReason *string `json:"canUndeleteReason,omitempty"` + EventTimestamp *string `json:"eventTimestamp,omitempty"` + OperationType *OperationType `json:"operationType,omitempty"` + OwnerId *string `json:"ownerId,omitempty"` + OwnerResourceId *string `json:"ownerResourceId,omitempty"` + Rid *string `json:"_rid,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabletableresourcesgetresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabletableresourcesgetresult.go new file mode 100644 index 00000000000..6d06efbb1ad --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabletableresourcesgetresult.go @@ -0,0 +1,10 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableTableResourcesGetResult struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabletableresourceslistresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabletableresourceslistresult.go new file mode 100644 index 00000000000..021455f4326 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabletableresourceslistresult.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableTableResourcesListResult struct { + Value *[]RestorableTableResourcesGetResult `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabletableslistresult.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabletableslistresult.go new file mode 100644 index 00000000000..640831007a3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restorabletableslistresult.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableTablesListResult struct { + Value *[]RestorableTableGetResult `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_restoreparametersbase.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_restoreparametersbase.go new file mode 100644 index 00000000000..72e50f652e1 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_restoreparametersbase.go @@ -0,0 +1,28 @@ +package restorables + +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 RestoreParametersBase struct { + RestoreSource *string `json:"restoreSource,omitempty"` + RestoreTimestampInUtc *string `json:"restoreTimestampInUtc,omitempty"` + RestoreWithTtlDisabled *bool `json:"restoreWithTtlDisabled,omitempty"` +} + +func (o *RestoreParametersBase) GetRestoreTimestampInUtcAsTime() (*time.Time, error) { + if o.RestoreTimestampInUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RestoreTimestampInUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *RestoreParametersBase) SetRestoreTimestampInUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RestoreTimestampInUtc = &formatted +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_spatialspec.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_spatialspec.go new file mode 100644 index 00000000000..5aac192f5bf --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_spatialspec.go @@ -0,0 +1,9 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SpatialSpec struct { + Path *string `json:"path,omitempty"` + Types *[]SpatialType `json:"types,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_uniquekey.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_uniquekey.go new file mode 100644 index 00000000000..efdebecc55b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_uniquekey.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UniqueKey struct { + Paths *[]string `json:"paths,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_uniquekeypolicy.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_uniquekeypolicy.go new file mode 100644 index 00000000000..d9ddcb04a30 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_uniquekeypolicy.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UniqueKeyPolicy struct { + UniqueKeys *[]UniqueKey `json:"uniqueKeys,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_vectorembedding.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_vectorembedding.go new file mode 100644 index 00000000000..6514adca28d --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_vectorembedding.go @@ -0,0 +1,11 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VectorEmbedding struct { + DataType VectorDataType `json:"dataType"` + Dimensions int64 `json:"dimensions"` + DistanceFunction DistanceFunction `json:"distanceFunction"` + Path string `json:"path"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_vectorembeddingpolicy.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_vectorembeddingpolicy.go new file mode 100644 index 00000000000..50b1d0ab266 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_vectorembeddingpolicy.go @@ -0,0 +1,8 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VectorEmbeddingPolicy struct { + VectorEmbeddings *[]VectorEmbedding `json:"vectorEmbeddings,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/model_vectorindex.go b/resource-manager/cosmosdb/2024-11-15/restorables/model_vectorindex.go new file mode 100644 index 00000000000..9569eb16b13 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/model_vectorindex.go @@ -0,0 +1,9 @@ +package restorables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VectorIndex struct { + Path string `json:"path"` + Type VectorIndexType `json:"type"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/restorables/version.go b/resource-manager/cosmosdb/2024-11-15/restorables/version.go new file mode 100644 index 00000000000..99d9a7d663a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/restorables/version.go @@ -0,0 +1,10 @@ +package restorables + +// 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-11-15" + +func userAgent() string { + return "hashicorp/go-azure-sdk/restorables/2024-11-15" +} diff --git a/resource-manager/cosmosdb/2024-11-15/services/README.md b/resource-manager/cosmosdb/2024-11-15/services/README.md new file mode 100644 index 00000000000..b24d9c3b4b5 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/services/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/services` Documentation + +The `services` SDK allows for interaction with Azure Resource Manager `cosmosdb` (API Version `2024-11-15`). + +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/cosmosdb/2024-11-15/services" +``` + + +### Client Initialization + +```go +client := services.NewServicesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ServicesClient.ServiceList` + +```go +ctx := context.TODO() +id := services.NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + +read, err := client.ServiceList(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/cosmosdb/2024-11-15/services/client.go b/resource-manager/cosmosdb/2024-11-15/services/client.go new file mode 100644 index 00000000000..24dd876692e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/services/client.go @@ -0,0 +1,26 @@ +package services + +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 ServicesClient struct { + Client *resourcemanager.Client +} + +func NewServicesClientWithBaseURI(sdkApi sdkEnv.Api) (*ServicesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "services", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServicesClient: %+v", err) + } + + return &ServicesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/services/constants.go b/resource-manager/cosmosdb/2024-11-15/services/constants.go new file mode 100644 index 00000000000..b12c7bb9cc8 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/services/constants.go @@ -0,0 +1,195 @@ +package services + +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 DedicatedGatewayType string + +const ( + DedicatedGatewayTypeDistributedQuery DedicatedGatewayType = "DistributedQuery" + DedicatedGatewayTypeIntegratedCache DedicatedGatewayType = "IntegratedCache" +) + +func PossibleValuesForDedicatedGatewayType() []string { + return []string{ + string(DedicatedGatewayTypeDistributedQuery), + string(DedicatedGatewayTypeIntegratedCache), + } +} + +func (s *DedicatedGatewayType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDedicatedGatewayType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDedicatedGatewayType(input string) (*DedicatedGatewayType, error) { + vals := map[string]DedicatedGatewayType{ + "distributedquery": DedicatedGatewayTypeDistributedQuery, + "integratedcache": DedicatedGatewayTypeIntegratedCache, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DedicatedGatewayType(input) + return &out, nil +} + +type ServiceSize string + +const ( + ServiceSizeCosmosPointDEights ServiceSize = "Cosmos.D8s" + ServiceSizeCosmosPointDFours ServiceSize = "Cosmos.D4s" + ServiceSizeCosmosPointDOneSixs ServiceSize = "Cosmos.D16s" +) + +func PossibleValuesForServiceSize() []string { + return []string{ + string(ServiceSizeCosmosPointDEights), + string(ServiceSizeCosmosPointDFours), + string(ServiceSizeCosmosPointDOneSixs), + } +} + +func (s *ServiceSize) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceSize(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceSize(input string) (*ServiceSize, error) { + vals := map[string]ServiceSize{ + "cosmos.d8s": ServiceSizeCosmosPointDEights, + "cosmos.d4s": ServiceSizeCosmosPointDFours, + "cosmos.d16s": ServiceSizeCosmosPointDOneSixs, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceSize(input) + return &out, nil +} + +type ServiceStatus string + +const ( + ServiceStatusCreating ServiceStatus = "Creating" + ServiceStatusDeleting ServiceStatus = "Deleting" + ServiceStatusError ServiceStatus = "Error" + ServiceStatusRunning ServiceStatus = "Running" + ServiceStatusStopped ServiceStatus = "Stopped" + ServiceStatusUpdating ServiceStatus = "Updating" +) + +func PossibleValuesForServiceStatus() []string { + return []string{ + string(ServiceStatusCreating), + string(ServiceStatusDeleting), + string(ServiceStatusError), + string(ServiceStatusRunning), + string(ServiceStatusStopped), + string(ServiceStatusUpdating), + } +} + +func (s *ServiceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceStatus(input string) (*ServiceStatus, error) { + vals := map[string]ServiceStatus{ + "creating": ServiceStatusCreating, + "deleting": ServiceStatusDeleting, + "error": ServiceStatusError, + "running": ServiceStatusRunning, + "stopped": ServiceStatusStopped, + "updating": ServiceStatusUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceStatus(input) + return &out, nil +} + +type ServiceType string + +const ( + ServiceTypeDataTransfer ServiceType = "DataTransfer" + ServiceTypeGraphAPICompute ServiceType = "GraphAPICompute" + ServiceTypeMaterializedViewsBuilder ServiceType = "MaterializedViewsBuilder" + ServiceTypeSqlDedicatedGateway ServiceType = "SqlDedicatedGateway" +) + +func PossibleValuesForServiceType() []string { + return []string{ + string(ServiceTypeDataTransfer), + string(ServiceTypeGraphAPICompute), + string(ServiceTypeMaterializedViewsBuilder), + string(ServiceTypeSqlDedicatedGateway), + } +} + +func (s *ServiceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceType(input string) (*ServiceType, error) { + vals := map[string]ServiceType{ + "datatransfer": ServiceTypeDataTransfer, + "graphapicompute": ServiceTypeGraphAPICompute, + "materializedviewsbuilder": ServiceTypeMaterializedViewsBuilder, + "sqldedicatedgateway": ServiceTypeSqlDedicatedGateway, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceType(input) + return &out, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/services/id_databaseaccount.go b/resource-manager/cosmosdb/2024-11-15/services/id_databaseaccount.go new file mode 100644 index 00000000000..16e2d04be53 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/services/id_databaseaccount.go @@ -0,0 +1,130 @@ +package services + +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(&DatabaseAccountId{}) +} + +var _ resourceids.ResourceId = &DatabaseAccountId{} + +// DatabaseAccountId is a struct representing the Resource ID for a Database Account +type DatabaseAccountId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string +} + +// NewDatabaseAccountID returns a new DatabaseAccountId struct +func NewDatabaseAccountID(subscriptionId string, resourceGroupName string, databaseAccountName string) DatabaseAccountId { + return DatabaseAccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + } +} + +// ParseDatabaseAccountID parses 'input' into a DatabaseAccountId +func ParseDatabaseAccountID(input string) (*DatabaseAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseAccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDatabaseAccountIDInsensitively parses 'input' case-insensitively into a DatabaseAccountId +// note: this method should only be used for API response data and not user input +func ParseDatabaseAccountIDInsensitively(input string) (*DatabaseAccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseAccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseAccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DatabaseAccountId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + return nil +} + +// ValidateDatabaseAccountID checks that 'input' can be parsed as a Database Account ID +func ValidateDatabaseAccountID(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 := ParseDatabaseAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Database Account ID +func (id DatabaseAccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Database Account ID +func (id DatabaseAccountId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + } +} + +// String returns a human-readable description of this Database Account ID +func (id DatabaseAccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + } + return fmt.Sprintf("Database Account (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/services/id_databaseaccount_test.go b/resource-manager/cosmosdb/2024-11-15/services/id_databaseaccount_test.go new file mode 100644 index 00000000000..1b08a40dab2 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/services/id_databaseaccount_test.go @@ -0,0 +1,282 @@ +package services + +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 = &DatabaseAccountId{} + +func TestNewDatabaseAccountID(t *testing.T) { + id := NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } +} + +func TestFormatDatabaseAccountID(t *testing.T) { + actual := NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDatabaseAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Expected: &DatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseAccountID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + } +} + +func TestParseDatabaseAccountIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseAccountId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Expected: &DatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Expected: &DatabaseAccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseAccountIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + } +} + +func TestSegmentsForDatabaseAccountId(t *testing.T) { + segments := DatabaseAccountId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DatabaseAccountId 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/cosmosdb/2024-11-15/services/method_servicelist.go b/resource-manager/cosmosdb/2024-11-15/services/method_servicelist.go new file mode 100644 index 00000000000..767b21042fc --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/services/method_servicelist.go @@ -0,0 +1,54 @@ +package services + +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 ServiceListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ServiceResourceListResult +} + +// ServiceList ... +func (c ServicesClient) ServiceList(ctx context.Context, id DatabaseAccountId) (result ServiceListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/services", 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 ServiceResourceListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/services/model_datatransferserviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/services/model_datatransferserviceresourceproperties.go new file mode 100644 index 00000000000..6564d315929 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/services/model_datatransferserviceresourceproperties.go @@ -0,0 +1,73 @@ +package services + +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 _ ServiceResourceProperties = DataTransferServiceResourceProperties{} + +type DataTransferServiceResourceProperties struct { + Locations *[]RegionalServiceResource `json:"locations,omitempty"` + + // Fields inherited from ServiceResourceProperties + + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s DataTransferServiceResourceProperties) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return BaseServiceResourcePropertiesImpl{ + CreationTime: s.CreationTime, + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + Status: s.Status, + } +} + +func (o *DataTransferServiceResourceProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DataTransferServiceResourceProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +var _ json.Marshaler = DataTransferServiceResourceProperties{} + +func (s DataTransferServiceResourceProperties) MarshalJSON() ([]byte, error) { + type wrapper DataTransferServiceResourceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DataTransferServiceResourceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DataTransferServiceResourceProperties: %+v", err) + } + + decoded["serviceType"] = "DataTransfer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DataTransferServiceResourceProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/services/model_graphapicomputeregionalserviceresource.go b/resource-manager/cosmosdb/2024-11-15/services/model_graphapicomputeregionalserviceresource.go new file mode 100644 index 00000000000..96b20a11edc --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/services/model_graphapicomputeregionalserviceresource.go @@ -0,0 +1,11 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GraphAPIComputeRegionalServiceResource struct { + GraphApiComputeEndpoint *string `json:"graphApiComputeEndpoint,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Status *ServiceStatus `json:"status,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/services/model_graphapicomputeserviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/services/model_graphapicomputeserviceresourceproperties.go new file mode 100644 index 00000000000..a738fff301e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/services/model_graphapicomputeserviceresourceproperties.go @@ -0,0 +1,74 @@ +package services + +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 _ ServiceResourceProperties = GraphAPIComputeServiceResourceProperties{} + +type GraphAPIComputeServiceResourceProperties struct { + GraphApiComputeEndpoint *string `json:"graphApiComputeEndpoint,omitempty"` + Locations *[]GraphAPIComputeRegionalServiceResource `json:"locations,omitempty"` + + // Fields inherited from ServiceResourceProperties + + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s GraphAPIComputeServiceResourceProperties) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return BaseServiceResourcePropertiesImpl{ + CreationTime: s.CreationTime, + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + Status: s.Status, + } +} + +func (o *GraphAPIComputeServiceResourceProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *GraphAPIComputeServiceResourceProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +var _ json.Marshaler = GraphAPIComputeServiceResourceProperties{} + +func (s GraphAPIComputeServiceResourceProperties) MarshalJSON() ([]byte, error) { + type wrapper GraphAPIComputeServiceResourceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GraphAPIComputeServiceResourceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GraphAPIComputeServiceResourceProperties: %+v", err) + } + + decoded["serviceType"] = "GraphAPICompute" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GraphAPIComputeServiceResourceProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/services/model_materializedviewsbuilderserviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/services/model_materializedviewsbuilderserviceresourceproperties.go new file mode 100644 index 00000000000..3fb1d86d5e4 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/services/model_materializedviewsbuilderserviceresourceproperties.go @@ -0,0 +1,73 @@ +package services + +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 _ ServiceResourceProperties = MaterializedViewsBuilderServiceResourceProperties{} + +type MaterializedViewsBuilderServiceResourceProperties struct { + Locations *[]RegionalServiceResource `json:"locations,omitempty"` + + // Fields inherited from ServiceResourceProperties + + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s MaterializedViewsBuilderServiceResourceProperties) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return BaseServiceResourcePropertiesImpl{ + CreationTime: s.CreationTime, + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + Status: s.Status, + } +} + +func (o *MaterializedViewsBuilderServiceResourceProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MaterializedViewsBuilderServiceResourceProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +var _ json.Marshaler = MaterializedViewsBuilderServiceResourceProperties{} + +func (s MaterializedViewsBuilderServiceResourceProperties) MarshalJSON() ([]byte, error) { + type wrapper MaterializedViewsBuilderServiceResourceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MaterializedViewsBuilderServiceResourceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MaterializedViewsBuilderServiceResourceProperties: %+v", err) + } + + decoded["serviceType"] = "MaterializedViewsBuilder" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MaterializedViewsBuilderServiceResourceProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/services/model_regionalserviceresource.go b/resource-manager/cosmosdb/2024-11-15/services/model_regionalserviceresource.go new file mode 100644 index 00000000000..355e61f45da --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/services/model_regionalserviceresource.go @@ -0,0 +1,10 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegionalServiceResource struct { + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Status *ServiceStatus `json:"status,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/services/model_serviceresource.go b/resource-manager/cosmosdb/2024-11-15/services/model_serviceresource.go new file mode 100644 index 00000000000..a60e063e6c2 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/services/model_serviceresource.go @@ -0,0 +1,48 @@ +package services + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties ServiceResourceProperties `json:"properties"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ServiceResource{} + +func (s *ServiceResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Id = decoded.Id + s.Name = decoded.Name + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ServiceResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalServiceResourcePropertiesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ServiceResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/services/model_serviceresourcelistresult.go b/resource-manager/cosmosdb/2024-11-15/services/model_serviceresourcelistresult.go new file mode 100644 index 00000000000..9ca2a18c9ab --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/services/model_serviceresourcelistresult.go @@ -0,0 +1,8 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceResourceListResult struct { + Value *[]ServiceResource `json:"value,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/services/model_serviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/services/model_serviceresourceproperties.go new file mode 100644 index 00000000000..7488a4b370b --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/services/model_serviceresourceproperties.go @@ -0,0 +1,103 @@ +package services + +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 ServiceResourceProperties interface { + ServiceResourceProperties() BaseServiceResourcePropertiesImpl +} + +var _ ServiceResourceProperties = BaseServiceResourcePropertiesImpl{} + +type BaseServiceResourcePropertiesImpl struct { + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s BaseServiceResourcePropertiesImpl) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return s +} + +var _ ServiceResourceProperties = RawServiceResourcePropertiesImpl{} + +// RawServiceResourcePropertiesImpl 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 RawServiceResourcePropertiesImpl struct { + serviceResourceProperties BaseServiceResourcePropertiesImpl + Type string + Values map[string]interface{} +} + +func (s RawServiceResourcePropertiesImpl) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return s.serviceResourceProperties +} + +func UnmarshalServiceResourcePropertiesImplementation(input []byte) (ServiceResourceProperties, 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 ServiceResourceProperties into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["serviceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "DataTransfer") { + var out DataTransferServiceResourceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DataTransferServiceResourceProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GraphAPICompute") { + var out GraphAPIComputeServiceResourceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GraphAPIComputeServiceResourceProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MaterializedViewsBuilder") { + var out MaterializedViewsBuilderServiceResourceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MaterializedViewsBuilderServiceResourceProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SqlDedicatedGateway") { + var out SqlDedicatedGatewayServiceResourceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SqlDedicatedGatewayServiceResourceProperties: %+v", err) + } + return out, nil + } + + var parent BaseServiceResourcePropertiesImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseServiceResourcePropertiesImpl: %+v", err) + } + + return RawServiceResourcePropertiesImpl{ + serviceResourceProperties: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/cosmosdb/2024-11-15/services/model_sqldedicatedgatewayregionalserviceresource.go b/resource-manager/cosmosdb/2024-11-15/services/model_sqldedicatedgatewayregionalserviceresource.go new file mode 100644 index 00000000000..01a0bf84530 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/services/model_sqldedicatedgatewayregionalserviceresource.go @@ -0,0 +1,11 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlDedicatedGatewayRegionalServiceResource struct { + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + SqlDedicatedGatewayEndpoint *string `json:"sqlDedicatedGatewayEndpoint,omitempty"` + Status *ServiceStatus `json:"status,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/services/model_sqldedicatedgatewayserviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/services/model_sqldedicatedgatewayserviceresourceproperties.go new file mode 100644 index 00000000000..1be4bb3bb59 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/services/model_sqldedicatedgatewayserviceresourceproperties.go @@ -0,0 +1,75 @@ +package services + +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 _ ServiceResourceProperties = SqlDedicatedGatewayServiceResourceProperties{} + +type SqlDedicatedGatewayServiceResourceProperties struct { + DedicatedGatewayType *DedicatedGatewayType `json:"dedicatedGatewayType,omitempty"` + Locations *[]SqlDedicatedGatewayRegionalServiceResource `json:"locations,omitempty"` + SqlDedicatedGatewayEndpoint *string `json:"sqlDedicatedGatewayEndpoint,omitempty"` + + // Fields inherited from ServiceResourceProperties + + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s SqlDedicatedGatewayServiceResourceProperties) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return BaseServiceResourcePropertiesImpl{ + CreationTime: s.CreationTime, + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + Status: s.Status, + } +} + +func (o *SqlDedicatedGatewayServiceResourceProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SqlDedicatedGatewayServiceResourceProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +var _ json.Marshaler = SqlDedicatedGatewayServiceResourceProperties{} + +func (s SqlDedicatedGatewayServiceResourceProperties) MarshalJSON() ([]byte, error) { + type wrapper SqlDedicatedGatewayServiceResourceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SqlDedicatedGatewayServiceResourceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SqlDedicatedGatewayServiceResourceProperties: %+v", err) + } + + decoded["serviceType"] = "SqlDedicatedGateway" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SqlDedicatedGatewayServiceResourceProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/services/version.go b/resource-manager/cosmosdb/2024-11-15/services/version.go new file mode 100644 index 00000000000..0064e3e9b65 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/services/version.go @@ -0,0 +1,10 @@ +package services + +// 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-11-15" + +func userAgent() string { + return "hashicorp/go-azure-sdk/services/2024-11-15" +} diff --git a/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/README.md b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/README.md new file mode 100644 index 00000000000..1b50c0cfdca --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/README.md @@ -0,0 +1,65 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway` Documentation + +The `sqldedicatedgateway` SDK allows for interaction with Azure Resource Manager `cosmosdb` (API Version `2024-11-15`). + +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/cosmosdb/2024-11-15/sqldedicatedgateway" +``` + + +### Client Initialization + +```go +client := sqldedicatedgateway.NewSqlDedicatedGatewayClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SqlDedicatedGatewayClient.ServiceCreate` + +```go +ctx := context.TODO() +id := sqldedicatedgateway.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "serviceName") + +payload := sqldedicatedgateway.ServiceResourceCreateUpdateParameters{ + // ... +} + + +if err := client.ServiceCreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SqlDedicatedGatewayClient.ServiceDelete` + +```go +ctx := context.TODO() +id := sqldedicatedgateway.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "serviceName") + +if err := client.ServiceDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SqlDedicatedGatewayClient.ServiceGet` + +```go +ctx := context.TODO() +id := sqldedicatedgateway.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "serviceName") + +read, err := client.ServiceGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/client.go b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/client.go new file mode 100644 index 00000000000..36faaebb619 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/client.go @@ -0,0 +1,26 @@ +package sqldedicatedgateway + +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 SqlDedicatedGatewayClient struct { + Client *resourcemanager.Client +} + +func NewSqlDedicatedGatewayClientWithBaseURI(sdkApi sdkEnv.Api) (*SqlDedicatedGatewayClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "sqldedicatedgateway", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SqlDedicatedGatewayClient: %+v", err) + } + + return &SqlDedicatedGatewayClient{ + Client: client, + }, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/constants.go b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/constants.go new file mode 100644 index 00000000000..ee64f33b2ac --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/constants.go @@ -0,0 +1,195 @@ +package sqldedicatedgateway + +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 DedicatedGatewayType string + +const ( + DedicatedGatewayTypeDistributedQuery DedicatedGatewayType = "DistributedQuery" + DedicatedGatewayTypeIntegratedCache DedicatedGatewayType = "IntegratedCache" +) + +func PossibleValuesForDedicatedGatewayType() []string { + return []string{ + string(DedicatedGatewayTypeDistributedQuery), + string(DedicatedGatewayTypeIntegratedCache), + } +} + +func (s *DedicatedGatewayType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDedicatedGatewayType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDedicatedGatewayType(input string) (*DedicatedGatewayType, error) { + vals := map[string]DedicatedGatewayType{ + "distributedquery": DedicatedGatewayTypeDistributedQuery, + "integratedcache": DedicatedGatewayTypeIntegratedCache, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DedicatedGatewayType(input) + return &out, nil +} + +type ServiceSize string + +const ( + ServiceSizeCosmosPointDEights ServiceSize = "Cosmos.D8s" + ServiceSizeCosmosPointDFours ServiceSize = "Cosmos.D4s" + ServiceSizeCosmosPointDOneSixs ServiceSize = "Cosmos.D16s" +) + +func PossibleValuesForServiceSize() []string { + return []string{ + string(ServiceSizeCosmosPointDEights), + string(ServiceSizeCosmosPointDFours), + string(ServiceSizeCosmosPointDOneSixs), + } +} + +func (s *ServiceSize) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceSize(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceSize(input string) (*ServiceSize, error) { + vals := map[string]ServiceSize{ + "cosmos.d8s": ServiceSizeCosmosPointDEights, + "cosmos.d4s": ServiceSizeCosmosPointDFours, + "cosmos.d16s": ServiceSizeCosmosPointDOneSixs, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceSize(input) + return &out, nil +} + +type ServiceStatus string + +const ( + ServiceStatusCreating ServiceStatus = "Creating" + ServiceStatusDeleting ServiceStatus = "Deleting" + ServiceStatusError ServiceStatus = "Error" + ServiceStatusRunning ServiceStatus = "Running" + ServiceStatusStopped ServiceStatus = "Stopped" + ServiceStatusUpdating ServiceStatus = "Updating" +) + +func PossibleValuesForServiceStatus() []string { + return []string{ + string(ServiceStatusCreating), + string(ServiceStatusDeleting), + string(ServiceStatusError), + string(ServiceStatusRunning), + string(ServiceStatusStopped), + string(ServiceStatusUpdating), + } +} + +func (s *ServiceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceStatus(input string) (*ServiceStatus, error) { + vals := map[string]ServiceStatus{ + "creating": ServiceStatusCreating, + "deleting": ServiceStatusDeleting, + "error": ServiceStatusError, + "running": ServiceStatusRunning, + "stopped": ServiceStatusStopped, + "updating": ServiceStatusUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceStatus(input) + return &out, nil +} + +type ServiceType string + +const ( + ServiceTypeDataTransfer ServiceType = "DataTransfer" + ServiceTypeGraphAPICompute ServiceType = "GraphAPICompute" + ServiceTypeMaterializedViewsBuilder ServiceType = "MaterializedViewsBuilder" + ServiceTypeSqlDedicatedGateway ServiceType = "SqlDedicatedGateway" +) + +func PossibleValuesForServiceType() []string { + return []string{ + string(ServiceTypeDataTransfer), + string(ServiceTypeGraphAPICompute), + string(ServiceTypeMaterializedViewsBuilder), + string(ServiceTypeSqlDedicatedGateway), + } +} + +func (s *ServiceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceType(input string) (*ServiceType, error) { + vals := map[string]ServiceType{ + "datatransfer": ServiceTypeDataTransfer, + "graphapicompute": ServiceTypeGraphAPICompute, + "materializedviewsbuilder": ServiceTypeMaterializedViewsBuilder, + "sqldedicatedgateway": ServiceTypeSqlDedicatedGateway, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceType(input) + return &out, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/id_service.go b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/id_service.go new file mode 100644 index 00000000000..f628c9a4812 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/id_service.go @@ -0,0 +1,139 @@ +package sqldedicatedgateway + +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(&ServiceId{}) +} + +var _ resourceids.ResourceId = &ServiceId{} + +// ServiceId is a struct representing the Resource ID for a Service +type ServiceId struct { + SubscriptionId string + ResourceGroupName string + DatabaseAccountName string + ServiceName string +} + +// NewServiceID returns a new ServiceId struct +func NewServiceID(subscriptionId string, resourceGroupName string, databaseAccountName string, serviceName string) ServiceId { + return ServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DatabaseAccountName: databaseAccountName, + ServiceName: serviceName, + } +} + +// ParseServiceID parses 'input' into a ServiceId +func ParseServiceID(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseServiceIDInsensitively parses 'input' case-insensitively into a ServiceId +// note: this method should only be used for API response data and not user input +func ParseServiceIDInsensitively(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ServiceId) 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.DatabaseAccountName, ok = input.Parsed["databaseAccountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseAccountName", input) + } + + if id.ServiceName, ok = input.Parsed["serviceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serviceName", input) + } + + return nil +} + +// ValidateServiceID checks that 'input' can be parsed as a Service ID +func ValidateServiceID(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 := ParseServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Service ID +func (id ServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/services/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.ServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Service ID +func (id ServiceId) 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("staticMicrosoftDocumentDB", "Microsoft.DocumentDB", "Microsoft.DocumentDB"), + resourceids.StaticSegment("staticDatabaseAccounts", "databaseAccounts", "databaseAccounts"), + resourceids.UserSpecifiedSegment("databaseAccountName", "databaseAccountName"), + resourceids.StaticSegment("staticServices", "services", "services"), + resourceids.UserSpecifiedSegment("serviceName", "serviceName"), + } +} + +// String returns a human-readable description of this Service ID +func (id ServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Database Account Name: %q", id.DatabaseAccountName), + fmt.Sprintf("Service Name: %q", id.ServiceName), + } + return fmt.Sprintf("Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/id_service_test.go b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/id_service_test.go new file mode 100644 index 00000000000..4c591e81432 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/id_service_test.go @@ -0,0 +1,327 @@ +package sqldedicatedgateway + +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 = &ServiceId{} + +func TestNewServiceID(t *testing.T) { + id := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "serviceName") + + 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.DatabaseAccountName != "databaseAccountName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseAccountName'", id.DatabaseAccountName, "databaseAccountName") + } + + if id.ServiceName != "serviceName" { + t.Fatalf("Expected %q but got %q for Segment 'ServiceName'", id.ServiceName, "serviceName") + } +} + +func TestFormatServiceID(t *testing.T) { + actual := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "databaseAccountName", "serviceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services/serviceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services/serviceName", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + ServiceName: "serviceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services/serviceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceID(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.ServiceName != v.Expected.ServiceName { + t.Fatalf("Expected %q but got %q for ServiceName", v.Expected.ServiceName, actual.ServiceName) + } + + } +} + +func TestParseServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services/serviceName", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DatabaseAccountName: "databaseAccountName", + ServiceName: "serviceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DocumentDB/databaseAccounts/databaseAccountName/services/serviceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sErViCeS/sErViCeNaMe", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DatabaseAccountName: "dAtAbAsEaCcOuNtNaMe", + ServiceName: "sErViCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOcUmEnTdB/dAtAbAsEaCcOuNtS/dAtAbAsEaCcOuNtNaMe/sErViCeS/sErViCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceIDInsensitively(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.DatabaseAccountName != v.Expected.DatabaseAccountName { + t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) + } + + if actual.ServiceName != v.Expected.ServiceName { + t.Fatalf("Expected %q but got %q for ServiceName", v.Expected.ServiceName, actual.ServiceName) + } + + } +} + +func TestSegmentsForServiceId(t *testing.T) { + segments := ServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ServiceId 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/cosmosdb/2024-11-15/sqldedicatedgateway/method_servicecreate.go b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/method_servicecreate.go new file mode 100644 index 00000000000..491a9614016 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/method_servicecreate.go @@ -0,0 +1,75 @@ +package sqldedicatedgateway + +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 ServiceCreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ServiceResource +} + +// ServiceCreate ... +func (c SqlDedicatedGatewayClient) ServiceCreate(ctx context.Context, id ServiceId, input ServiceResourceCreateUpdateParameters) (result ServiceCreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// ServiceCreateThenPoll performs ServiceCreate then polls until it's completed +func (c SqlDedicatedGatewayClient) ServiceCreateThenPoll(ctx context.Context, id ServiceId, input ServiceResourceCreateUpdateParameters) error { + result, err := c.ServiceCreate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ServiceCreate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServiceCreate: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/method_servicedelete.go b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/method_servicedelete.go new file mode 100644 index 00000000000..fb96db6f11a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/method_servicedelete.go @@ -0,0 +1,71 @@ +package sqldedicatedgateway + +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 ServiceDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ServiceDelete ... +func (c SqlDedicatedGatewayClient) ServiceDelete(ctx context.Context, id ServiceId) (result ServiceDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ServiceDeleteThenPoll performs ServiceDelete then polls until it's completed +func (c SqlDedicatedGatewayClient) ServiceDeleteThenPoll(ctx context.Context, id ServiceId) error { + result, err := c.ServiceDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing ServiceDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServiceDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/method_serviceget.go b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/method_serviceget.go new file mode 100644 index 00000000000..e4c481bbe69 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/method_serviceget.go @@ -0,0 +1,53 @@ +package sqldedicatedgateway + +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 ServiceGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ServiceResource +} + +// ServiceGet ... +func (c SqlDedicatedGatewayClient) ServiceGet(ctx context.Context, id ServiceId) (result ServiceGetOperationResponse, 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 ServiceResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_datatransferserviceresourcecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_datatransferserviceresourcecreateupdateproperties.go new file mode 100644 index 00000000000..d240d7d056e --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_datatransferserviceresourcecreateupdateproperties.go @@ -0,0 +1,53 @@ +package sqldedicatedgateway + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServiceResourceCreateUpdateProperties = DataTransferServiceResourceCreateUpdateProperties{} + +type DataTransferServiceResourceCreateUpdateProperties struct { + + // Fields inherited from ServiceResourceCreateUpdateProperties + + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` +} + +func (s DataTransferServiceResourceCreateUpdateProperties) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return BaseServiceResourceCreateUpdatePropertiesImpl{ + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + } +} + +var _ json.Marshaler = DataTransferServiceResourceCreateUpdateProperties{} + +func (s DataTransferServiceResourceCreateUpdateProperties) MarshalJSON() ([]byte, error) { + type wrapper DataTransferServiceResourceCreateUpdateProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DataTransferServiceResourceCreateUpdateProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DataTransferServiceResourceCreateUpdateProperties: %+v", err) + } + + decoded["serviceType"] = "DataTransfer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DataTransferServiceResourceCreateUpdateProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_datatransferserviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_datatransferserviceresourceproperties.go new file mode 100644 index 00000000000..14399b118ab --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_datatransferserviceresourceproperties.go @@ -0,0 +1,73 @@ +package sqldedicatedgateway + +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 _ ServiceResourceProperties = DataTransferServiceResourceProperties{} + +type DataTransferServiceResourceProperties struct { + Locations *[]RegionalServiceResource `json:"locations,omitempty"` + + // Fields inherited from ServiceResourceProperties + + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s DataTransferServiceResourceProperties) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return BaseServiceResourcePropertiesImpl{ + CreationTime: s.CreationTime, + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + Status: s.Status, + } +} + +func (o *DataTransferServiceResourceProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DataTransferServiceResourceProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +var _ json.Marshaler = DataTransferServiceResourceProperties{} + +func (s DataTransferServiceResourceProperties) MarshalJSON() ([]byte, error) { + type wrapper DataTransferServiceResourceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DataTransferServiceResourceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DataTransferServiceResourceProperties: %+v", err) + } + + decoded["serviceType"] = "DataTransfer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DataTransferServiceResourceProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_graphapicomputeregionalserviceresource.go b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_graphapicomputeregionalserviceresource.go new file mode 100644 index 00000000000..c594985a904 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_graphapicomputeregionalserviceresource.go @@ -0,0 +1,11 @@ +package sqldedicatedgateway + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GraphAPIComputeRegionalServiceResource struct { + GraphApiComputeEndpoint *string `json:"graphApiComputeEndpoint,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Status *ServiceStatus `json:"status,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_graphapicomputeserviceresourcecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_graphapicomputeserviceresourcecreateupdateproperties.go new file mode 100644 index 00000000000..6ce366182ee --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_graphapicomputeserviceresourcecreateupdateproperties.go @@ -0,0 +1,53 @@ +package sqldedicatedgateway + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServiceResourceCreateUpdateProperties = GraphAPIComputeServiceResourceCreateUpdateProperties{} + +type GraphAPIComputeServiceResourceCreateUpdateProperties struct { + + // Fields inherited from ServiceResourceCreateUpdateProperties + + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` +} + +func (s GraphAPIComputeServiceResourceCreateUpdateProperties) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return BaseServiceResourceCreateUpdatePropertiesImpl{ + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + } +} + +var _ json.Marshaler = GraphAPIComputeServiceResourceCreateUpdateProperties{} + +func (s GraphAPIComputeServiceResourceCreateUpdateProperties) MarshalJSON() ([]byte, error) { + type wrapper GraphAPIComputeServiceResourceCreateUpdateProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GraphAPIComputeServiceResourceCreateUpdateProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GraphAPIComputeServiceResourceCreateUpdateProperties: %+v", err) + } + + decoded["serviceType"] = "GraphAPICompute" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GraphAPIComputeServiceResourceCreateUpdateProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_graphapicomputeserviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_graphapicomputeserviceresourceproperties.go new file mode 100644 index 00000000000..4a3df37bd1c --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_graphapicomputeserviceresourceproperties.go @@ -0,0 +1,74 @@ +package sqldedicatedgateway + +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 _ ServiceResourceProperties = GraphAPIComputeServiceResourceProperties{} + +type GraphAPIComputeServiceResourceProperties struct { + GraphApiComputeEndpoint *string `json:"graphApiComputeEndpoint,omitempty"` + Locations *[]GraphAPIComputeRegionalServiceResource `json:"locations,omitempty"` + + // Fields inherited from ServiceResourceProperties + + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s GraphAPIComputeServiceResourceProperties) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return BaseServiceResourcePropertiesImpl{ + CreationTime: s.CreationTime, + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + Status: s.Status, + } +} + +func (o *GraphAPIComputeServiceResourceProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *GraphAPIComputeServiceResourceProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +var _ json.Marshaler = GraphAPIComputeServiceResourceProperties{} + +func (s GraphAPIComputeServiceResourceProperties) MarshalJSON() ([]byte, error) { + type wrapper GraphAPIComputeServiceResourceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GraphAPIComputeServiceResourceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GraphAPIComputeServiceResourceProperties: %+v", err) + } + + decoded["serviceType"] = "GraphAPICompute" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GraphAPIComputeServiceResourceProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_materializedviewsbuilderserviceresourcecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_materializedviewsbuilderserviceresourcecreateupdateproperties.go new file mode 100644 index 00000000000..16b8151945a --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_materializedviewsbuilderserviceresourcecreateupdateproperties.go @@ -0,0 +1,53 @@ +package sqldedicatedgateway + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServiceResourceCreateUpdateProperties = MaterializedViewsBuilderServiceResourceCreateUpdateProperties{} + +type MaterializedViewsBuilderServiceResourceCreateUpdateProperties struct { + + // Fields inherited from ServiceResourceCreateUpdateProperties + + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` +} + +func (s MaterializedViewsBuilderServiceResourceCreateUpdateProperties) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return BaseServiceResourceCreateUpdatePropertiesImpl{ + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + } +} + +var _ json.Marshaler = MaterializedViewsBuilderServiceResourceCreateUpdateProperties{} + +func (s MaterializedViewsBuilderServiceResourceCreateUpdateProperties) MarshalJSON() ([]byte, error) { + type wrapper MaterializedViewsBuilderServiceResourceCreateUpdateProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MaterializedViewsBuilderServiceResourceCreateUpdateProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MaterializedViewsBuilderServiceResourceCreateUpdateProperties: %+v", err) + } + + decoded["serviceType"] = "MaterializedViewsBuilder" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MaterializedViewsBuilderServiceResourceCreateUpdateProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_materializedviewsbuilderserviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_materializedviewsbuilderserviceresourceproperties.go new file mode 100644 index 00000000000..9062b4166c3 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_materializedviewsbuilderserviceresourceproperties.go @@ -0,0 +1,73 @@ +package sqldedicatedgateway + +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 _ ServiceResourceProperties = MaterializedViewsBuilderServiceResourceProperties{} + +type MaterializedViewsBuilderServiceResourceProperties struct { + Locations *[]RegionalServiceResource `json:"locations,omitempty"` + + // Fields inherited from ServiceResourceProperties + + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s MaterializedViewsBuilderServiceResourceProperties) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return BaseServiceResourcePropertiesImpl{ + CreationTime: s.CreationTime, + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + Status: s.Status, + } +} + +func (o *MaterializedViewsBuilderServiceResourceProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MaterializedViewsBuilderServiceResourceProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +var _ json.Marshaler = MaterializedViewsBuilderServiceResourceProperties{} + +func (s MaterializedViewsBuilderServiceResourceProperties) MarshalJSON() ([]byte, error) { + type wrapper MaterializedViewsBuilderServiceResourceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MaterializedViewsBuilderServiceResourceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MaterializedViewsBuilderServiceResourceProperties: %+v", err) + } + + decoded["serviceType"] = "MaterializedViewsBuilder" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MaterializedViewsBuilderServiceResourceProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_regionalserviceresource.go b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_regionalserviceresource.go new file mode 100644 index 00000000000..d9b388314b0 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_regionalserviceresource.go @@ -0,0 +1,10 @@ +package sqldedicatedgateway + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegionalServiceResource struct { + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Status *ServiceStatus `json:"status,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_serviceresource.go b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_serviceresource.go new file mode 100644 index 00000000000..a8a211ab13f --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_serviceresource.go @@ -0,0 +1,48 @@ +package sqldedicatedgateway + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties ServiceResourceProperties `json:"properties"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ServiceResource{} + +func (s *ServiceResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Id = decoded.Id + s.Name = decoded.Name + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ServiceResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalServiceResourcePropertiesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ServiceResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_serviceresourcecreateupdateparameters.go b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_serviceresourcecreateupdateparameters.go new file mode 100644 index 00000000000..757ce55ee81 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_serviceresourcecreateupdateparameters.go @@ -0,0 +1,33 @@ +package sqldedicatedgateway + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceResourceCreateUpdateParameters struct { + Properties ServiceResourceCreateUpdateProperties `json:"properties"` +} + +var _ json.Unmarshaler = &ServiceResourceCreateUpdateParameters{} + +func (s *ServiceResourceCreateUpdateParameters) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ServiceResourceCreateUpdateParameters into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalServiceResourceCreateUpdatePropertiesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ServiceResourceCreateUpdateParameters': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_serviceresourcecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_serviceresourcecreateupdateproperties.go new file mode 100644 index 00000000000..ea57d6a5753 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_serviceresourcecreateupdateproperties.go @@ -0,0 +1,101 @@ +package sqldedicatedgateway + +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 ServiceResourceCreateUpdateProperties interface { + ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl +} + +var _ ServiceResourceCreateUpdateProperties = BaseServiceResourceCreateUpdatePropertiesImpl{} + +type BaseServiceResourceCreateUpdatePropertiesImpl struct { + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` +} + +func (s BaseServiceResourceCreateUpdatePropertiesImpl) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return s +} + +var _ ServiceResourceCreateUpdateProperties = RawServiceResourceCreateUpdatePropertiesImpl{} + +// RawServiceResourceCreateUpdatePropertiesImpl 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 RawServiceResourceCreateUpdatePropertiesImpl struct { + serviceResourceCreateUpdateProperties BaseServiceResourceCreateUpdatePropertiesImpl + Type string + Values map[string]interface{} +} + +func (s RawServiceResourceCreateUpdatePropertiesImpl) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return s.serviceResourceCreateUpdateProperties +} + +func UnmarshalServiceResourceCreateUpdatePropertiesImplementation(input []byte) (ServiceResourceCreateUpdateProperties, 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 ServiceResourceCreateUpdateProperties into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["serviceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "DataTransfer") { + var out DataTransferServiceResourceCreateUpdateProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DataTransferServiceResourceCreateUpdateProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GraphAPICompute") { + var out GraphAPIComputeServiceResourceCreateUpdateProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GraphAPIComputeServiceResourceCreateUpdateProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MaterializedViewsBuilder") { + var out MaterializedViewsBuilderServiceResourceCreateUpdateProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MaterializedViewsBuilderServiceResourceCreateUpdateProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SqlDedicatedGateway") { + var out SqlDedicatedGatewayServiceResourceCreateUpdateProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SqlDedicatedGatewayServiceResourceCreateUpdateProperties: %+v", err) + } + return out, nil + } + + var parent BaseServiceResourceCreateUpdatePropertiesImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseServiceResourceCreateUpdatePropertiesImpl: %+v", err) + } + + return RawServiceResourceCreateUpdatePropertiesImpl{ + serviceResourceCreateUpdateProperties: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_serviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_serviceresourceproperties.go new file mode 100644 index 00000000000..e33f6828514 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_serviceresourceproperties.go @@ -0,0 +1,103 @@ +package sqldedicatedgateway + +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 ServiceResourceProperties interface { + ServiceResourceProperties() BaseServiceResourcePropertiesImpl +} + +var _ ServiceResourceProperties = BaseServiceResourcePropertiesImpl{} + +type BaseServiceResourcePropertiesImpl struct { + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s BaseServiceResourcePropertiesImpl) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return s +} + +var _ ServiceResourceProperties = RawServiceResourcePropertiesImpl{} + +// RawServiceResourcePropertiesImpl 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 RawServiceResourcePropertiesImpl struct { + serviceResourceProperties BaseServiceResourcePropertiesImpl + Type string + Values map[string]interface{} +} + +func (s RawServiceResourcePropertiesImpl) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return s.serviceResourceProperties +} + +func UnmarshalServiceResourcePropertiesImplementation(input []byte) (ServiceResourceProperties, 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 ServiceResourceProperties into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["serviceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "DataTransfer") { + var out DataTransferServiceResourceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DataTransferServiceResourceProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GraphAPICompute") { + var out GraphAPIComputeServiceResourceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GraphAPIComputeServiceResourceProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MaterializedViewsBuilder") { + var out MaterializedViewsBuilderServiceResourceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MaterializedViewsBuilderServiceResourceProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SqlDedicatedGateway") { + var out SqlDedicatedGatewayServiceResourceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SqlDedicatedGatewayServiceResourceProperties: %+v", err) + } + return out, nil + } + + var parent BaseServiceResourcePropertiesImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseServiceResourcePropertiesImpl: %+v", err) + } + + return RawServiceResourcePropertiesImpl{ + serviceResourceProperties: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_sqldedicatedgatewayregionalserviceresource.go b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_sqldedicatedgatewayregionalserviceresource.go new file mode 100644 index 00000000000..21edb9c87f1 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_sqldedicatedgatewayregionalserviceresource.go @@ -0,0 +1,11 @@ +package sqldedicatedgateway + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlDedicatedGatewayRegionalServiceResource struct { + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + SqlDedicatedGatewayEndpoint *string `json:"sqlDedicatedGatewayEndpoint,omitempty"` + Status *ServiceStatus `json:"status,omitempty"` +} diff --git a/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_sqldedicatedgatewayserviceresourcecreateupdateproperties.go b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_sqldedicatedgatewayserviceresourcecreateupdateproperties.go new file mode 100644 index 00000000000..223d32eed77 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_sqldedicatedgatewayserviceresourcecreateupdateproperties.go @@ -0,0 +1,54 @@ +package sqldedicatedgateway + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServiceResourceCreateUpdateProperties = SqlDedicatedGatewayServiceResourceCreateUpdateProperties{} + +type SqlDedicatedGatewayServiceResourceCreateUpdateProperties struct { + DedicatedGatewayType *DedicatedGatewayType `json:"dedicatedGatewayType,omitempty"` + + // Fields inherited from ServiceResourceCreateUpdateProperties + + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` +} + +func (s SqlDedicatedGatewayServiceResourceCreateUpdateProperties) ServiceResourceCreateUpdateProperties() BaseServiceResourceCreateUpdatePropertiesImpl { + return BaseServiceResourceCreateUpdatePropertiesImpl{ + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + } +} + +var _ json.Marshaler = SqlDedicatedGatewayServiceResourceCreateUpdateProperties{} + +func (s SqlDedicatedGatewayServiceResourceCreateUpdateProperties) MarshalJSON() ([]byte, error) { + type wrapper SqlDedicatedGatewayServiceResourceCreateUpdateProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SqlDedicatedGatewayServiceResourceCreateUpdateProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SqlDedicatedGatewayServiceResourceCreateUpdateProperties: %+v", err) + } + + decoded["serviceType"] = "SqlDedicatedGateway" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SqlDedicatedGatewayServiceResourceCreateUpdateProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_sqldedicatedgatewayserviceresourceproperties.go b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_sqldedicatedgatewayserviceresourceproperties.go new file mode 100644 index 00000000000..fe6bd3a7a54 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/model_sqldedicatedgatewayserviceresourceproperties.go @@ -0,0 +1,75 @@ +package sqldedicatedgateway + +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 _ ServiceResourceProperties = SqlDedicatedGatewayServiceResourceProperties{} + +type SqlDedicatedGatewayServiceResourceProperties struct { + DedicatedGatewayType *DedicatedGatewayType `json:"dedicatedGatewayType,omitempty"` + Locations *[]SqlDedicatedGatewayRegionalServiceResource `json:"locations,omitempty"` + SqlDedicatedGatewayEndpoint *string `json:"sqlDedicatedGatewayEndpoint,omitempty"` + + // Fields inherited from ServiceResourceProperties + + CreationTime *string `json:"creationTime,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceSize *ServiceSize `json:"instanceSize,omitempty"` + ServiceType ServiceType `json:"serviceType"` + Status *ServiceStatus `json:"status,omitempty"` +} + +func (s SqlDedicatedGatewayServiceResourceProperties) ServiceResourceProperties() BaseServiceResourcePropertiesImpl { + return BaseServiceResourcePropertiesImpl{ + CreationTime: s.CreationTime, + InstanceCount: s.InstanceCount, + InstanceSize: s.InstanceSize, + ServiceType: s.ServiceType, + Status: s.Status, + } +} + +func (o *SqlDedicatedGatewayServiceResourceProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SqlDedicatedGatewayServiceResourceProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +var _ json.Marshaler = SqlDedicatedGatewayServiceResourceProperties{} + +func (s SqlDedicatedGatewayServiceResourceProperties) MarshalJSON() ([]byte, error) { + type wrapper SqlDedicatedGatewayServiceResourceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SqlDedicatedGatewayServiceResourceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SqlDedicatedGatewayServiceResourceProperties: %+v", err) + } + + decoded["serviceType"] = "SqlDedicatedGateway" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SqlDedicatedGatewayServiceResourceProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/version.go b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/version.go new file mode 100644 index 00000000000..a791af12a41 --- /dev/null +++ b/resource-manager/cosmosdb/2024-11-15/sqldedicatedgateway/version.go @@ -0,0 +1,10 @@ +package sqldedicatedgateway + +// 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-11-15" + +func userAgent() string { + return "hashicorp/go-azure-sdk/sqldedicatedgateway/2024-11-15" +} diff --git a/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/README.md b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/README.md new file mode 100644 index 00000000000..7e7bdeb1e2e --- /dev/null +++ b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/README.md @@ -0,0 +1,103 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations` Documentation + +The `attacheddatabaseconfigurations` SDK allows for interaction with Azure Resource Manager `kusto` (API Version `2024-04-13`). + +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/kusto/2024-04-13/attacheddatabaseconfigurations" +``` + + +### Client Initialization + +```go +client := attacheddatabaseconfigurations.NewAttachedDatabaseConfigurationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AttachedDatabaseConfigurationsClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +payload := attacheddatabaseconfigurations.AttachedDatabaseConfigurationsCheckNameRequest{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AttachedDatabaseConfigurationsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := attacheddatabaseconfigurations.NewAttachedDatabaseConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "attachedDatabaseConfigurationName") + +payload := attacheddatabaseconfigurations.AttachedDatabaseConfiguration{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AttachedDatabaseConfigurationsClient.Delete` + +```go +ctx := context.TODO() +id := attacheddatabaseconfigurations.NewAttachedDatabaseConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "attachedDatabaseConfigurationName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AttachedDatabaseConfigurationsClient.Get` + +```go +ctx := context.TODO() +id := attacheddatabaseconfigurations.NewAttachedDatabaseConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "attachedDatabaseConfigurationName") + +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: `AttachedDatabaseConfigurationsClient.ListByCluster` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +read, err := client.ListByCluster(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/client.go b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/client.go new file mode 100644 index 00000000000..92c6e47e4b1 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/client.go @@ -0,0 +1,26 @@ +package attacheddatabaseconfigurations + +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 AttachedDatabaseConfigurationsClient struct { + Client *resourcemanager.Client +} + +func NewAttachedDatabaseConfigurationsClientWithBaseURI(sdkApi sdkEnv.Api) (*AttachedDatabaseConfigurationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "attacheddatabaseconfigurations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AttachedDatabaseConfigurationsClient: %+v", err) + } + + return &AttachedDatabaseConfigurationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/constants.go b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/constants.go new file mode 100644 index 00000000000..6fff6d6518e --- /dev/null +++ b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/constants.go @@ -0,0 +1,189 @@ +package attacheddatabaseconfigurations + +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 AttachedDatabaseType string + +const ( + AttachedDatabaseTypeMicrosoftPointKustoClustersAttachedDatabaseConfigurations AttachedDatabaseType = "Microsoft.Kusto/clusters/attachedDatabaseConfigurations" +) + +func PossibleValuesForAttachedDatabaseType() []string { + return []string{ + string(AttachedDatabaseTypeMicrosoftPointKustoClustersAttachedDatabaseConfigurations), + } +} + +func (s *AttachedDatabaseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAttachedDatabaseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAttachedDatabaseType(input string) (*AttachedDatabaseType, error) { + vals := map[string]AttachedDatabaseType{ + "microsoft.kusto/clusters/attacheddatabaseconfigurations": AttachedDatabaseTypeMicrosoftPointKustoClustersAttachedDatabaseConfigurations, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AttachedDatabaseType(input) + return &out, nil +} + +type DefaultPrincipalsModificationKind string + +const ( + DefaultPrincipalsModificationKindNone DefaultPrincipalsModificationKind = "None" + DefaultPrincipalsModificationKindReplace DefaultPrincipalsModificationKind = "Replace" + DefaultPrincipalsModificationKindUnion DefaultPrincipalsModificationKind = "Union" +) + +func PossibleValuesForDefaultPrincipalsModificationKind() []string { + return []string{ + string(DefaultPrincipalsModificationKindNone), + string(DefaultPrincipalsModificationKindReplace), + string(DefaultPrincipalsModificationKindUnion), + } +} + +func (s *DefaultPrincipalsModificationKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDefaultPrincipalsModificationKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDefaultPrincipalsModificationKind(input string) (*DefaultPrincipalsModificationKind, error) { + vals := map[string]DefaultPrincipalsModificationKind{ + "none": DefaultPrincipalsModificationKindNone, + "replace": DefaultPrincipalsModificationKindReplace, + "union": DefaultPrincipalsModificationKindUnion, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DefaultPrincipalsModificationKind(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateMoving ProvisioningState = "Moving" + ProvisioningStateRunning ProvisioningState = "Running" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateMoving), + string(ProvisioningStateRunning), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "moving": ProvisioningStateMoving, + "running": ProvisioningStateRunning, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type Reason string + +const ( + ReasonAlreadyExists Reason = "AlreadyExists" + ReasonInvalid Reason = "Invalid" +) + +func PossibleValuesForReason() []string { + return []string{ + string(ReasonAlreadyExists), + string(ReasonInvalid), + } +} + +func (s *Reason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReason(input string) (*Reason, error) { + vals := map[string]Reason{ + "alreadyexists": ReasonAlreadyExists, + "invalid": ReasonInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Reason(input) + return &out, nil +} diff --git a/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/id_attacheddatabaseconfiguration.go b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/id_attacheddatabaseconfiguration.go new file mode 100644 index 00000000000..3244ce81c54 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/id_attacheddatabaseconfiguration.go @@ -0,0 +1,139 @@ +package attacheddatabaseconfigurations + +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(&AttachedDatabaseConfigurationId{}) +} + +var _ resourceids.ResourceId = &AttachedDatabaseConfigurationId{} + +// AttachedDatabaseConfigurationId is a struct representing the Resource ID for a Attached Database Configuration +type AttachedDatabaseConfigurationId struct { + SubscriptionId string + ResourceGroupName string + ClusterName string + AttachedDatabaseConfigurationName string +} + +// NewAttachedDatabaseConfigurationID returns a new AttachedDatabaseConfigurationId struct +func NewAttachedDatabaseConfigurationID(subscriptionId string, resourceGroupName string, clusterName string, attachedDatabaseConfigurationName string) AttachedDatabaseConfigurationId { + return AttachedDatabaseConfigurationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ClusterName: clusterName, + AttachedDatabaseConfigurationName: attachedDatabaseConfigurationName, + } +} + +// ParseAttachedDatabaseConfigurationID parses 'input' into a AttachedDatabaseConfigurationId +func ParseAttachedDatabaseConfigurationID(input string) (*AttachedDatabaseConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&AttachedDatabaseConfigurationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AttachedDatabaseConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAttachedDatabaseConfigurationIDInsensitively parses 'input' case-insensitively into a AttachedDatabaseConfigurationId +// note: this method should only be used for API response data and not user input +func ParseAttachedDatabaseConfigurationIDInsensitively(input string) (*AttachedDatabaseConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&AttachedDatabaseConfigurationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AttachedDatabaseConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AttachedDatabaseConfigurationId) 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.ClusterName, ok = input.Parsed["clusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "clusterName", input) + } + + if id.AttachedDatabaseConfigurationName, ok = input.Parsed["attachedDatabaseConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "attachedDatabaseConfigurationName", input) + } + + return nil +} + +// ValidateAttachedDatabaseConfigurationID checks that 'input' can be parsed as a Attached Database Configuration ID +func ValidateAttachedDatabaseConfigurationID(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 := ParseAttachedDatabaseConfigurationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Attached Database Configuration ID +func (id AttachedDatabaseConfigurationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Kusto/clusters/%s/attachedDatabaseConfigurations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName, id.AttachedDatabaseConfigurationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Attached Database Configuration ID +func (id AttachedDatabaseConfigurationId) 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("staticMicrosoftKusto", "Microsoft.Kusto", "Microsoft.Kusto"), + resourceids.StaticSegment("staticClusters", "clusters", "clusters"), + resourceids.UserSpecifiedSegment("clusterName", "clusterName"), + resourceids.StaticSegment("staticAttachedDatabaseConfigurations", "attachedDatabaseConfigurations", "attachedDatabaseConfigurations"), + resourceids.UserSpecifiedSegment("attachedDatabaseConfigurationName", "attachedDatabaseConfigurationName"), + } +} + +// String returns a human-readable description of this Attached Database Configuration ID +func (id AttachedDatabaseConfigurationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cluster Name: %q", id.ClusterName), + fmt.Sprintf("Attached Database Configuration Name: %q", id.AttachedDatabaseConfigurationName), + } + return fmt.Sprintf("Attached Database Configuration (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/id_attacheddatabaseconfiguration_test.go b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/id_attacheddatabaseconfiguration_test.go new file mode 100644 index 00000000000..602d8c8f989 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/id_attacheddatabaseconfiguration_test.go @@ -0,0 +1,327 @@ +package attacheddatabaseconfigurations + +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 = &AttachedDatabaseConfigurationId{} + +func TestNewAttachedDatabaseConfigurationID(t *testing.T) { + id := NewAttachedDatabaseConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "attachedDatabaseConfigurationName") + + 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.ClusterName != "clusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterName") + } + + if id.AttachedDatabaseConfigurationName != "attachedDatabaseConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'AttachedDatabaseConfigurationName'", id.AttachedDatabaseConfigurationName, "attachedDatabaseConfigurationName") + } +} + +func TestFormatAttachedDatabaseConfigurationID(t *testing.T) { + actual := NewAttachedDatabaseConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "attachedDatabaseConfigurationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/attachedDatabaseConfigurations/attachedDatabaseConfigurationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAttachedDatabaseConfigurationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AttachedDatabaseConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/attachedDatabaseConfigurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/attachedDatabaseConfigurations/attachedDatabaseConfigurationName", + Expected: &AttachedDatabaseConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + AttachedDatabaseConfigurationName: "attachedDatabaseConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/attachedDatabaseConfigurations/attachedDatabaseConfigurationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAttachedDatabaseConfigurationID(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.AttachedDatabaseConfigurationName != v.Expected.AttachedDatabaseConfigurationName { + t.Fatalf("Expected %q but got %q for AttachedDatabaseConfigurationName", v.Expected.AttachedDatabaseConfigurationName, actual.AttachedDatabaseConfigurationName) + } + + } +} + +func TestParseAttachedDatabaseConfigurationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AttachedDatabaseConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/attachedDatabaseConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/aTtAcHeDdAtAbAsEcOnFiGuRaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/attachedDatabaseConfigurations/attachedDatabaseConfigurationName", + Expected: &AttachedDatabaseConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + AttachedDatabaseConfigurationName: "attachedDatabaseConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/attachedDatabaseConfigurations/attachedDatabaseConfigurationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/aTtAcHeDdAtAbAsEcOnFiGuRaTiOnS/aTtAcHeDdAtAbAsEcOnFiGuRaTiOnNaMe", + Expected: &AttachedDatabaseConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ClusterName: "cLuStErNaMe", + AttachedDatabaseConfigurationName: "aTtAcHeDdAtAbAsEcOnFiGuRaTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/aTtAcHeDdAtAbAsEcOnFiGuRaTiOnS/aTtAcHeDdAtAbAsEcOnFiGuRaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAttachedDatabaseConfigurationIDInsensitively(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.AttachedDatabaseConfigurationName != v.Expected.AttachedDatabaseConfigurationName { + t.Fatalf("Expected %q but got %q for AttachedDatabaseConfigurationName", v.Expected.AttachedDatabaseConfigurationName, actual.AttachedDatabaseConfigurationName) + } + + } +} + +func TestSegmentsForAttachedDatabaseConfigurationId(t *testing.T) { + segments := AttachedDatabaseConfigurationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AttachedDatabaseConfigurationId 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/kusto/2024-04-13/attacheddatabaseconfigurations/method_checknameavailability.go b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/method_checknameavailability.go new file mode 100644 index 00000000000..08dd7288a49 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/method_checknameavailability.go @@ -0,0 +1,59 @@ +package attacheddatabaseconfigurations + +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 CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameResult +} + +// CheckNameAvailability ... +func (c AttachedDatabaseConfigurationsClient) CheckNameAvailability(ctx context.Context, id commonids.KustoClusterId, input AttachedDatabaseConfigurationsCheckNameRequest) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/attachedDatabaseConfigurationCheckNameAvailability", 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 CheckNameResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/method_createorupdate.go b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/method_createorupdate.go new file mode 100644 index 00000000000..f8ce77292e6 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/method_createorupdate.go @@ -0,0 +1,76 @@ +package attacheddatabaseconfigurations + +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 *AttachedDatabaseConfiguration +} + +// CreateOrUpdate ... +func (c AttachedDatabaseConfigurationsClient) CreateOrUpdate(ctx context.Context, id AttachedDatabaseConfigurationId, input AttachedDatabaseConfiguration) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c AttachedDatabaseConfigurationsClient) CreateOrUpdateThenPoll(ctx context.Context, id AttachedDatabaseConfigurationId, input AttachedDatabaseConfiguration) 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/kusto/2024-04-13/attacheddatabaseconfigurations/method_delete.go b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/method_delete.go new file mode 100644 index 00000000000..e8893055054 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/method_delete.go @@ -0,0 +1,71 @@ +package attacheddatabaseconfigurations + +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 AttachedDatabaseConfigurationsClient) Delete(ctx context.Context, id AttachedDatabaseConfigurationId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c AttachedDatabaseConfigurationsClient) DeleteThenPoll(ctx context.Context, id AttachedDatabaseConfigurationId) 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/kusto/2024-04-13/attacheddatabaseconfigurations/method_get.go b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/method_get.go new file mode 100644 index 00000000000..7b2caf73fe1 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/method_get.go @@ -0,0 +1,53 @@ +package attacheddatabaseconfigurations + +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 *AttachedDatabaseConfiguration +} + +// Get ... +func (c AttachedDatabaseConfigurationsClient) Get(ctx context.Context, id AttachedDatabaseConfigurationId) (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 AttachedDatabaseConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/method_listbycluster.go b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/method_listbycluster.go new file mode 100644 index 00000000000..881cef6fc3f --- /dev/null +++ b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/method_listbycluster.go @@ -0,0 +1,55 @@ +package attacheddatabaseconfigurations + +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 ListByClusterOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AttachedDatabaseConfigurationListResult +} + +// ListByCluster ... +func (c AttachedDatabaseConfigurationsClient) ListByCluster(ctx context.Context, id commonids.KustoClusterId) (result ListByClusterOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/attachedDatabaseConfigurations", 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 AttachedDatabaseConfigurationListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/model_attacheddatabaseconfiguration.go b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/model_attacheddatabaseconfiguration.go new file mode 100644 index 00000000000..e08fd890d7b --- /dev/null +++ b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/model_attacheddatabaseconfiguration.go @@ -0,0 +1,12 @@ +package attacheddatabaseconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AttachedDatabaseConfiguration struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AttachedDatabaseConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/model_attacheddatabaseconfigurationlistresult.go b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/model_attacheddatabaseconfigurationlistresult.go new file mode 100644 index 00000000000..2a426671eee --- /dev/null +++ b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/model_attacheddatabaseconfigurationlistresult.go @@ -0,0 +1,8 @@ +package attacheddatabaseconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AttachedDatabaseConfigurationListResult struct { + Value *[]AttachedDatabaseConfiguration `json:"value,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/model_attacheddatabaseconfigurationproperties.go b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/model_attacheddatabaseconfigurationproperties.go new file mode 100644 index 00000000000..f7b9d2b0614 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/model_attacheddatabaseconfigurationproperties.go @@ -0,0 +1,15 @@ +package attacheddatabaseconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AttachedDatabaseConfigurationProperties struct { + AttachedDatabaseNames *[]string `json:"attachedDatabaseNames,omitempty"` + ClusterResourceId string `json:"clusterResourceId"` + DatabaseName string `json:"databaseName"` + DatabaseNameOverride *string `json:"databaseNameOverride,omitempty"` + DatabaseNamePrefix *string `json:"databaseNamePrefix,omitempty"` + DefaultPrincipalsModificationKind DefaultPrincipalsModificationKind `json:"defaultPrincipalsModificationKind"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + TableLevelSharingProperties *TableLevelSharingProperties `json:"tableLevelSharingProperties,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/model_attacheddatabaseconfigurationschecknamerequest.go b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/model_attacheddatabaseconfigurationschecknamerequest.go new file mode 100644 index 00000000000..66a281fb352 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/model_attacheddatabaseconfigurationschecknamerequest.go @@ -0,0 +1,9 @@ +package attacheddatabaseconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AttachedDatabaseConfigurationsCheckNameRequest struct { + Name string `json:"name"` + Type AttachedDatabaseType `json:"type"` +} diff --git a/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/model_checknameresult.go b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/model_checknameresult.go new file mode 100644 index 00000000000..7398e6a9f00 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/model_checknameresult.go @@ -0,0 +1,11 @@ +package attacheddatabaseconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameResult struct { + Message *string `json:"message,omitempty"` + Name *string `json:"name,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *Reason `json:"reason,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/model_tablelevelsharingproperties.go b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/model_tablelevelsharingproperties.go new file mode 100644 index 00000000000..b5369e51352 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/model_tablelevelsharingproperties.go @@ -0,0 +1,15 @@ +package attacheddatabaseconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TableLevelSharingProperties struct { + ExternalTablesToExclude *[]string `json:"externalTablesToExclude,omitempty"` + ExternalTablesToInclude *[]string `json:"externalTablesToInclude,omitempty"` + FunctionsToExclude *[]string `json:"functionsToExclude,omitempty"` + FunctionsToInclude *[]string `json:"functionsToInclude,omitempty"` + MaterializedViewsToExclude *[]string `json:"materializedViewsToExclude,omitempty"` + MaterializedViewsToInclude *[]string `json:"materializedViewsToInclude,omitempty"` + TablesToExclude *[]string `json:"tablesToExclude,omitempty"` + TablesToInclude *[]string `json:"tablesToInclude,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/version.go b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/version.go new file mode 100644 index 00000000000..79510d61f23 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/attacheddatabaseconfigurations/version.go @@ -0,0 +1,10 @@ +package attacheddatabaseconfigurations + +// 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-04-13" + +func userAgent() string { + return "hashicorp/go-azure-sdk/attacheddatabaseconfigurations/2024-04-13" +} diff --git a/resource-manager/kusto/2024-04-13/client.go b/resource-manager/kusto/2024-04-13/client.go new file mode 100644 index 00000000000..b1001918007 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/client.go @@ -0,0 +1,136 @@ +package v2024_04_13 + +// 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/kusto/2024-04-13/attacheddatabaseconfigurations" + "github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/clusterprincipalassignments" + "github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/clusters" + "github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/databaseprincipalassignments" + "github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/databases" + "github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/dataconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/kusto" + "github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/managedprivateendpoints" + "github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints" + "github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/privateendpointconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/privatelinkresources" + "github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/sandboxcustomimages" + "github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/scripts" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + AttachedDatabaseConfigurations *attacheddatabaseconfigurations.AttachedDatabaseConfigurationsClient + ClusterPrincipalAssignments *clusterprincipalassignments.ClusterPrincipalAssignmentsClient + Clusters *clusters.ClustersClient + DataConnections *dataconnections.DataConnectionsClient + DatabasePrincipalAssignments *databaseprincipalassignments.DatabasePrincipalAssignmentsClient + Databases *databases.DatabasesClient + Kusto *kusto.KustoClient + ManagedPrivateEndpoints *managedprivateendpoints.ManagedPrivateEndpointsClient + OutboundNetworkDependenciesEndpoints *outboundnetworkdependenciesendpoints.OutboundNetworkDependenciesEndpointsClient + PrivateEndpointConnections *privateendpointconnections.PrivateEndpointConnectionsClient + PrivateLinkResources *privatelinkresources.PrivateLinkResourcesClient + SandboxCustomImages *sandboxcustomimages.SandboxCustomImagesClient + Scripts *scripts.ScriptsClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + attachedDatabaseConfigurationsClient, err := attacheddatabaseconfigurations.NewAttachedDatabaseConfigurationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AttachedDatabaseConfigurations client: %+v", err) + } + configureFunc(attachedDatabaseConfigurationsClient.Client) + + clusterPrincipalAssignmentsClient, err := clusterprincipalassignments.NewClusterPrincipalAssignmentsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ClusterPrincipalAssignments client: %+v", err) + } + configureFunc(clusterPrincipalAssignmentsClient.Client) + + clustersClient, err := clusters.NewClustersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Clusters client: %+v", err) + } + configureFunc(clustersClient.Client) + + dataConnectionsClient, err := dataconnections.NewDataConnectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DataConnections client: %+v", err) + } + configureFunc(dataConnectionsClient.Client) + + databasePrincipalAssignmentsClient, err := databaseprincipalassignments.NewDatabasePrincipalAssignmentsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DatabasePrincipalAssignments client: %+v", err) + } + configureFunc(databasePrincipalAssignmentsClient.Client) + + databasesClient, err := databases.NewDatabasesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Databases client: %+v", err) + } + configureFunc(databasesClient.Client) + + kustoClient, err := kusto.NewKustoClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Kusto client: %+v", err) + } + configureFunc(kustoClient.Client) + + managedPrivateEndpointsClient, err := managedprivateendpoints.NewManagedPrivateEndpointsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ManagedPrivateEndpoints client: %+v", err) + } + configureFunc(managedPrivateEndpointsClient.Client) + + outboundNetworkDependenciesEndpointsClient, err := outboundnetworkdependenciesendpoints.NewOutboundNetworkDependenciesEndpointsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building OutboundNetworkDependenciesEndpoints client: %+v", err) + } + configureFunc(outboundNetworkDependenciesEndpointsClient.Client) + + privateEndpointConnectionsClient, err := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PrivateEndpointConnections client: %+v", err) + } + configureFunc(privateEndpointConnectionsClient.Client) + + privateLinkResourcesClient, err := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PrivateLinkResources client: %+v", err) + } + configureFunc(privateLinkResourcesClient.Client) + + sandboxCustomImagesClient, err := sandboxcustomimages.NewSandboxCustomImagesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SandboxCustomImages client: %+v", err) + } + configureFunc(sandboxCustomImagesClient.Client) + + scriptsClient, err := scripts.NewScriptsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Scripts client: %+v", err) + } + configureFunc(scriptsClient.Client) + + return &Client{ + AttachedDatabaseConfigurations: attachedDatabaseConfigurationsClient, + ClusterPrincipalAssignments: clusterPrincipalAssignmentsClient, + Clusters: clustersClient, + DataConnections: dataConnectionsClient, + DatabasePrincipalAssignments: databasePrincipalAssignmentsClient, + Databases: databasesClient, + Kusto: kustoClient, + ManagedPrivateEndpoints: managedPrivateEndpointsClient, + OutboundNetworkDependenciesEndpoints: outboundNetworkDependenciesEndpointsClient, + PrivateEndpointConnections: privateEndpointConnectionsClient, + PrivateLinkResources: privateLinkResourcesClient, + SandboxCustomImages: sandboxCustomImagesClient, + Scripts: scriptsClient, + }, nil +} diff --git a/resource-manager/kusto/2024-04-13/clusterprincipalassignments/README.md b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/README.md new file mode 100644 index 00000000000..0bad9012dc8 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/README.md @@ -0,0 +1,103 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/clusterprincipalassignments` Documentation + +The `clusterprincipalassignments` SDK allows for interaction with Azure Resource Manager `kusto` (API Version `2024-04-13`). + +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/kusto/2024-04-13/clusterprincipalassignments" +``` + + +### Client Initialization + +```go +client := clusterprincipalassignments.NewClusterPrincipalAssignmentsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ClusterPrincipalAssignmentsClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +payload := clusterprincipalassignments.ClusterPrincipalAssignmentCheckNameRequest{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ClusterPrincipalAssignmentsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := clusterprincipalassignments.NewPrincipalAssignmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "principalAssignmentName") + +payload := clusterprincipalassignments.ClusterPrincipalAssignment{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ClusterPrincipalAssignmentsClient.Delete` + +```go +ctx := context.TODO() +id := clusterprincipalassignments.NewPrincipalAssignmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "principalAssignmentName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ClusterPrincipalAssignmentsClient.Get` + +```go +ctx := context.TODO() +id := clusterprincipalassignments.NewPrincipalAssignmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "principalAssignmentName") + +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: `ClusterPrincipalAssignmentsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +read, err := client.List(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/kusto/2024-04-13/clusterprincipalassignments/client.go b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/client.go new file mode 100644 index 00000000000..20b3be15cf5 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/client.go @@ -0,0 +1,26 @@ +package clusterprincipalassignments + +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 ClusterPrincipalAssignmentsClient struct { + Client *resourcemanager.Client +} + +func NewClusterPrincipalAssignmentsClientWithBaseURI(sdkApi sdkEnv.Api) (*ClusterPrincipalAssignmentsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "clusterprincipalassignments", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ClusterPrincipalAssignmentsClient: %+v", err) + } + + return &ClusterPrincipalAssignmentsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/kusto/2024-04-13/clusterprincipalassignments/constants.go b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/constants.go new file mode 100644 index 00000000000..a934bed80f4 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/constants.go @@ -0,0 +1,233 @@ +package clusterprincipalassignments + +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 ClusterPrincipalRole string + +const ( + ClusterPrincipalRoleAllDatabasesAdmin ClusterPrincipalRole = "AllDatabasesAdmin" + ClusterPrincipalRoleAllDatabasesMonitor ClusterPrincipalRole = "AllDatabasesMonitor" + ClusterPrincipalRoleAllDatabasesViewer ClusterPrincipalRole = "AllDatabasesViewer" +) + +func PossibleValuesForClusterPrincipalRole() []string { + return []string{ + string(ClusterPrincipalRoleAllDatabasesAdmin), + string(ClusterPrincipalRoleAllDatabasesMonitor), + string(ClusterPrincipalRoleAllDatabasesViewer), + } +} + +func (s *ClusterPrincipalRole) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterPrincipalRole(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterPrincipalRole(input string) (*ClusterPrincipalRole, error) { + vals := map[string]ClusterPrincipalRole{ + "alldatabasesadmin": ClusterPrincipalRoleAllDatabasesAdmin, + "alldatabasesmonitor": ClusterPrincipalRoleAllDatabasesMonitor, + "alldatabasesviewer": ClusterPrincipalRoleAllDatabasesViewer, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterPrincipalRole(input) + return &out, nil +} + +type PrincipalAssignmentType string + +const ( + PrincipalAssignmentTypeMicrosoftPointKustoClustersPrincipalAssignments PrincipalAssignmentType = "Microsoft.Kusto/clusters/principalAssignments" +) + +func PossibleValuesForPrincipalAssignmentType() []string { + return []string{ + string(PrincipalAssignmentTypeMicrosoftPointKustoClustersPrincipalAssignments), + } +} + +func (s *PrincipalAssignmentType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrincipalAssignmentType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrincipalAssignmentType(input string) (*PrincipalAssignmentType, error) { + vals := map[string]PrincipalAssignmentType{ + "microsoft.kusto/clusters/principalassignments": PrincipalAssignmentTypeMicrosoftPointKustoClustersPrincipalAssignments, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrincipalAssignmentType(input) + return &out, nil +} + +type PrincipalType string + +const ( + PrincipalTypeApp PrincipalType = "App" + PrincipalTypeGroup PrincipalType = "Group" + PrincipalTypeUser PrincipalType = "User" +) + +func PossibleValuesForPrincipalType() []string { + return []string{ + string(PrincipalTypeApp), + string(PrincipalTypeGroup), + string(PrincipalTypeUser), + } +} + +func (s *PrincipalType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrincipalType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrincipalType(input string) (*PrincipalType, error) { + vals := map[string]PrincipalType{ + "app": PrincipalTypeApp, + "group": PrincipalTypeGroup, + "user": PrincipalTypeUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrincipalType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateMoving ProvisioningState = "Moving" + ProvisioningStateRunning ProvisioningState = "Running" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateMoving), + string(ProvisioningStateRunning), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "moving": ProvisioningStateMoving, + "running": ProvisioningStateRunning, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type Reason string + +const ( + ReasonAlreadyExists Reason = "AlreadyExists" + ReasonInvalid Reason = "Invalid" +) + +func PossibleValuesForReason() []string { + return []string{ + string(ReasonAlreadyExists), + string(ReasonInvalid), + } +} + +func (s *Reason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReason(input string) (*Reason, error) { + vals := map[string]Reason{ + "alreadyexists": ReasonAlreadyExists, + "invalid": ReasonInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Reason(input) + return &out, nil +} diff --git a/resource-manager/kusto/2024-04-13/clusterprincipalassignments/id_principalassignment.go b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/id_principalassignment.go new file mode 100644 index 00000000000..ebe5d2d33ef --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/id_principalassignment.go @@ -0,0 +1,139 @@ +package clusterprincipalassignments + +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(&PrincipalAssignmentId{}) +} + +var _ resourceids.ResourceId = &PrincipalAssignmentId{} + +// PrincipalAssignmentId is a struct representing the Resource ID for a Principal Assignment +type PrincipalAssignmentId struct { + SubscriptionId string + ResourceGroupName string + ClusterName string + PrincipalAssignmentName string +} + +// NewPrincipalAssignmentID returns a new PrincipalAssignmentId struct +func NewPrincipalAssignmentID(subscriptionId string, resourceGroupName string, clusterName string, principalAssignmentName string) PrincipalAssignmentId { + return PrincipalAssignmentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ClusterName: clusterName, + PrincipalAssignmentName: principalAssignmentName, + } +} + +// ParsePrincipalAssignmentID parses 'input' into a PrincipalAssignmentId +func ParsePrincipalAssignmentID(input string) (*PrincipalAssignmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrincipalAssignmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrincipalAssignmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrincipalAssignmentIDInsensitively parses 'input' case-insensitively into a PrincipalAssignmentId +// note: this method should only be used for API response data and not user input +func ParsePrincipalAssignmentIDInsensitively(input string) (*PrincipalAssignmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrincipalAssignmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrincipalAssignmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrincipalAssignmentId) 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.ClusterName, ok = input.Parsed["clusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "clusterName", input) + } + + if id.PrincipalAssignmentName, ok = input.Parsed["principalAssignmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "principalAssignmentName", input) + } + + return nil +} + +// ValidatePrincipalAssignmentID checks that 'input' can be parsed as a Principal Assignment ID +func ValidatePrincipalAssignmentID(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 := ParsePrincipalAssignmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Principal Assignment ID +func (id PrincipalAssignmentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Kusto/clusters/%s/principalAssignments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName, id.PrincipalAssignmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Principal Assignment ID +func (id PrincipalAssignmentId) 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("staticMicrosoftKusto", "Microsoft.Kusto", "Microsoft.Kusto"), + resourceids.StaticSegment("staticClusters", "clusters", "clusters"), + resourceids.UserSpecifiedSegment("clusterName", "clusterName"), + resourceids.StaticSegment("staticPrincipalAssignments", "principalAssignments", "principalAssignments"), + resourceids.UserSpecifiedSegment("principalAssignmentName", "principalAssignmentName"), + } +} + +// String returns a human-readable description of this Principal Assignment ID +func (id PrincipalAssignmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cluster Name: %q", id.ClusterName), + fmt.Sprintf("Principal Assignment Name: %q", id.PrincipalAssignmentName), + } + return fmt.Sprintf("Principal Assignment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/kusto/2024-04-13/clusterprincipalassignments/id_principalassignment_test.go b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/id_principalassignment_test.go new file mode 100644 index 00000000000..8a7bea442c5 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/id_principalassignment_test.go @@ -0,0 +1,327 @@ +package clusterprincipalassignments + +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 = &PrincipalAssignmentId{} + +func TestNewPrincipalAssignmentID(t *testing.T) { + id := NewPrincipalAssignmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "principalAssignmentName") + + 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.ClusterName != "clusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterName") + } + + if id.PrincipalAssignmentName != "principalAssignmentName" { + t.Fatalf("Expected %q but got %q for Segment 'PrincipalAssignmentName'", id.PrincipalAssignmentName, "principalAssignmentName") + } +} + +func TestFormatPrincipalAssignmentID(t *testing.T) { + actual := NewPrincipalAssignmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "principalAssignmentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/principalAssignments/principalAssignmentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrincipalAssignmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrincipalAssignmentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/principalAssignments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/principalAssignments/principalAssignmentName", + Expected: &PrincipalAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + PrincipalAssignmentName: "principalAssignmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/principalAssignments/principalAssignmentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrincipalAssignmentID(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.PrincipalAssignmentName != v.Expected.PrincipalAssignmentName { + t.Fatalf("Expected %q but got %q for PrincipalAssignmentName", v.Expected.PrincipalAssignmentName, actual.PrincipalAssignmentName) + } + + } +} + +func TestParsePrincipalAssignmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrincipalAssignmentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/principalAssignments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/pRiNcIpAlAsSiGnMeNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/principalAssignments/principalAssignmentName", + Expected: &PrincipalAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + PrincipalAssignmentName: "principalAssignmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/principalAssignments/principalAssignmentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/pRiNcIpAlAsSiGnMeNtS/pRiNcIpAlAsSiGnMeNtNaMe", + Expected: &PrincipalAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ClusterName: "cLuStErNaMe", + PrincipalAssignmentName: "pRiNcIpAlAsSiGnMeNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/pRiNcIpAlAsSiGnMeNtS/pRiNcIpAlAsSiGnMeNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrincipalAssignmentIDInsensitively(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.PrincipalAssignmentName != v.Expected.PrincipalAssignmentName { + t.Fatalf("Expected %q but got %q for PrincipalAssignmentName", v.Expected.PrincipalAssignmentName, actual.PrincipalAssignmentName) + } + + } +} + +func TestSegmentsForPrincipalAssignmentId(t *testing.T) { + segments := PrincipalAssignmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrincipalAssignmentId 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/kusto/2024-04-13/clusterprincipalassignments/method_checknameavailability.go b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/method_checknameavailability.go new file mode 100644 index 00000000000..88cd7a85a86 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/method_checknameavailability.go @@ -0,0 +1,59 @@ +package clusterprincipalassignments + +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 CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameResult +} + +// CheckNameAvailability ... +func (c ClusterPrincipalAssignmentsClient) CheckNameAvailability(ctx context.Context, id commonids.KustoClusterId, input ClusterPrincipalAssignmentCheckNameRequest) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkPrincipalAssignmentNameAvailability", 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 CheckNameResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/clusterprincipalassignments/method_createorupdate.go b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/method_createorupdate.go new file mode 100644 index 00000000000..d74b33757e7 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/method_createorupdate.go @@ -0,0 +1,75 @@ +package clusterprincipalassignments + +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 *ClusterPrincipalAssignment +} + +// CreateOrUpdate ... +func (c ClusterPrincipalAssignmentsClient) CreateOrUpdate(ctx context.Context, id PrincipalAssignmentId, input ClusterPrincipalAssignment) (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 ClusterPrincipalAssignmentsClient) CreateOrUpdateThenPoll(ctx context.Context, id PrincipalAssignmentId, input ClusterPrincipalAssignment) 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/kusto/2024-04-13/clusterprincipalassignments/method_delete.go b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/method_delete.go new file mode 100644 index 00000000000..fd2029e069f --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/method_delete.go @@ -0,0 +1,71 @@ +package clusterprincipalassignments + +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 ClusterPrincipalAssignmentsClient) Delete(ctx context.Context, id PrincipalAssignmentId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ClusterPrincipalAssignmentsClient) DeleteThenPoll(ctx context.Context, id PrincipalAssignmentId) 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/kusto/2024-04-13/clusterprincipalassignments/method_get.go b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/method_get.go new file mode 100644 index 00000000000..ca4ab3ccde1 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/method_get.go @@ -0,0 +1,53 @@ +package clusterprincipalassignments + +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 *ClusterPrincipalAssignment +} + +// Get ... +func (c ClusterPrincipalAssignmentsClient) Get(ctx context.Context, id PrincipalAssignmentId) (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 ClusterPrincipalAssignment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/clusterprincipalassignments/method_list.go b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/method_list.go new file mode 100644 index 00000000000..e30ad607a75 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/method_list.go @@ -0,0 +1,55 @@ +package clusterprincipalassignments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ClusterPrincipalAssignmentListResult +} + +// List ... +func (c ClusterPrincipalAssignmentsClient) List(ctx context.Context, id commonids.KustoClusterId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/principalAssignments", 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 ClusterPrincipalAssignmentListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/clusterprincipalassignments/model_checknameresult.go b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/model_checknameresult.go new file mode 100644 index 00000000000..49e899dfb6b --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/model_checknameresult.go @@ -0,0 +1,11 @@ +package clusterprincipalassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameResult struct { + Message *string `json:"message,omitempty"` + Name *string `json:"name,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *Reason `json:"reason,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusterprincipalassignments/model_clusterprincipalassignment.go b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/model_clusterprincipalassignment.go new file mode 100644 index 00000000000..6630e52de5e --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/model_clusterprincipalassignment.go @@ -0,0 +1,11 @@ +package clusterprincipalassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterPrincipalAssignment struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ClusterPrincipalProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusterprincipalassignments/model_clusterprincipalassignmentchecknamerequest.go b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/model_clusterprincipalassignmentchecknamerequest.go new file mode 100644 index 00000000000..7c33df37d9e --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/model_clusterprincipalassignmentchecknamerequest.go @@ -0,0 +1,9 @@ +package clusterprincipalassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterPrincipalAssignmentCheckNameRequest struct { + Name string `json:"name"` + Type PrincipalAssignmentType `json:"type"` +} diff --git a/resource-manager/kusto/2024-04-13/clusterprincipalassignments/model_clusterprincipalassignmentlistresult.go b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/model_clusterprincipalassignmentlistresult.go new file mode 100644 index 00000000000..32653049bbf --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/model_clusterprincipalassignmentlistresult.go @@ -0,0 +1,8 @@ +package clusterprincipalassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterPrincipalAssignmentListResult struct { + Value *[]ClusterPrincipalAssignment `json:"value,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusterprincipalassignments/model_clusterprincipalproperties.go b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/model_clusterprincipalproperties.go new file mode 100644 index 00000000000..cd7e4eddc8e --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/model_clusterprincipalproperties.go @@ -0,0 +1,15 @@ +package clusterprincipalassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterPrincipalProperties struct { + AadObjectId *string `json:"aadObjectId,omitempty"` + PrincipalId string `json:"principalId"` + PrincipalName *string `json:"principalName,omitempty"` + PrincipalType PrincipalType `json:"principalType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Role ClusterPrincipalRole `json:"role"` + TenantId *string `json:"tenantId,omitempty"` + TenantName *string `json:"tenantName,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusterprincipalassignments/version.go b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/version.go new file mode 100644 index 00000000000..f6f21c20332 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusterprincipalassignments/version.go @@ -0,0 +1,10 @@ +package clusterprincipalassignments + +// 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-04-13" + +func userAgent() string { + return "hashicorp/go-azure-sdk/clusterprincipalassignments/2024-04-13" +} diff --git a/resource-manager/kusto/2024-04-13/clusters/README.md b/resource-manager/kusto/2024-04-13/clusters/README.md new file mode 100644 index 00000000000..897b121981d --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/README.md @@ -0,0 +1,356 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/clusters` Documentation + +The `clusters` SDK allows for interaction with Azure Resource Manager `kusto` (API Version `2024-04-13`). + +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/kusto/2024-04-13/clusters" +``` + + +### Client Initialization + +```go +client := clusters.NewClustersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ClustersClient.AddCalloutPolicies` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +payload := clusters.CalloutPoliciesList{ + // ... +} + + +if err := client.AddCalloutPoliciesThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ClustersClient.AddLanguageExtensions` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +payload := clusters.LanguageExtensionsList{ + // ... +} + + +if err := client.AddLanguageExtensionsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ClustersClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := clusters.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := clusters.ClusterCheckNameRequest{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ClustersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +payload := clusters.Cluster{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload, clusters.DefaultCreateOrUpdateOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `ClustersClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ClustersClient.DetachFollowerDatabases` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +payload := clusters.FollowerDatabaseDefinition{ + // ... +} + + +if err := client.DetachFollowerDatabasesThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ClustersClient.DiagnoseVirtualNetwork` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +if err := client.DiagnoseVirtualNetworkThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ClustersClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +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: `ClustersClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.List(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ClustersClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +read, err := client.ListByResourceGroup(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ClustersClient.ListCalloutPolicies` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +// alternatively `client.ListCalloutPolicies(ctx, id)` can be used to do batched pagination +items, err := client.ListCalloutPoliciesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ClustersClient.ListFollowerDatabases` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +read, err := client.ListFollowerDatabases(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ClustersClient.ListFollowerDatabasesGet` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +// alternatively `client.ListFollowerDatabasesGet(ctx, id)` can be used to do batched pagination +items, err := client.ListFollowerDatabasesGetComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ClustersClient.ListLanguageExtensions` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +read, err := client.ListLanguageExtensions(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ClustersClient.ListSkusByResource` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +read, err := client.ListSkusByResource(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ClustersClient.Migrate` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +payload := clusters.ClusterMigrateRequest{ + // ... +} + + +if err := client.MigrateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ClustersClient.RemoveCalloutPolicy` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +payload := clusters.CalloutPolicyToRemove{ + // ... +} + + +if err := client.RemoveCalloutPolicyThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ClustersClient.RemoveLanguageExtensions` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +payload := clusters.LanguageExtensionsList{ + // ... +} + + +if err := client.RemoveLanguageExtensionsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ClustersClient.Start` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +if err := client.StartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ClustersClient.Stop` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +if err := client.StopThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ClustersClient.Update` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +payload := clusters.ClusterUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload, clusters.DefaultUpdateOperationOptions()); err != nil { + // handle the error +} +``` diff --git a/resource-manager/kusto/2024-04-13/clusters/client.go b/resource-manager/kusto/2024-04-13/clusters/client.go new file mode 100644 index 00000000000..4ead092b486 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/client.go @@ -0,0 +1,26 @@ +package clusters + +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 ClustersClient struct { + Client *resourcemanager.Client +} + +func NewClustersClientWithBaseURI(sdkApi sdkEnv.Api) (*ClustersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "clusters", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ClustersClient: %+v", err) + } + + return &ClustersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/kusto/2024-04-13/clusters/constants.go b/resource-manager/kusto/2024-04-13/clusters/constants.go new file mode 100644 index 00000000000..03a20b6173f --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/constants.go @@ -0,0 +1,1062 @@ +package clusters + +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 AzureScaleType string + +const ( + AzureScaleTypeAutomatic AzureScaleType = "automatic" + AzureScaleTypeManual AzureScaleType = "manual" + AzureScaleTypeNone AzureScaleType = "none" +) + +func PossibleValuesForAzureScaleType() []string { + return []string{ + string(AzureScaleTypeAutomatic), + string(AzureScaleTypeManual), + string(AzureScaleTypeNone), + } +} + +func (s *AzureScaleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureScaleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureScaleType(input string) (*AzureScaleType, error) { + vals := map[string]AzureScaleType{ + "automatic": AzureScaleTypeAutomatic, + "manual": AzureScaleTypeManual, + "none": AzureScaleTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureScaleType(input) + return &out, nil +} + +type AzureSkuName string + +const ( + AzureSkuNameDevNoSLAStandardDOneOneVTwo AzureSkuName = "Dev(No SLA)_Standard_D11_v2" + AzureSkuNameDevNoSLAStandardETwoaVFour AzureSkuName = "Dev(No SLA)_Standard_E2a_v4" + AzureSkuNameStandardDOneFourVTwo AzureSkuName = "Standard_D14_v2" + AzureSkuNameStandardDOneOneVTwo AzureSkuName = "Standard_D11_v2" + AzureSkuNameStandardDOneSixdVFive AzureSkuName = "Standard_D16d_v5" + AzureSkuNameStandardDOneThreeVTwo AzureSkuName = "Standard_D13_v2" + AzureSkuNameStandardDOneTwoVTwo AzureSkuName = "Standard_D12_v2" + AzureSkuNameStandardDSOneFourVTwoPositiveFourTBPS AzureSkuName = "Standard_DS14_v2+4TB_PS" + AzureSkuNameStandardDSOneFourVTwoPositiveThreeTBPS AzureSkuName = "Standard_DS14_v2+3TB_PS" + AzureSkuNameStandardDSOneThreeVTwoPositiveOneTBPS AzureSkuName = "Standard_DS13_v2+1TB_PS" + AzureSkuNameStandardDSOneThreeVTwoPositiveTwoTBPS AzureSkuName = "Standard_DS13_v2+2TB_PS" + AzureSkuNameStandardDThreeTwodVFive AzureSkuName = "Standard_D32d_v5" + AzureSkuNameStandardDThreeTwodVFour AzureSkuName = "Standard_D32d_v4" + AzureSkuNameStandardECEightadsVFive AzureSkuName = "Standard_EC8ads_v5" + AzureSkuNameStandardECEightasVFivePositiveOneTBPS AzureSkuName = "Standard_EC8as_v5+1TB_PS" + AzureSkuNameStandardECEightasVFivePositiveTwoTBPS AzureSkuName = "Standard_EC8as_v5+2TB_PS" + AzureSkuNameStandardECOneSixadsVFive AzureSkuName = "Standard_EC16ads_v5" + AzureSkuNameStandardECOneSixasVFivePositiveFourTBPS AzureSkuName = "Standard_EC16as_v5+4TB_PS" + AzureSkuNameStandardECOneSixasVFivePositiveThreeTBPS AzureSkuName = "Standard_EC16as_v5+3TB_PS" + AzureSkuNameStandardEEightZeroidsVFour AzureSkuName = "Standard_E80ids_v4" + AzureSkuNameStandardEEightaVFour AzureSkuName = "Standard_E8a_v4" + AzureSkuNameStandardEEightadsVFive AzureSkuName = "Standard_E8ads_v5" + AzureSkuNameStandardEEightasVFivePositiveOneTBPS AzureSkuName = "Standard_E8as_v5+1TB_PS" + AzureSkuNameStandardEEightasVFivePositiveTwoTBPS AzureSkuName = "Standard_E8as_v5+2TB_PS" + AzureSkuNameStandardEEightasVFourPositiveOneTBPS AzureSkuName = "Standard_E8as_v4+1TB_PS" + AzureSkuNameStandardEEightasVFourPositiveTwoTBPS AzureSkuName = "Standard_E8as_v4+2TB_PS" + AzureSkuNameStandardEEightdVFive AzureSkuName = "Standard_E8d_v5" + AzureSkuNameStandardEEightdVFour AzureSkuName = "Standard_E8d_v4" + AzureSkuNameStandardEEightsVFivePositiveOneTBPS AzureSkuName = "Standard_E8s_v5+1TB_PS" + AzureSkuNameStandardEEightsVFivePositiveTwoTBPS AzureSkuName = "Standard_E8s_v5+2TB_PS" + AzureSkuNameStandardEEightsVFourPositiveOneTBPS AzureSkuName = "Standard_E8s_v4+1TB_PS" + AzureSkuNameStandardEEightsVFourPositiveTwoTBPS AzureSkuName = "Standard_E8s_v4+2TB_PS" + AzureSkuNameStandardEFouraVFour AzureSkuName = "Standard_E4a_v4" + AzureSkuNameStandardEFouradsVFive AzureSkuName = "Standard_E4ads_v5" + AzureSkuNameStandardEFourdVFive AzureSkuName = "Standard_E4d_v5" + AzureSkuNameStandardEFourdVFour AzureSkuName = "Standard_E4d_v4" + AzureSkuNameStandardEOneSixaVFour AzureSkuName = "Standard_E16a_v4" + AzureSkuNameStandardEOneSixadsVFive AzureSkuName = "Standard_E16ads_v5" + AzureSkuNameStandardEOneSixasVFivePositiveFourTBPS AzureSkuName = "Standard_E16as_v5+4TB_PS" + AzureSkuNameStandardEOneSixasVFivePositiveThreeTBPS AzureSkuName = "Standard_E16as_v5+3TB_PS" + AzureSkuNameStandardEOneSixasVFourPositiveFourTBPS AzureSkuName = "Standard_E16as_v4+4TB_PS" + AzureSkuNameStandardEOneSixasVFourPositiveThreeTBPS AzureSkuName = "Standard_E16as_v4+3TB_PS" + AzureSkuNameStandardEOneSixdVFive AzureSkuName = "Standard_E16d_v5" + AzureSkuNameStandardEOneSixdVFour AzureSkuName = "Standard_E16d_v4" + AzureSkuNameStandardEOneSixsVFivePositiveFourTBPS AzureSkuName = "Standard_E16s_v5+4TB_PS" + AzureSkuNameStandardEOneSixsVFivePositiveThreeTBPS AzureSkuName = "Standard_E16s_v5+3TB_PS" + AzureSkuNameStandardEOneSixsVFourPositiveFourTBPS AzureSkuName = "Standard_E16s_v4+4TB_PS" + AzureSkuNameStandardEOneSixsVFourPositiveThreeTBPS AzureSkuName = "Standard_E16s_v4+3TB_PS" + AzureSkuNameStandardESixFouriVThree AzureSkuName = "Standard_E64i_v3" + AzureSkuNameStandardETwoaVFour AzureSkuName = "Standard_E2a_v4" + AzureSkuNameStandardETwoadsVFive AzureSkuName = "Standard_E2ads_v5" + AzureSkuNameStandardETwodVFive AzureSkuName = "Standard_E2d_v5" + AzureSkuNameStandardETwodVFour AzureSkuName = "Standard_E2d_v4" + AzureSkuNameStandardLEightasVThree AzureSkuName = "Standard_L8as_v3" + AzureSkuNameStandardLEights AzureSkuName = "Standard_L8s" + AzureSkuNameStandardLEightsVThree AzureSkuName = "Standard_L8s_v3" + AzureSkuNameStandardLEightsVTwo AzureSkuName = "Standard_L8s_v2" + AzureSkuNameStandardLFours AzureSkuName = "Standard_L4s" + AzureSkuNameStandardLOneSixasVThree AzureSkuName = "Standard_L16as_v3" + AzureSkuNameStandardLOneSixs AzureSkuName = "Standard_L16s" + AzureSkuNameStandardLOneSixsVThree AzureSkuName = "Standard_L16s_v3" + AzureSkuNameStandardLOneSixsVTwo AzureSkuName = "Standard_L16s_v2" + AzureSkuNameStandardLThreeTwoasVThree AzureSkuName = "Standard_L32as_v3" + AzureSkuNameStandardLThreeTwosVThree AzureSkuName = "Standard_L32s_v3" +) + +func PossibleValuesForAzureSkuName() []string { + return []string{ + string(AzureSkuNameDevNoSLAStandardDOneOneVTwo), + string(AzureSkuNameDevNoSLAStandardETwoaVFour), + string(AzureSkuNameStandardDOneFourVTwo), + string(AzureSkuNameStandardDOneOneVTwo), + string(AzureSkuNameStandardDOneSixdVFive), + string(AzureSkuNameStandardDOneThreeVTwo), + string(AzureSkuNameStandardDOneTwoVTwo), + string(AzureSkuNameStandardDSOneFourVTwoPositiveFourTBPS), + string(AzureSkuNameStandardDSOneFourVTwoPositiveThreeTBPS), + string(AzureSkuNameStandardDSOneThreeVTwoPositiveOneTBPS), + string(AzureSkuNameStandardDSOneThreeVTwoPositiveTwoTBPS), + string(AzureSkuNameStandardDThreeTwodVFive), + string(AzureSkuNameStandardDThreeTwodVFour), + string(AzureSkuNameStandardECEightadsVFive), + string(AzureSkuNameStandardECEightasVFivePositiveOneTBPS), + string(AzureSkuNameStandardECEightasVFivePositiveTwoTBPS), + string(AzureSkuNameStandardECOneSixadsVFive), + string(AzureSkuNameStandardECOneSixasVFivePositiveFourTBPS), + string(AzureSkuNameStandardECOneSixasVFivePositiveThreeTBPS), + string(AzureSkuNameStandardEEightZeroidsVFour), + string(AzureSkuNameStandardEEightaVFour), + string(AzureSkuNameStandardEEightadsVFive), + string(AzureSkuNameStandardEEightasVFivePositiveOneTBPS), + string(AzureSkuNameStandardEEightasVFivePositiveTwoTBPS), + string(AzureSkuNameStandardEEightasVFourPositiveOneTBPS), + string(AzureSkuNameStandardEEightasVFourPositiveTwoTBPS), + string(AzureSkuNameStandardEEightdVFive), + string(AzureSkuNameStandardEEightdVFour), + string(AzureSkuNameStandardEEightsVFivePositiveOneTBPS), + string(AzureSkuNameStandardEEightsVFivePositiveTwoTBPS), + string(AzureSkuNameStandardEEightsVFourPositiveOneTBPS), + string(AzureSkuNameStandardEEightsVFourPositiveTwoTBPS), + string(AzureSkuNameStandardEFouraVFour), + string(AzureSkuNameStandardEFouradsVFive), + string(AzureSkuNameStandardEFourdVFive), + string(AzureSkuNameStandardEFourdVFour), + string(AzureSkuNameStandardEOneSixaVFour), + string(AzureSkuNameStandardEOneSixadsVFive), + string(AzureSkuNameStandardEOneSixasVFivePositiveFourTBPS), + string(AzureSkuNameStandardEOneSixasVFivePositiveThreeTBPS), + string(AzureSkuNameStandardEOneSixasVFourPositiveFourTBPS), + string(AzureSkuNameStandardEOneSixasVFourPositiveThreeTBPS), + string(AzureSkuNameStandardEOneSixdVFive), + string(AzureSkuNameStandardEOneSixdVFour), + string(AzureSkuNameStandardEOneSixsVFivePositiveFourTBPS), + string(AzureSkuNameStandardEOneSixsVFivePositiveThreeTBPS), + string(AzureSkuNameStandardEOneSixsVFourPositiveFourTBPS), + string(AzureSkuNameStandardEOneSixsVFourPositiveThreeTBPS), + string(AzureSkuNameStandardESixFouriVThree), + string(AzureSkuNameStandardETwoaVFour), + string(AzureSkuNameStandardETwoadsVFive), + string(AzureSkuNameStandardETwodVFive), + string(AzureSkuNameStandardETwodVFour), + string(AzureSkuNameStandardLEightasVThree), + string(AzureSkuNameStandardLEights), + string(AzureSkuNameStandardLEightsVThree), + string(AzureSkuNameStandardLEightsVTwo), + string(AzureSkuNameStandardLFours), + string(AzureSkuNameStandardLOneSixasVThree), + string(AzureSkuNameStandardLOneSixs), + string(AzureSkuNameStandardLOneSixsVThree), + string(AzureSkuNameStandardLOneSixsVTwo), + string(AzureSkuNameStandardLThreeTwoasVThree), + string(AzureSkuNameStandardLThreeTwosVThree), + } +} + +func (s *AzureSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureSkuName(input string) (*AzureSkuName, error) { + vals := map[string]AzureSkuName{ + "dev(no sla)_standard_d11_v2": AzureSkuNameDevNoSLAStandardDOneOneVTwo, + "dev(no sla)_standard_e2a_v4": AzureSkuNameDevNoSLAStandardETwoaVFour, + "standard_d14_v2": AzureSkuNameStandardDOneFourVTwo, + "standard_d11_v2": AzureSkuNameStandardDOneOneVTwo, + "standard_d16d_v5": AzureSkuNameStandardDOneSixdVFive, + "standard_d13_v2": AzureSkuNameStandardDOneThreeVTwo, + "standard_d12_v2": AzureSkuNameStandardDOneTwoVTwo, + "standard_ds14_v2+4tb_ps": AzureSkuNameStandardDSOneFourVTwoPositiveFourTBPS, + "standard_ds14_v2+3tb_ps": AzureSkuNameStandardDSOneFourVTwoPositiveThreeTBPS, + "standard_ds13_v2+1tb_ps": AzureSkuNameStandardDSOneThreeVTwoPositiveOneTBPS, + "standard_ds13_v2+2tb_ps": AzureSkuNameStandardDSOneThreeVTwoPositiveTwoTBPS, + "standard_d32d_v5": AzureSkuNameStandardDThreeTwodVFive, + "standard_d32d_v4": AzureSkuNameStandardDThreeTwodVFour, + "standard_ec8ads_v5": AzureSkuNameStandardECEightadsVFive, + "standard_ec8as_v5+1tb_ps": AzureSkuNameStandardECEightasVFivePositiveOneTBPS, + "standard_ec8as_v5+2tb_ps": AzureSkuNameStandardECEightasVFivePositiveTwoTBPS, + "standard_ec16ads_v5": AzureSkuNameStandardECOneSixadsVFive, + "standard_ec16as_v5+4tb_ps": AzureSkuNameStandardECOneSixasVFivePositiveFourTBPS, + "standard_ec16as_v5+3tb_ps": AzureSkuNameStandardECOneSixasVFivePositiveThreeTBPS, + "standard_e80ids_v4": AzureSkuNameStandardEEightZeroidsVFour, + "standard_e8a_v4": AzureSkuNameStandardEEightaVFour, + "standard_e8ads_v5": AzureSkuNameStandardEEightadsVFive, + "standard_e8as_v5+1tb_ps": AzureSkuNameStandardEEightasVFivePositiveOneTBPS, + "standard_e8as_v5+2tb_ps": AzureSkuNameStandardEEightasVFivePositiveTwoTBPS, + "standard_e8as_v4+1tb_ps": AzureSkuNameStandardEEightasVFourPositiveOneTBPS, + "standard_e8as_v4+2tb_ps": AzureSkuNameStandardEEightasVFourPositiveTwoTBPS, + "standard_e8d_v5": AzureSkuNameStandardEEightdVFive, + "standard_e8d_v4": AzureSkuNameStandardEEightdVFour, + "standard_e8s_v5+1tb_ps": AzureSkuNameStandardEEightsVFivePositiveOneTBPS, + "standard_e8s_v5+2tb_ps": AzureSkuNameStandardEEightsVFivePositiveTwoTBPS, + "standard_e8s_v4+1tb_ps": AzureSkuNameStandardEEightsVFourPositiveOneTBPS, + "standard_e8s_v4+2tb_ps": AzureSkuNameStandardEEightsVFourPositiveTwoTBPS, + "standard_e4a_v4": AzureSkuNameStandardEFouraVFour, + "standard_e4ads_v5": AzureSkuNameStandardEFouradsVFive, + "standard_e4d_v5": AzureSkuNameStandardEFourdVFive, + "standard_e4d_v4": AzureSkuNameStandardEFourdVFour, + "standard_e16a_v4": AzureSkuNameStandardEOneSixaVFour, + "standard_e16ads_v5": AzureSkuNameStandardEOneSixadsVFive, + "standard_e16as_v5+4tb_ps": AzureSkuNameStandardEOneSixasVFivePositiveFourTBPS, + "standard_e16as_v5+3tb_ps": AzureSkuNameStandardEOneSixasVFivePositiveThreeTBPS, + "standard_e16as_v4+4tb_ps": AzureSkuNameStandardEOneSixasVFourPositiveFourTBPS, + "standard_e16as_v4+3tb_ps": AzureSkuNameStandardEOneSixasVFourPositiveThreeTBPS, + "standard_e16d_v5": AzureSkuNameStandardEOneSixdVFive, + "standard_e16d_v4": AzureSkuNameStandardEOneSixdVFour, + "standard_e16s_v5+4tb_ps": AzureSkuNameStandardEOneSixsVFivePositiveFourTBPS, + "standard_e16s_v5+3tb_ps": AzureSkuNameStandardEOneSixsVFivePositiveThreeTBPS, + "standard_e16s_v4+4tb_ps": AzureSkuNameStandardEOneSixsVFourPositiveFourTBPS, + "standard_e16s_v4+3tb_ps": AzureSkuNameStandardEOneSixsVFourPositiveThreeTBPS, + "standard_e64i_v3": AzureSkuNameStandardESixFouriVThree, + "standard_e2a_v4": AzureSkuNameStandardETwoaVFour, + "standard_e2ads_v5": AzureSkuNameStandardETwoadsVFive, + "standard_e2d_v5": AzureSkuNameStandardETwodVFive, + "standard_e2d_v4": AzureSkuNameStandardETwodVFour, + "standard_l8as_v3": AzureSkuNameStandardLEightasVThree, + "standard_l8s": AzureSkuNameStandardLEights, + "standard_l8s_v3": AzureSkuNameStandardLEightsVThree, + "standard_l8s_v2": AzureSkuNameStandardLEightsVTwo, + "standard_l4s": AzureSkuNameStandardLFours, + "standard_l16as_v3": AzureSkuNameStandardLOneSixasVThree, + "standard_l16s": AzureSkuNameStandardLOneSixs, + "standard_l16s_v3": AzureSkuNameStandardLOneSixsVThree, + "standard_l16s_v2": AzureSkuNameStandardLOneSixsVTwo, + "standard_l32as_v3": AzureSkuNameStandardLThreeTwoasVThree, + "standard_l32s_v3": AzureSkuNameStandardLThreeTwosVThree, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureSkuName(input) + return &out, nil +} + +type AzureSkuTier string + +const ( + AzureSkuTierBasic AzureSkuTier = "Basic" + AzureSkuTierStandard AzureSkuTier = "Standard" +) + +func PossibleValuesForAzureSkuTier() []string { + return []string{ + string(AzureSkuTierBasic), + string(AzureSkuTierStandard), + } +} + +func (s *AzureSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureSkuTier(input string) (*AzureSkuTier, error) { + vals := map[string]AzureSkuTier{ + "basic": AzureSkuTierBasic, + "standard": AzureSkuTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureSkuTier(input) + return &out, nil +} + +type CalloutType string + +const ( + CalloutTypeAzureDigitalTwins CalloutType = "azure_digital_twins" + CalloutTypeAzureOpenai CalloutType = "azure_openai" + CalloutTypeCosmosdb CalloutType = "cosmosdb" + CalloutTypeExternalData CalloutType = "external_data" + CalloutTypeGenevametrics CalloutType = "genevametrics" + CalloutTypeKusto CalloutType = "kusto" + CalloutTypeMysql CalloutType = "mysql" + CalloutTypePostgresql CalloutType = "postgresql" + CalloutTypeSandboxArtifacts CalloutType = "sandbox_artifacts" + CalloutTypeSql CalloutType = "sql" + CalloutTypeWebapi CalloutType = "webapi" +) + +func PossibleValuesForCalloutType() []string { + return []string{ + string(CalloutTypeAzureDigitalTwins), + string(CalloutTypeAzureOpenai), + string(CalloutTypeCosmosdb), + string(CalloutTypeExternalData), + string(CalloutTypeGenevametrics), + string(CalloutTypeKusto), + string(CalloutTypeMysql), + string(CalloutTypePostgresql), + string(CalloutTypeSandboxArtifacts), + string(CalloutTypeSql), + string(CalloutTypeWebapi), + } +} + +func (s *CalloutType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCalloutType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCalloutType(input string) (*CalloutType, error) { + vals := map[string]CalloutType{ + "azure_digital_twins": CalloutTypeAzureDigitalTwins, + "azure_openai": CalloutTypeAzureOpenai, + "cosmosdb": CalloutTypeCosmosdb, + "external_data": CalloutTypeExternalData, + "genevametrics": CalloutTypeGenevametrics, + "kusto": CalloutTypeKusto, + "mysql": CalloutTypeMysql, + "postgresql": CalloutTypePostgresql, + "sandbox_artifacts": CalloutTypeSandboxArtifacts, + "sql": CalloutTypeSql, + "webapi": CalloutTypeWebapi, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CalloutType(input) + return &out, nil +} + +type ClusterNetworkAccessFlag string + +const ( + ClusterNetworkAccessFlagDisabled ClusterNetworkAccessFlag = "Disabled" + ClusterNetworkAccessFlagEnabled ClusterNetworkAccessFlag = "Enabled" +) + +func PossibleValuesForClusterNetworkAccessFlag() []string { + return []string{ + string(ClusterNetworkAccessFlagDisabled), + string(ClusterNetworkAccessFlagEnabled), + } +} + +func (s *ClusterNetworkAccessFlag) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterNetworkAccessFlag(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterNetworkAccessFlag(input string) (*ClusterNetworkAccessFlag, error) { + vals := map[string]ClusterNetworkAccessFlag{ + "disabled": ClusterNetworkAccessFlagDisabled, + "enabled": ClusterNetworkAccessFlagEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterNetworkAccessFlag(input) + return &out, nil +} + +type ClusterType string + +const ( + ClusterTypeMicrosoftPointKustoClusters ClusterType = "Microsoft.Kusto/clusters" +) + +func PossibleValuesForClusterType() []string { + return []string{ + string(ClusterTypeMicrosoftPointKustoClusters), + } +} + +func (s *ClusterType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterType(input string) (*ClusterType, error) { + vals := map[string]ClusterType{ + "microsoft.kusto/clusters": ClusterTypeMicrosoftPointKustoClusters, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterType(input) + return &out, nil +} + +type DatabaseShareOrigin string + +const ( + DatabaseShareOriginDataShare DatabaseShareOrigin = "DataShare" + DatabaseShareOriginDirect DatabaseShareOrigin = "Direct" + DatabaseShareOriginOther DatabaseShareOrigin = "Other" +) + +func PossibleValuesForDatabaseShareOrigin() []string { + return []string{ + string(DatabaseShareOriginDataShare), + string(DatabaseShareOriginDirect), + string(DatabaseShareOriginOther), + } +} + +func (s *DatabaseShareOrigin) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDatabaseShareOrigin(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDatabaseShareOrigin(input string) (*DatabaseShareOrigin, error) { + vals := map[string]DatabaseShareOrigin{ + "datashare": DatabaseShareOriginDataShare, + "direct": DatabaseShareOriginDirect, + "other": DatabaseShareOriginOther, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DatabaseShareOrigin(input) + return &out, nil +} + +type EngineType string + +const ( + EngineTypeVThree EngineType = "V3" + EngineTypeVTwo EngineType = "V2" +) + +func PossibleValuesForEngineType() []string { + return []string{ + string(EngineTypeVThree), + string(EngineTypeVTwo), + } +} + +func (s *EngineType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEngineType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEngineType(input string) (*EngineType, error) { + vals := map[string]EngineType{ + "v3": EngineTypeVThree, + "v2": EngineTypeVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EngineType(input) + return &out, nil +} + +type LanguageExtensionImageName string + +const ( + LanguageExtensionImageNamePythonCustomImage LanguageExtensionImageName = "PythonCustomImage" + LanguageExtensionImageNamePythonThreeOneOneSeven LanguageExtensionImageName = "Python3_11_7" + LanguageExtensionImageNamePythonThreeOneOneSevenDL LanguageExtensionImageName = "Python3_11_7_DL" + LanguageExtensionImageNamePythonThreeOneZeroEight LanguageExtensionImageName = "Python3_10_8" + LanguageExtensionImageNamePythonThreeOneZeroEightDL LanguageExtensionImageName = "Python3_10_8_DL" + LanguageExtensionImageNamePythonThreeSixFive LanguageExtensionImageName = "Python3_6_5" + LanguageExtensionImageNameR LanguageExtensionImageName = "R" +) + +func PossibleValuesForLanguageExtensionImageName() []string { + return []string{ + string(LanguageExtensionImageNamePythonCustomImage), + string(LanguageExtensionImageNamePythonThreeOneOneSeven), + string(LanguageExtensionImageNamePythonThreeOneOneSevenDL), + string(LanguageExtensionImageNamePythonThreeOneZeroEight), + string(LanguageExtensionImageNamePythonThreeOneZeroEightDL), + string(LanguageExtensionImageNamePythonThreeSixFive), + string(LanguageExtensionImageNameR), + } +} + +func (s *LanguageExtensionImageName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLanguageExtensionImageName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLanguageExtensionImageName(input string) (*LanguageExtensionImageName, error) { + vals := map[string]LanguageExtensionImageName{ + "pythoncustomimage": LanguageExtensionImageNamePythonCustomImage, + "python3_11_7": LanguageExtensionImageNamePythonThreeOneOneSeven, + "python3_11_7_dl": LanguageExtensionImageNamePythonThreeOneOneSevenDL, + "python3_10_8": LanguageExtensionImageNamePythonThreeOneZeroEight, + "python3_10_8_dl": LanguageExtensionImageNamePythonThreeOneZeroEightDL, + "python3_6_5": LanguageExtensionImageNamePythonThreeSixFive, + "r": LanguageExtensionImageNameR, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LanguageExtensionImageName(input) + return &out, nil +} + +type LanguageExtensionName string + +const ( + LanguageExtensionNamePYTHON LanguageExtensionName = "PYTHON" + LanguageExtensionNameR LanguageExtensionName = "R" +) + +func PossibleValuesForLanguageExtensionName() []string { + return []string{ + string(LanguageExtensionNamePYTHON), + string(LanguageExtensionNameR), + } +} + +func (s *LanguageExtensionName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLanguageExtensionName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLanguageExtensionName(input string) (*LanguageExtensionName, error) { + vals := map[string]LanguageExtensionName{ + "python": LanguageExtensionNamePYTHON, + "r": LanguageExtensionNameR, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LanguageExtensionName(input) + return &out, nil +} + +type MigrationClusterRole string + +const ( + MigrationClusterRoleDestination MigrationClusterRole = "Destination" + MigrationClusterRoleSource MigrationClusterRole = "Source" +) + +func PossibleValuesForMigrationClusterRole() []string { + return []string{ + string(MigrationClusterRoleDestination), + string(MigrationClusterRoleSource), + } +} + +func (s *MigrationClusterRole) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMigrationClusterRole(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMigrationClusterRole(input string) (*MigrationClusterRole, error) { + vals := map[string]MigrationClusterRole{ + "destination": MigrationClusterRoleDestination, + "source": MigrationClusterRoleSource, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MigrationClusterRole(input) + return &out, nil +} + +type OutboundAccess string + +const ( + OutboundAccessAllow OutboundAccess = "Allow" + OutboundAccessDeny OutboundAccess = "Deny" +) + +func PossibleValuesForOutboundAccess() []string { + return []string{ + string(OutboundAccessAllow), + string(OutboundAccessDeny), + } +} + +func (s *OutboundAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOutboundAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOutboundAccess(input string) (*OutboundAccess, error) { + vals := map[string]OutboundAccess{ + "allow": OutboundAccessAllow, + "deny": OutboundAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OutboundAccess(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateMoving ProvisioningState = "Moving" + ProvisioningStateRunning ProvisioningState = "Running" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateMoving), + string(ProvisioningStateRunning), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "moving": ProvisioningStateMoving, + "running": ProvisioningStateRunning, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPType string + +const ( + PublicIPTypeDualStack PublicIPType = "DualStack" + PublicIPTypeIPvFour PublicIPType = "IPv4" +) + +func PossibleValuesForPublicIPType() []string { + return []string{ + string(PublicIPTypeDualStack), + string(PublicIPTypeIPvFour), + } +} + +func (s *PublicIPType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPType(input string) (*PublicIPType, error) { + vals := map[string]PublicIPType{ + "dualstack": PublicIPTypeDualStack, + "ipv4": PublicIPTypeIPvFour, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPType(input) + return &out, nil +} + +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" +) + +func PossibleValuesForPublicNetworkAccess() []string { + return []string{ + string(PublicNetworkAccessDisabled), + string(PublicNetworkAccessEnabled), + } +} + +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { + vals := map[string]PublicNetworkAccess{ + "disabled": PublicNetworkAccessDisabled, + "enabled": PublicNetworkAccessEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccess(input) + return &out, nil +} + +type Reason string + +const ( + ReasonAlreadyExists Reason = "AlreadyExists" + ReasonInvalid Reason = "Invalid" +) + +func PossibleValuesForReason() []string { + return []string{ + string(ReasonAlreadyExists), + string(ReasonInvalid), + } +} + +func (s *Reason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReason(input string) (*Reason, error) { + vals := map[string]Reason{ + "alreadyexists": ReasonAlreadyExists, + "invalid": ReasonInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Reason(input) + return &out, nil +} + +type State string + +const ( + StateCreating State = "Creating" + StateDeleted State = "Deleted" + StateDeleting State = "Deleting" + StateMigrated State = "Migrated" + StateRunning State = "Running" + StateStarting State = "Starting" + StateStopped State = "Stopped" + StateStopping State = "Stopping" + StateUnavailable State = "Unavailable" + StateUpdating State = "Updating" +) + +func PossibleValuesForState() []string { + return []string{ + string(StateCreating), + string(StateDeleted), + string(StateDeleting), + string(StateMigrated), + string(StateRunning), + string(StateStarting), + string(StateStopped), + string(StateStopping), + string(StateUnavailable), + string(StateUpdating), + } +} + +func (s *State) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseState(input string) (*State, error) { + vals := map[string]State{ + "creating": StateCreating, + "deleted": StateDeleted, + "deleting": StateDeleting, + "migrated": StateMigrated, + "running": StateRunning, + "starting": StateStarting, + "stopped": StateStopped, + "stopping": StateStopping, + "unavailable": StateUnavailable, + "updating": StateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := State(input) + return &out, nil +} + +type VnetState string + +const ( + VnetStateDisabled VnetState = "Disabled" + VnetStateEnabled VnetState = "Enabled" +) + +func PossibleValuesForVnetState() []string { + return []string{ + string(VnetStateDisabled), + string(VnetStateEnabled), + } +} + +func (s *VnetState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVnetState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVnetState(input string) (*VnetState, error) { + vals := map[string]VnetState{ + "disabled": VnetStateDisabled, + "enabled": VnetStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VnetState(input) + return &out, nil +} + +type ZoneStatus string + +const ( + ZoneStatusNonZonal ZoneStatus = "NonZonal" + ZoneStatusZonal ZoneStatus = "Zonal" + ZoneStatusZonalInconsistency ZoneStatus = "ZonalInconsistency" +) + +func PossibleValuesForZoneStatus() []string { + return []string{ + string(ZoneStatusNonZonal), + string(ZoneStatusZonal), + string(ZoneStatusZonalInconsistency), + } +} + +func (s *ZoneStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseZoneStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseZoneStatus(input string) (*ZoneStatus, error) { + vals := map[string]ZoneStatus{ + "nonzonal": ZoneStatusNonZonal, + "zonal": ZoneStatusZonal, + "zonalinconsistency": ZoneStatusZonalInconsistency, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ZoneStatus(input) + return &out, nil +} diff --git a/resource-manager/kusto/2024-04-13/clusters/id_location.go b/resource-manager/kusto/2024-04-13/clusters/id_location.go new file mode 100644 index 00000000000..19571e74f04 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/id_location.go @@ -0,0 +1,121 @@ +package clusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Kusto/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("staticMicrosoftKusto", "Microsoft.Kusto", "Microsoft.Kusto"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// 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/kusto/2024-04-13/clusters/id_location_test.go b/resource-manager/kusto/2024-04-13/clusters/id_location_test.go new file mode 100644 index 00000000000..f5bc75b9954 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/id_location_test.go @@ -0,0 +1,237 @@ +package clusters + +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", "locationName") + + 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 != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Kusto/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Kusto", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Kusto/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Kusto/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Kusto/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Kusto", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kUsTo", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Kusto/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kUsTo/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Kusto/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Kusto/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kUsTo/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kUsTo/lOcAtIoNs/lOcAtIoNnAmE/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/kusto/2024-04-13/clusters/method_addcalloutpolicies.go b/resource-manager/kusto/2024-04-13/clusters/method_addcalloutpolicies.go new file mode 100644 index 00000000000..dc153913481 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/method_addcalloutpolicies.go @@ -0,0 +1,75 @@ +package clusters + +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 AddCalloutPoliciesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// AddCalloutPolicies ... +func (c ClustersClient) AddCalloutPolicies(ctx context.Context, id commonids.KustoClusterId, input CalloutPoliciesList) (result AddCalloutPoliciesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/addCalloutPolicies", 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 +} + +// AddCalloutPoliciesThenPoll performs AddCalloutPolicies then polls until it's completed +func (c ClustersClient) AddCalloutPoliciesThenPoll(ctx context.Context, id commonids.KustoClusterId, input CalloutPoliciesList) error { + result, err := c.AddCalloutPolicies(ctx, id, input) + if err != nil { + return fmt.Errorf("performing AddCalloutPolicies: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AddCalloutPolicies: %+v", err) + } + + return nil +} diff --git a/resource-manager/kusto/2024-04-13/clusters/method_addlanguageextensions.go b/resource-manager/kusto/2024-04-13/clusters/method_addlanguageextensions.go new file mode 100644 index 00000000000..16a1d90b331 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/method_addlanguageextensions.go @@ -0,0 +1,75 @@ +package clusters + +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 AddLanguageExtensionsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// AddLanguageExtensions ... +func (c ClustersClient) AddLanguageExtensions(ctx context.Context, id commonids.KustoClusterId, input LanguageExtensionsList) (result AddLanguageExtensionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/addLanguageExtensions", 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 +} + +// AddLanguageExtensionsThenPoll performs AddLanguageExtensions then polls until it's completed +func (c ClustersClient) AddLanguageExtensionsThenPoll(ctx context.Context, id commonids.KustoClusterId, input LanguageExtensionsList) error { + result, err := c.AddLanguageExtensions(ctx, id, input) + if err != nil { + return fmt.Errorf("performing AddLanguageExtensions: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AddLanguageExtensions: %+v", err) + } + + return nil +} diff --git a/resource-manager/kusto/2024-04-13/clusters/method_checknameavailability.go b/resource-manager/kusto/2024-04-13/clusters/method_checknameavailability.go new file mode 100644 index 00000000000..45fd64789ac --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/method_checknameavailability.go @@ -0,0 +1,58 @@ +package clusters + +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 CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameResult +} + +// CheckNameAvailability ... +func (c ClustersClient) CheckNameAvailability(ctx context.Context, id LocationId, input ClusterCheckNameRequest) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkNameAvailability", 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 CheckNameResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/clusters/method_createorupdate.go b/resource-manager/kusto/2024-04-13/clusters/method_createorupdate.go new file mode 100644 index 00000000000..06b54dfc102 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/method_createorupdate.go @@ -0,0 +1,109 @@ +package clusters + +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 *Cluster +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string + IfNoneMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + if o.IfNoneMatch != nil { + out.Append("If-None-Match", fmt.Sprintf("%v", *o.IfNoneMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ClustersClient) CreateOrUpdate(ctx context.Context, id commonids.KustoClusterId, input Cluster, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + 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 ClustersClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.KustoClusterId, input Cluster, options CreateOrUpdateOperationOptions) error { + result, err := c.CreateOrUpdate(ctx, id, input, options) + 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/kusto/2024-04-13/clusters/method_delete.go b/resource-manager/kusto/2024-04-13/clusters/method_delete.go new file mode 100644 index 00000000000..8db1e23a2e2 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/method_delete.go @@ -0,0 +1,72 @@ +package clusters + +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 ClustersClient) Delete(ctx context.Context, id commonids.KustoClusterId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ClustersClient) DeleteThenPoll(ctx context.Context, id commonids.KustoClusterId) 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/kusto/2024-04-13/clusters/method_detachfollowerdatabases.go b/resource-manager/kusto/2024-04-13/clusters/method_detachfollowerdatabases.go new file mode 100644 index 00000000000..694536c1c72 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/method_detachfollowerdatabases.go @@ -0,0 +1,75 @@ +package clusters + +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 DetachFollowerDatabasesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DetachFollowerDatabases ... +func (c ClustersClient) DetachFollowerDatabases(ctx context.Context, id commonids.KustoClusterId, input FollowerDatabaseDefinition) (result DetachFollowerDatabasesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/detachFollowerDatabases", 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 +} + +// DetachFollowerDatabasesThenPoll performs DetachFollowerDatabases then polls until it's completed +func (c ClustersClient) DetachFollowerDatabasesThenPoll(ctx context.Context, id commonids.KustoClusterId, input FollowerDatabaseDefinition) error { + result, err := c.DetachFollowerDatabases(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DetachFollowerDatabases: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DetachFollowerDatabases: %+v", err) + } + + return nil +} diff --git a/resource-manager/kusto/2024-04-13/clusters/method_diagnosevirtualnetwork.go b/resource-manager/kusto/2024-04-13/clusters/method_diagnosevirtualnetwork.go new file mode 100644 index 00000000000..8d6aafd1a51 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/method_diagnosevirtualnetwork.go @@ -0,0 +1,72 @@ +package clusters + +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 DiagnoseVirtualNetworkOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DiagnoseVirtualNetworkResult +} + +// DiagnoseVirtualNetwork ... +func (c ClustersClient) DiagnoseVirtualNetwork(ctx context.Context, id commonids.KustoClusterId) (result DiagnoseVirtualNetworkOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/diagnoseVirtualNetwork", 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 +} + +// DiagnoseVirtualNetworkThenPoll performs DiagnoseVirtualNetwork then polls until it's completed +func (c ClustersClient) DiagnoseVirtualNetworkThenPoll(ctx context.Context, id commonids.KustoClusterId) error { + result, err := c.DiagnoseVirtualNetwork(ctx, id) + if err != nil { + return fmt.Errorf("performing DiagnoseVirtualNetwork: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DiagnoseVirtualNetwork: %+v", err) + } + + return nil +} diff --git a/resource-manager/kusto/2024-04-13/clusters/method_get.go b/resource-manager/kusto/2024-04-13/clusters/method_get.go new file mode 100644 index 00000000000..40382e83f4b --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/method_get.go @@ -0,0 +1,54 @@ +package clusters + +import ( + "context" + "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 *Cluster +} + +// Get ... +func (c ClustersClient) Get(ctx context.Context, id commonids.KustoClusterId) (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 Cluster + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/clusters/method_list.go b/resource-manager/kusto/2024-04-13/clusters/method_list.go new file mode 100644 index 00000000000..82c843af942 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/method_list.go @@ -0,0 +1,55 @@ +package clusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ClusterListResult +} + +// List ... +func (c ClustersClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Kusto/clusters", 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 ClusterListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/clusters/method_listbyresourcegroup.go b/resource-manager/kusto/2024-04-13/clusters/method_listbyresourcegroup.go new file mode 100644 index 00000000000..776c57c3480 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/method_listbyresourcegroup.go @@ -0,0 +1,55 @@ +package clusters + +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 *ClusterListResult +} + +// ListByResourceGroup ... +func (c ClustersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Kusto/clusters", 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 ClusterListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/clusters/method_listcalloutpolicies.go b/resource-manager/kusto/2024-04-13/clusters/method_listcalloutpolicies.go new file mode 100644 index 00000000000..a36b6e62a5d --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/method_listcalloutpolicies.go @@ -0,0 +1,106 @@ +package clusters + +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 ListCalloutPoliciesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CalloutPolicy +} + +type ListCalloutPoliciesCompleteResult struct { + LatestHttpResponse *http.Response + Items []CalloutPolicy +} + +type ListCalloutPoliciesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCalloutPoliciesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListCalloutPolicies ... +func (c ClustersClient) ListCalloutPolicies(ctx context.Context, id commonids.KustoClusterId) (result ListCalloutPoliciesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListCalloutPoliciesCustomPager{}, + Path: fmt.Sprintf("%s/listCalloutPolicies", 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 *[]CalloutPolicy `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListCalloutPoliciesComplete retrieves all the results into a single object +func (c ClustersClient) ListCalloutPoliciesComplete(ctx context.Context, id commonids.KustoClusterId) (ListCalloutPoliciesCompleteResult, error) { + return c.ListCalloutPoliciesCompleteMatchingPredicate(ctx, id, CalloutPolicyOperationPredicate{}) +} + +// ListCalloutPoliciesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ClustersClient) ListCalloutPoliciesCompleteMatchingPredicate(ctx context.Context, id commonids.KustoClusterId, predicate CalloutPolicyOperationPredicate) (result ListCalloutPoliciesCompleteResult, err error) { + items := make([]CalloutPolicy, 0) + + resp, err := c.ListCalloutPolicies(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 = ListCalloutPoliciesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/kusto/2024-04-13/clusters/method_listfollowerdatabases.go b/resource-manager/kusto/2024-04-13/clusters/method_listfollowerdatabases.go new file mode 100644 index 00000000000..15f64c75c2a --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/method_listfollowerdatabases.go @@ -0,0 +1,55 @@ +package clusters + +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 ListFollowerDatabasesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FollowerDatabaseListResult +} + +// ListFollowerDatabases ... +func (c ClustersClient) ListFollowerDatabases(ctx context.Context, id commonids.KustoClusterId) (result ListFollowerDatabasesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listFollowerDatabases", 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 FollowerDatabaseListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/clusters/method_listfollowerdatabasesget.go b/resource-manager/kusto/2024-04-13/clusters/method_listfollowerdatabasesget.go new file mode 100644 index 00000000000..41a1aae8fb4 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/method_listfollowerdatabasesget.go @@ -0,0 +1,106 @@ +package clusters + +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 ListFollowerDatabasesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FollowerDatabaseDefinitionGet +} + +type ListFollowerDatabasesGetCompleteResult struct { + LatestHttpResponse *http.Response + Items []FollowerDatabaseDefinitionGet +} + +type ListFollowerDatabasesGetCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListFollowerDatabasesGetCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListFollowerDatabasesGet ... +func (c ClustersClient) ListFollowerDatabasesGet(ctx context.Context, id commonids.KustoClusterId) (result ListFollowerDatabasesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListFollowerDatabasesGetCustomPager{}, + Path: fmt.Sprintf("%s/listFollowerDatabases", 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 *[]FollowerDatabaseDefinitionGet `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListFollowerDatabasesGetComplete retrieves all the results into a single object +func (c ClustersClient) ListFollowerDatabasesGetComplete(ctx context.Context, id commonids.KustoClusterId) (ListFollowerDatabasesGetCompleteResult, error) { + return c.ListFollowerDatabasesGetCompleteMatchingPredicate(ctx, id, FollowerDatabaseDefinitionGetOperationPredicate{}) +} + +// ListFollowerDatabasesGetCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ClustersClient) ListFollowerDatabasesGetCompleteMatchingPredicate(ctx context.Context, id commonids.KustoClusterId, predicate FollowerDatabaseDefinitionGetOperationPredicate) (result ListFollowerDatabasesGetCompleteResult, err error) { + items := make([]FollowerDatabaseDefinitionGet, 0) + + resp, err := c.ListFollowerDatabasesGet(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 = ListFollowerDatabasesGetCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/kusto/2024-04-13/clusters/method_listlanguageextensions.go b/resource-manager/kusto/2024-04-13/clusters/method_listlanguageextensions.go new file mode 100644 index 00000000000..c5af35d2b3e --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/method_listlanguageextensions.go @@ -0,0 +1,55 @@ +package clusters + +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 ListLanguageExtensionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LanguageExtensionsList +} + +// ListLanguageExtensions ... +func (c ClustersClient) ListLanguageExtensions(ctx context.Context, id commonids.KustoClusterId) (result ListLanguageExtensionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listLanguageExtensions", 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 LanguageExtensionsList + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/clusters/method_listskusbyresource.go b/resource-manager/kusto/2024-04-13/clusters/method_listskusbyresource.go new file mode 100644 index 00000000000..19a17796d87 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/method_listskusbyresource.go @@ -0,0 +1,55 @@ +package clusters + +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 ListSkusByResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ListResourceSkusResult +} + +// ListSkusByResource ... +func (c ClustersClient) ListSkusByResource(ctx context.Context, id commonids.KustoClusterId) (result ListSkusByResourceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/skus", 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 ListResourceSkusResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/clusters/method_migrate.go b/resource-manager/kusto/2024-04-13/clusters/method_migrate.go new file mode 100644 index 00000000000..017d5478b6f --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/method_migrate.go @@ -0,0 +1,75 @@ +package clusters + +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 MigrateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Migrate ... +func (c ClustersClient) Migrate(ctx context.Context, id commonids.KustoClusterId, input ClusterMigrateRequest) (result MigrateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/migrate", 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 +} + +// MigrateThenPoll performs Migrate then polls until it's completed +func (c ClustersClient) MigrateThenPoll(ctx context.Context, id commonids.KustoClusterId, input ClusterMigrateRequest) error { + result, err := c.Migrate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Migrate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Migrate: %+v", err) + } + + return nil +} diff --git a/resource-manager/kusto/2024-04-13/clusters/method_removecalloutpolicy.go b/resource-manager/kusto/2024-04-13/clusters/method_removecalloutpolicy.go new file mode 100644 index 00000000000..d4610244794 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/method_removecalloutpolicy.go @@ -0,0 +1,75 @@ +package clusters + +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 RemoveCalloutPolicyOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RemoveCalloutPolicy ... +func (c ClustersClient) RemoveCalloutPolicy(ctx context.Context, id commonids.KustoClusterId, input CalloutPolicyToRemove) (result RemoveCalloutPolicyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/removeCalloutPolicy", 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 +} + +// RemoveCalloutPolicyThenPoll performs RemoveCalloutPolicy then polls until it's completed +func (c ClustersClient) RemoveCalloutPolicyThenPoll(ctx context.Context, id commonids.KustoClusterId, input CalloutPolicyToRemove) error { + result, err := c.RemoveCalloutPolicy(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RemoveCalloutPolicy: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RemoveCalloutPolicy: %+v", err) + } + + return nil +} diff --git a/resource-manager/kusto/2024-04-13/clusters/method_removelanguageextensions.go b/resource-manager/kusto/2024-04-13/clusters/method_removelanguageextensions.go new file mode 100644 index 00000000000..b4168106014 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/method_removelanguageextensions.go @@ -0,0 +1,75 @@ +package clusters + +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 RemoveLanguageExtensionsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RemoveLanguageExtensions ... +func (c ClustersClient) RemoveLanguageExtensions(ctx context.Context, id commonids.KustoClusterId, input LanguageExtensionsList) (result RemoveLanguageExtensionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/removeLanguageExtensions", 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 +} + +// RemoveLanguageExtensionsThenPoll performs RemoveLanguageExtensions then polls until it's completed +func (c ClustersClient) RemoveLanguageExtensionsThenPoll(ctx context.Context, id commonids.KustoClusterId, input LanguageExtensionsList) error { + result, err := c.RemoveLanguageExtensions(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RemoveLanguageExtensions: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RemoveLanguageExtensions: %+v", err) + } + + return nil +} diff --git a/resource-manager/kusto/2024-04-13/clusters/method_start.go b/resource-manager/kusto/2024-04-13/clusters/method_start.go new file mode 100644 index 00000000000..39f1b91f2c7 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/method_start.go @@ -0,0 +1,71 @@ +package clusters + +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 StartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Start ... +func (c ClustersClient) Start(ctx context.Context, id commonids.KustoClusterId) (result StartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StartThenPoll performs Start then polls until it's completed +func (c ClustersClient) StartThenPoll(ctx context.Context, id commonids.KustoClusterId) error { + result, err := c.Start(ctx, id) + if err != nil { + return fmt.Errorf("performing Start: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Start: %+v", err) + } + + return nil +} diff --git a/resource-manager/kusto/2024-04-13/clusters/method_stop.go b/resource-manager/kusto/2024-04-13/clusters/method_stop.go new file mode 100644 index 00000000000..cb528e3b82c --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/method_stop.go @@ -0,0 +1,71 @@ +package clusters + +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 StopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Stop ... +func (c ClustersClient) Stop(ctx context.Context, id commonids.KustoClusterId) (result StopOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StopThenPoll performs Stop then polls until it's completed +func (c ClustersClient) StopThenPoll(ctx context.Context, id commonids.KustoClusterId) error { + result, err := c.Stop(ctx, id) + if err != nil { + return fmt.Errorf("performing Stop: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Stop: %+v", err) + } + + return nil +} diff --git a/resource-manager/kusto/2024-04-13/clusters/method_update.go b/resource-manager/kusto/2024-04-13/clusters/method_update.go new file mode 100644 index 00000000000..984e1dcb321 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/method_update.go @@ -0,0 +1,106 @@ +package clusters + +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 *Cluster +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c ClustersClient) Update(ctx context.Context, id commonids.KustoClusterId, input ClusterUpdate, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + OptionsObject: options, + 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 ClustersClient) UpdateThenPoll(ctx context.Context, id commonids.KustoClusterId, input ClusterUpdate, options UpdateOperationOptions) error { + result, err := c.Update(ctx, id, input, options) + 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/kusto/2024-04-13/clusters/model_acceptedaudiences.go b/resource-manager/kusto/2024-04-13/clusters/model_acceptedaudiences.go new file mode 100644 index 00000000000..380c1812f40 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_acceptedaudiences.go @@ -0,0 +1,8 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AcceptedAudiences struct { + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_azurecapacity.go b/resource-manager/kusto/2024-04-13/clusters/model_azurecapacity.go new file mode 100644 index 00000000000..45346d20b10 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_azurecapacity.go @@ -0,0 +1,11 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureCapacity struct { + Default int64 `json:"default"` + Maximum int64 `json:"maximum"` + Minimum int64 `json:"minimum"` + ScaleType AzureScaleType `json:"scaleType"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_azureresourcesku.go b/resource-manager/kusto/2024-04-13/clusters/model_azureresourcesku.go new file mode 100644 index 00000000000..502d4ff7bef --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_azureresourcesku.go @@ -0,0 +1,10 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureResourceSku struct { + Capacity *AzureCapacity `json:"capacity,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + Sku *AzureSku `json:"sku,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_azuresku.go b/resource-manager/kusto/2024-04-13/clusters/model_azuresku.go new file mode 100644 index 00000000000..ec5553a4bd4 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_azuresku.go @@ -0,0 +1,10 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureSku struct { + Capacity *int64 `json:"capacity,omitempty"` + Name AzureSkuName `json:"name"` + Tier AzureSkuTier `json:"tier"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_calloutpolicieslist.go b/resource-manager/kusto/2024-04-13/clusters/model_calloutpolicieslist.go new file mode 100644 index 00000000000..b97a0dff8a2 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_calloutpolicieslist.go @@ -0,0 +1,9 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CalloutPoliciesList struct { + NextLink *string `json:"nextLink,omitempty"` + Value *[]CalloutPolicy `json:"value,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_calloutpolicy.go b/resource-manager/kusto/2024-04-13/clusters/model_calloutpolicy.go new file mode 100644 index 00000000000..80d3457a34c --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_calloutpolicy.go @@ -0,0 +1,11 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CalloutPolicy struct { + CalloutId *string `json:"calloutId,omitempty"` + CalloutType *CalloutType `json:"calloutType,omitempty"` + CalloutUriRegex *string `json:"calloutUriRegex,omitempty"` + OutboundAccess *OutboundAccess `json:"outboundAccess,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_calloutpolicytoremove.go b/resource-manager/kusto/2024-04-13/clusters/model_calloutpolicytoremove.go new file mode 100644 index 00000000000..960b9a86294 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_calloutpolicytoremove.go @@ -0,0 +1,8 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CalloutPolicyToRemove struct { + CalloutId *string `json:"calloutId,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_checknameresult.go b/resource-manager/kusto/2024-04-13/clusters/model_checknameresult.go new file mode 100644 index 00000000000..a8e7037cce2 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_checknameresult.go @@ -0,0 +1,11 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameResult struct { + Message *string `json:"message,omitempty"` + Name *string `json:"name,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *Reason `json:"reason,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_cluster.go b/resource-manager/kusto/2024-04-13/clusters/model_cluster.go new file mode 100644 index 00000000000..a214c6249de --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_cluster.go @@ -0,0 +1,24 @@ +package clusters + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Cluster struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ClusterProperties `json:"properties,omitempty"` + Sku AzureSku `json:"sku"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_clusterchecknamerequest.go b/resource-manager/kusto/2024-04-13/clusters/model_clusterchecknamerequest.go new file mode 100644 index 00000000000..2c588e8314d --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_clusterchecknamerequest.go @@ -0,0 +1,9 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterCheckNameRequest struct { + Name string `json:"name"` + Type ClusterType `json:"type"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_clusterlistresult.go b/resource-manager/kusto/2024-04-13/clusters/model_clusterlistresult.go new file mode 100644 index 00000000000..b556dcab107 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_clusterlistresult.go @@ -0,0 +1,8 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterListResult struct { + Value *[]Cluster `json:"value,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_clustermigraterequest.go b/resource-manager/kusto/2024-04-13/clusters/model_clustermigraterequest.go new file mode 100644 index 00000000000..4db4e0a9820 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_clustermigraterequest.go @@ -0,0 +1,8 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterMigrateRequest struct { + ClusterResourceId string `json:"clusterResourceId"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_clusterproperties.go b/resource-manager/kusto/2024-04-13/clusters/model_clusterproperties.go new file mode 100644 index 00000000000..c16564f836f --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_clusterproperties.go @@ -0,0 +1,34 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterProperties struct { + AcceptedAudiences *[]AcceptedAudiences `json:"acceptedAudiences,omitempty"` + AllowedFqdnList *[]string `json:"allowedFqdnList,omitempty"` + AllowedIPRangeList *[]string `json:"allowedIpRangeList,omitempty"` + CalloutPolicies *[]CalloutPolicy `json:"calloutPolicies,omitempty"` + DataIngestionUri *string `json:"dataIngestionUri,omitempty"` + EnableAutoStop *bool `json:"enableAutoStop,omitempty"` + EnableDiskEncryption *bool `json:"enableDiskEncryption,omitempty"` + EnableDoubleEncryption *bool `json:"enableDoubleEncryption,omitempty"` + EnablePurge *bool `json:"enablePurge,omitempty"` + EnableStreamingIngest *bool `json:"enableStreamingIngest,omitempty"` + EngineType *EngineType `json:"engineType,omitempty"` + KeyVaultProperties *KeyVaultProperties `json:"keyVaultProperties,omitempty"` + LanguageExtensions *LanguageExtensionsList `json:"languageExtensions,omitempty"` + MigrationCluster *MigrationClusterProperties `json:"migrationCluster,omitempty"` + OptimizedAutoscale *OptimizedAutoscale `json:"optimizedAutoscale,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPType *PublicIPType `json:"publicIPType,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + RestrictOutboundNetworkAccess *ClusterNetworkAccessFlag `json:"restrictOutboundNetworkAccess,omitempty"` + State *State `json:"state,omitempty"` + StateReason *string `json:"stateReason,omitempty"` + TrustedExternalTenants *[]TrustedExternalTenant `json:"trustedExternalTenants,omitempty"` + Uri *string `json:"uri,omitempty"` + VirtualClusterGraduationProperties *string `json:"virtualClusterGraduationProperties,omitempty"` + VirtualNetworkConfiguration *VirtualNetworkConfiguration `json:"virtualNetworkConfiguration,omitempty"` + ZoneStatus *ZoneStatus `json:"zoneStatus,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_clusterupdate.go b/resource-manager/kusto/2024-04-13/clusters/model_clusterupdate.go new file mode 100644 index 00000000000..009d8019689 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_clusterupdate.go @@ -0,0 +1,21 @@ +package clusters + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "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 ClusterUpdate struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ClusterProperties `json:"properties,omitempty"` + Sku *AzureSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_diagnosevirtualnetworkresult.go b/resource-manager/kusto/2024-04-13/clusters/model_diagnosevirtualnetworkresult.go new file mode 100644 index 00000000000..8cbb2a10118 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_diagnosevirtualnetworkresult.go @@ -0,0 +1,8 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnoseVirtualNetworkResult struct { + Findings *[]string `json:"findings,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_followerdatabasedefinition.go b/resource-manager/kusto/2024-04-13/clusters/model_followerdatabasedefinition.go new file mode 100644 index 00000000000..59b0a5646a8 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_followerdatabasedefinition.go @@ -0,0 +1,12 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FollowerDatabaseDefinition struct { + AttachedDatabaseConfigurationName string `json:"attachedDatabaseConfigurationName"` + ClusterResourceId string `json:"clusterResourceId"` + DatabaseName *string `json:"databaseName,omitempty"` + DatabaseShareOrigin *DatabaseShareOrigin `json:"databaseShareOrigin,omitempty"` + TableLevelSharingProperties *TableLevelSharingProperties `json:"tableLevelSharingProperties,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_followerdatabasedefinitionget.go b/resource-manager/kusto/2024-04-13/clusters/model_followerdatabasedefinitionget.go new file mode 100644 index 00000000000..e584b9d4bbe --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_followerdatabasedefinitionget.go @@ -0,0 +1,8 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FollowerDatabaseDefinitionGet struct { + Properties *FollowerDatabaseProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_followerdatabaselistresult.go b/resource-manager/kusto/2024-04-13/clusters/model_followerdatabaselistresult.go new file mode 100644 index 00000000000..21440cb4c91 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_followerdatabaselistresult.go @@ -0,0 +1,8 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FollowerDatabaseListResult struct { + Value *[]FollowerDatabaseDefinition `json:"value,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_followerdatabaseproperties.go b/resource-manager/kusto/2024-04-13/clusters/model_followerdatabaseproperties.go new file mode 100644 index 00000000000..62097c53395 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_followerdatabaseproperties.go @@ -0,0 +1,12 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FollowerDatabaseProperties struct { + AttachedDatabaseConfigurationName string `json:"attachedDatabaseConfigurationName"` + ClusterResourceId string `json:"clusterResourceId"` + DatabaseName *string `json:"databaseName,omitempty"` + DatabaseShareOrigin *DatabaseShareOrigin `json:"databaseShareOrigin,omitempty"` + TableLevelSharingProperties *TableLevelSharingProperties `json:"tableLevelSharingProperties,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_keyvaultproperties.go b/resource-manager/kusto/2024-04-13/clusters/model_keyvaultproperties.go new file mode 100644 index 00000000000..1585ac05771 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_keyvaultproperties.go @@ -0,0 +1,11 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultProperties struct { + KeyName *string `json:"keyName,omitempty"` + KeyVaultUri *string `json:"keyVaultUri,omitempty"` + KeyVersion *string `json:"keyVersion,omitempty"` + UserIdentity *string `json:"userIdentity,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_languageextension.go b/resource-manager/kusto/2024-04-13/clusters/model_languageextension.go new file mode 100644 index 00000000000..feb4434e396 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_languageextension.go @@ -0,0 +1,10 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LanguageExtension struct { + LanguageExtensionCustomImageName *string `json:"languageExtensionCustomImageName,omitempty"` + LanguageExtensionImageName *LanguageExtensionImageName `json:"languageExtensionImageName,omitempty"` + LanguageExtensionName *LanguageExtensionName `json:"languageExtensionName,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_languageextensionslist.go b/resource-manager/kusto/2024-04-13/clusters/model_languageextensionslist.go new file mode 100644 index 00000000000..be274ec2cf0 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_languageextensionslist.go @@ -0,0 +1,8 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LanguageExtensionsList struct { + Value *[]LanguageExtension `json:"value,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_listresourceskusresult.go b/resource-manager/kusto/2024-04-13/clusters/model_listresourceskusresult.go new file mode 100644 index 00000000000..2cf5909b9d5 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_listresourceskusresult.go @@ -0,0 +1,8 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListResourceSkusResult struct { + Value *[]AzureResourceSku `json:"value,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_migrationclusterproperties.go b/resource-manager/kusto/2024-04-13/clusters/model_migrationclusterproperties.go new file mode 100644 index 00000000000..34d6f787e71 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_migrationclusterproperties.go @@ -0,0 +1,11 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationClusterProperties struct { + DataIngestionUri *string `json:"dataIngestionUri,omitempty"` + Id *string `json:"id,omitempty"` + Role *MigrationClusterRole `json:"role,omitempty"` + Uri *string `json:"uri,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_optimizedautoscale.go b/resource-manager/kusto/2024-04-13/clusters/model_optimizedautoscale.go new file mode 100644 index 00000000000..341a3138481 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_optimizedautoscale.go @@ -0,0 +1,11 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OptimizedAutoscale struct { + IsEnabled bool `json:"isEnabled"` + Maximum int64 `json:"maximum"` + Minimum int64 `json:"minimum"` + Version int64 `json:"version"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_privateendpointconnection.go b/resource-manager/kusto/2024-04-13/clusters/model_privateendpointconnection.go new file mode 100644 index 00000000000..87e04718600 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_privateendpointconnection.go @@ -0,0 +1,16 @@ +package clusters + +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 PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_privateendpointconnectionproperties.go b/resource-manager/kusto/2024-04-13/clusters/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..3c959462977 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupId *string `json:"groupId,omitempty"` + PrivateEndpoint *PrivateEndpointProperty `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionStateProperty `json:"privateLinkServiceConnectionState"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_privateendpointproperty.go b/resource-manager/kusto/2024-04-13/clusters/model_privateendpointproperty.go new file mode 100644 index 00000000000..5da9b341454 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_privateendpointproperty.go @@ -0,0 +1,8 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperty struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_privatelinkserviceconnectionstateproperty.go b/resource-manager/kusto/2024-04-13/clusters/model_privatelinkserviceconnectionstateproperty.go new file mode 100644 index 00000000000..e4b57994628 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_privatelinkserviceconnectionstateproperty.go @@ -0,0 +1,10 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionStateProperty struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_tablelevelsharingproperties.go b/resource-manager/kusto/2024-04-13/clusters/model_tablelevelsharingproperties.go new file mode 100644 index 00000000000..34b322b02dc --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_tablelevelsharingproperties.go @@ -0,0 +1,15 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TableLevelSharingProperties struct { + ExternalTablesToExclude *[]string `json:"externalTablesToExclude,omitempty"` + ExternalTablesToInclude *[]string `json:"externalTablesToInclude,omitempty"` + FunctionsToExclude *[]string `json:"functionsToExclude,omitempty"` + FunctionsToInclude *[]string `json:"functionsToInclude,omitempty"` + MaterializedViewsToExclude *[]string `json:"materializedViewsToExclude,omitempty"` + MaterializedViewsToInclude *[]string `json:"materializedViewsToInclude,omitempty"` + TablesToExclude *[]string `json:"tablesToExclude,omitempty"` + TablesToInclude *[]string `json:"tablesToInclude,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_trustedexternaltenant.go b/resource-manager/kusto/2024-04-13/clusters/model_trustedexternaltenant.go new file mode 100644 index 00000000000..e589152aa78 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_trustedexternaltenant.go @@ -0,0 +1,8 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrustedExternalTenant struct { + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/model_virtualnetworkconfiguration.go b/resource-manager/kusto/2024-04-13/clusters/model_virtualnetworkconfiguration.go new file mode 100644 index 00000000000..45ef97e0641 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/model_virtualnetworkconfiguration.go @@ -0,0 +1,11 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkConfiguration struct { + DataManagementPublicIPId string `json:"dataManagementPublicIpId"` + EnginePublicIPId string `json:"enginePublicIpId"` + State *VnetState `json:"state,omitempty"` + SubnetId string `json:"subnetId"` +} diff --git a/resource-manager/kusto/2024-04-13/clusters/predicates.go b/resource-manager/kusto/2024-04-13/clusters/predicates.go new file mode 100644 index 00000000000..738a73be392 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/predicates.go @@ -0,0 +1,30 @@ +package clusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CalloutPolicyOperationPredicate struct { + CalloutId *string + CalloutUriRegex *string +} + +func (p CalloutPolicyOperationPredicate) Matches(input CalloutPolicy) bool { + + if p.CalloutId != nil && (input.CalloutId == nil || *p.CalloutId != *input.CalloutId) { + return false + } + + if p.CalloutUriRegex != nil && (input.CalloutUriRegex == nil || *p.CalloutUriRegex != *input.CalloutUriRegex) { + return false + } + + return true +} + +type FollowerDatabaseDefinitionGetOperationPredicate struct { +} + +func (p FollowerDatabaseDefinitionGetOperationPredicate) Matches(input FollowerDatabaseDefinitionGet) bool { + + return true +} diff --git a/resource-manager/kusto/2024-04-13/clusters/version.go b/resource-manager/kusto/2024-04-13/clusters/version.go new file mode 100644 index 00000000000..aad3620dc2c --- /dev/null +++ b/resource-manager/kusto/2024-04-13/clusters/version.go @@ -0,0 +1,10 @@ +package clusters + +// 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-04-13" + +func userAgent() string { + return "hashicorp/go-azure-sdk/clusters/2024-04-13" +} diff --git a/resource-manager/kusto/2024-04-13/databaseprincipalassignments/README.md b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/README.md new file mode 100644 index 00000000000..6e48d42a9a9 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/README.md @@ -0,0 +1,103 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/databaseprincipalassignments` Documentation + +The `databaseprincipalassignments` SDK allows for interaction with Azure Resource Manager `kusto` (API Version `2024-04-13`). + +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/kusto/2024-04-13/databaseprincipalassignments" +``` + + +### Client Initialization + +```go +client := databaseprincipalassignments.NewDatabasePrincipalAssignmentsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DatabasePrincipalAssignmentsClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := commonids.NewKustoDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName") + +payload := databaseprincipalassignments.DatabasePrincipalAssignmentCheckNameRequest{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DatabasePrincipalAssignmentsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := databaseprincipalassignments.NewDatabasePrincipalAssignmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName", "principalAssignmentName") + +payload := databaseprincipalassignments.DatabasePrincipalAssignment{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DatabasePrincipalAssignmentsClient.Delete` + +```go +ctx := context.TODO() +id := databaseprincipalassignments.NewDatabasePrincipalAssignmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName", "principalAssignmentName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `DatabasePrincipalAssignmentsClient.Get` + +```go +ctx := context.TODO() +id := databaseprincipalassignments.NewDatabasePrincipalAssignmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName", "principalAssignmentName") + +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: `DatabasePrincipalAssignmentsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewKustoDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName") + +read, err := client.List(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/kusto/2024-04-13/databaseprincipalassignments/client.go b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/client.go new file mode 100644 index 00000000000..937513d7036 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/client.go @@ -0,0 +1,26 @@ +package databaseprincipalassignments + +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 DatabasePrincipalAssignmentsClient struct { + Client *resourcemanager.Client +} + +func NewDatabasePrincipalAssignmentsClientWithBaseURI(sdkApi sdkEnv.Api) (*DatabasePrincipalAssignmentsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "databaseprincipalassignments", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DatabasePrincipalAssignmentsClient: %+v", err) + } + + return &DatabasePrincipalAssignmentsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/kusto/2024-04-13/databaseprincipalassignments/constants.go b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/constants.go new file mode 100644 index 00000000000..d225e34ae78 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/constants.go @@ -0,0 +1,242 @@ +package databaseprincipalassignments + +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 DatabasePrincipalAssignmentType string + +const ( + DatabasePrincipalAssignmentTypeMicrosoftPointKustoClustersDatabasesPrincipalAssignments DatabasePrincipalAssignmentType = "Microsoft.Kusto/clusters/databases/principalAssignments" +) + +func PossibleValuesForDatabasePrincipalAssignmentType() []string { + return []string{ + string(DatabasePrincipalAssignmentTypeMicrosoftPointKustoClustersDatabasesPrincipalAssignments), + } +} + +func (s *DatabasePrincipalAssignmentType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDatabasePrincipalAssignmentType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDatabasePrincipalAssignmentType(input string) (*DatabasePrincipalAssignmentType, error) { + vals := map[string]DatabasePrincipalAssignmentType{ + "microsoft.kusto/clusters/databases/principalassignments": DatabasePrincipalAssignmentTypeMicrosoftPointKustoClustersDatabasesPrincipalAssignments, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DatabasePrincipalAssignmentType(input) + return &out, nil +} + +type DatabasePrincipalRole string + +const ( + DatabasePrincipalRoleAdmin DatabasePrincipalRole = "Admin" + DatabasePrincipalRoleIngestor DatabasePrincipalRole = "Ingestor" + DatabasePrincipalRoleMonitor DatabasePrincipalRole = "Monitor" + DatabasePrincipalRoleUnrestrictedViewer DatabasePrincipalRole = "UnrestrictedViewer" + DatabasePrincipalRoleUser DatabasePrincipalRole = "User" + DatabasePrincipalRoleViewer DatabasePrincipalRole = "Viewer" +) + +func PossibleValuesForDatabasePrincipalRole() []string { + return []string{ + string(DatabasePrincipalRoleAdmin), + string(DatabasePrincipalRoleIngestor), + string(DatabasePrincipalRoleMonitor), + string(DatabasePrincipalRoleUnrestrictedViewer), + string(DatabasePrincipalRoleUser), + string(DatabasePrincipalRoleViewer), + } +} + +func (s *DatabasePrincipalRole) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDatabasePrincipalRole(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDatabasePrincipalRole(input string) (*DatabasePrincipalRole, error) { + vals := map[string]DatabasePrincipalRole{ + "admin": DatabasePrincipalRoleAdmin, + "ingestor": DatabasePrincipalRoleIngestor, + "monitor": DatabasePrincipalRoleMonitor, + "unrestrictedviewer": DatabasePrincipalRoleUnrestrictedViewer, + "user": DatabasePrincipalRoleUser, + "viewer": DatabasePrincipalRoleViewer, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DatabasePrincipalRole(input) + return &out, nil +} + +type PrincipalType string + +const ( + PrincipalTypeApp PrincipalType = "App" + PrincipalTypeGroup PrincipalType = "Group" + PrincipalTypeUser PrincipalType = "User" +) + +func PossibleValuesForPrincipalType() []string { + return []string{ + string(PrincipalTypeApp), + string(PrincipalTypeGroup), + string(PrincipalTypeUser), + } +} + +func (s *PrincipalType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrincipalType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrincipalType(input string) (*PrincipalType, error) { + vals := map[string]PrincipalType{ + "app": PrincipalTypeApp, + "group": PrincipalTypeGroup, + "user": PrincipalTypeUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrincipalType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateMoving ProvisioningState = "Moving" + ProvisioningStateRunning ProvisioningState = "Running" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateMoving), + string(ProvisioningStateRunning), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "moving": ProvisioningStateMoving, + "running": ProvisioningStateRunning, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type Reason string + +const ( + ReasonAlreadyExists Reason = "AlreadyExists" + ReasonInvalid Reason = "Invalid" +) + +func PossibleValuesForReason() []string { + return []string{ + string(ReasonAlreadyExists), + string(ReasonInvalid), + } +} + +func (s *Reason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReason(input string) (*Reason, error) { + vals := map[string]Reason{ + "alreadyexists": ReasonAlreadyExists, + "invalid": ReasonInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Reason(input) + return &out, nil +} diff --git a/resource-manager/kusto/2024-04-13/databaseprincipalassignments/id_databaseprincipalassignment.go b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/id_databaseprincipalassignment.go new file mode 100644 index 00000000000..bc6f5bd0030 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/id_databaseprincipalassignment.go @@ -0,0 +1,148 @@ +package databaseprincipalassignments + +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(&DatabasePrincipalAssignmentId{}) +} + +var _ resourceids.ResourceId = &DatabasePrincipalAssignmentId{} + +// DatabasePrincipalAssignmentId is a struct representing the Resource ID for a Database Principal Assignment +type DatabasePrincipalAssignmentId struct { + SubscriptionId string + ResourceGroupName string + ClusterName string + DatabaseName string + PrincipalAssignmentName string +} + +// NewDatabasePrincipalAssignmentID returns a new DatabasePrincipalAssignmentId struct +func NewDatabasePrincipalAssignmentID(subscriptionId string, resourceGroupName string, clusterName string, databaseName string, principalAssignmentName string) DatabasePrincipalAssignmentId { + return DatabasePrincipalAssignmentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ClusterName: clusterName, + DatabaseName: databaseName, + PrincipalAssignmentName: principalAssignmentName, + } +} + +// ParseDatabasePrincipalAssignmentID parses 'input' into a DatabasePrincipalAssignmentId +func ParseDatabasePrincipalAssignmentID(input string) (*DatabasePrincipalAssignmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabasePrincipalAssignmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabasePrincipalAssignmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDatabasePrincipalAssignmentIDInsensitively parses 'input' case-insensitively into a DatabasePrincipalAssignmentId +// note: this method should only be used for API response data and not user input +func ParseDatabasePrincipalAssignmentIDInsensitively(input string) (*DatabasePrincipalAssignmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabasePrincipalAssignmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabasePrincipalAssignmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DatabasePrincipalAssignmentId) 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.ClusterName, ok = input.Parsed["clusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "clusterName", input) + } + + if id.DatabaseName, ok = input.Parsed["databaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseName", input) + } + + if id.PrincipalAssignmentName, ok = input.Parsed["principalAssignmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "principalAssignmentName", input) + } + + return nil +} + +// ValidateDatabasePrincipalAssignmentID checks that 'input' can be parsed as a Database Principal Assignment ID +func ValidateDatabasePrincipalAssignmentID(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 := ParseDatabasePrincipalAssignmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Database Principal Assignment ID +func (id DatabasePrincipalAssignmentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Kusto/clusters/%s/databases/%s/principalAssignments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName, id.DatabaseName, id.PrincipalAssignmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Database Principal Assignment ID +func (id DatabasePrincipalAssignmentId) 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("staticMicrosoftKusto", "Microsoft.Kusto", "Microsoft.Kusto"), + resourceids.StaticSegment("staticClusters", "clusters", "clusters"), + resourceids.UserSpecifiedSegment("clusterName", "clusterName"), + resourceids.StaticSegment("staticDatabases", "databases", "databases"), + resourceids.UserSpecifiedSegment("databaseName", "databaseName"), + resourceids.StaticSegment("staticPrincipalAssignments", "principalAssignments", "principalAssignments"), + resourceids.UserSpecifiedSegment("principalAssignmentName", "principalAssignmentName"), + } +} + +// String returns a human-readable description of this Database Principal Assignment ID +func (id DatabasePrincipalAssignmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cluster Name: %q", id.ClusterName), + fmt.Sprintf("Database Name: %q", id.DatabaseName), + fmt.Sprintf("Principal Assignment Name: %q", id.PrincipalAssignmentName), + } + return fmt.Sprintf("Database Principal Assignment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/kusto/2024-04-13/databaseprincipalassignments/id_databaseprincipalassignment_test.go b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/id_databaseprincipalassignment_test.go new file mode 100644 index 00000000000..2324d837dc6 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/id_databaseprincipalassignment_test.go @@ -0,0 +1,372 @@ +package databaseprincipalassignments + +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 = &DatabasePrincipalAssignmentId{} + +func TestNewDatabasePrincipalAssignmentID(t *testing.T) { + id := NewDatabasePrincipalAssignmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName", "principalAssignmentName") + + 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.ClusterName != "clusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterName") + } + + if id.DatabaseName != "databaseName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseName'", id.DatabaseName, "databaseName") + } + + if id.PrincipalAssignmentName != "principalAssignmentName" { + t.Fatalf("Expected %q but got %q for Segment 'PrincipalAssignmentName'", id.PrincipalAssignmentName, "principalAssignmentName") + } +} + +func TestFormatDatabasePrincipalAssignmentID(t *testing.T) { + actual := NewDatabasePrincipalAssignmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName", "principalAssignmentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName/principalAssignments/principalAssignmentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDatabasePrincipalAssignmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabasePrincipalAssignmentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName/principalAssignments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName/principalAssignments/principalAssignmentName", + Expected: &DatabasePrincipalAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + DatabaseName: "databaseName", + PrincipalAssignmentName: "principalAssignmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName/principalAssignments/principalAssignmentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabasePrincipalAssignmentID(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.DatabaseName != v.Expected.DatabaseName { + t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) + } + + if actual.PrincipalAssignmentName != v.Expected.PrincipalAssignmentName { + t.Fatalf("Expected %q but got %q for PrincipalAssignmentName", v.Expected.PrincipalAssignmentName, actual.PrincipalAssignmentName) + } + + } +} + +func TestParseDatabasePrincipalAssignmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabasePrincipalAssignmentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/dAtAbAsEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/dAtAbAsEs/dAtAbAsEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName/principalAssignments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/dAtAbAsEs/dAtAbAsEnAmE/pRiNcIpAlAsSiGnMeNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName/principalAssignments/principalAssignmentName", + Expected: &DatabasePrincipalAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + DatabaseName: "databaseName", + PrincipalAssignmentName: "principalAssignmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName/principalAssignments/principalAssignmentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/dAtAbAsEs/dAtAbAsEnAmE/pRiNcIpAlAsSiGnMeNtS/pRiNcIpAlAsSiGnMeNtNaMe", + Expected: &DatabasePrincipalAssignmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ClusterName: "cLuStErNaMe", + DatabaseName: "dAtAbAsEnAmE", + PrincipalAssignmentName: "pRiNcIpAlAsSiGnMeNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/dAtAbAsEs/dAtAbAsEnAmE/pRiNcIpAlAsSiGnMeNtS/pRiNcIpAlAsSiGnMeNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabasePrincipalAssignmentIDInsensitively(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.DatabaseName != v.Expected.DatabaseName { + t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) + } + + if actual.PrincipalAssignmentName != v.Expected.PrincipalAssignmentName { + t.Fatalf("Expected %q but got %q for PrincipalAssignmentName", v.Expected.PrincipalAssignmentName, actual.PrincipalAssignmentName) + } + + } +} + +func TestSegmentsForDatabasePrincipalAssignmentId(t *testing.T) { + segments := DatabasePrincipalAssignmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DatabasePrincipalAssignmentId 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/kusto/2024-04-13/databaseprincipalassignments/method_checknameavailability.go b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/method_checknameavailability.go new file mode 100644 index 00000000000..b7451eac2c5 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/method_checknameavailability.go @@ -0,0 +1,59 @@ +package databaseprincipalassignments + +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 CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameResult +} + +// CheckNameAvailability ... +func (c DatabasePrincipalAssignmentsClient) CheckNameAvailability(ctx context.Context, id commonids.KustoDatabaseId, input DatabasePrincipalAssignmentCheckNameRequest) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkPrincipalAssignmentNameAvailability", 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 CheckNameResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/databaseprincipalassignments/method_createorupdate.go b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/method_createorupdate.go new file mode 100644 index 00000000000..30a34844c33 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/method_createorupdate.go @@ -0,0 +1,75 @@ +package databaseprincipalassignments + +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 *DatabasePrincipalAssignment +} + +// CreateOrUpdate ... +func (c DatabasePrincipalAssignmentsClient) CreateOrUpdate(ctx context.Context, id DatabasePrincipalAssignmentId, input DatabasePrincipalAssignment) (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 DatabasePrincipalAssignmentsClient) CreateOrUpdateThenPoll(ctx context.Context, id DatabasePrincipalAssignmentId, input DatabasePrincipalAssignment) 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/kusto/2024-04-13/databaseprincipalassignments/method_delete.go b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/method_delete.go new file mode 100644 index 00000000000..16f88b84e64 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/method_delete.go @@ -0,0 +1,71 @@ +package databaseprincipalassignments + +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 DatabasePrincipalAssignmentsClient) Delete(ctx context.Context, id DatabasePrincipalAssignmentId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c DatabasePrincipalAssignmentsClient) DeleteThenPoll(ctx context.Context, id DatabasePrincipalAssignmentId) 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/kusto/2024-04-13/databaseprincipalassignments/method_get.go b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/method_get.go new file mode 100644 index 00000000000..346ec4607b5 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/method_get.go @@ -0,0 +1,53 @@ +package databaseprincipalassignments + +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 *DatabasePrincipalAssignment +} + +// Get ... +func (c DatabasePrincipalAssignmentsClient) Get(ctx context.Context, id DatabasePrincipalAssignmentId) (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 DatabasePrincipalAssignment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/databaseprincipalassignments/method_list.go b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/method_list.go new file mode 100644 index 00000000000..d9aea904550 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/method_list.go @@ -0,0 +1,55 @@ +package databaseprincipalassignments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabasePrincipalAssignmentListResult +} + +// List ... +func (c DatabasePrincipalAssignmentsClient) List(ctx context.Context, id commonids.KustoDatabaseId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/principalAssignments", 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 DatabasePrincipalAssignmentListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/databaseprincipalassignments/model_checknameresult.go b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/model_checknameresult.go new file mode 100644 index 00000000000..bb574281c04 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/model_checknameresult.go @@ -0,0 +1,11 @@ +package databaseprincipalassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameResult struct { + Message *string `json:"message,omitempty"` + Name *string `json:"name,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *Reason `json:"reason,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/databaseprincipalassignments/model_databaseprincipalassignment.go b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/model_databaseprincipalassignment.go new file mode 100644 index 00000000000..190c9a56a2d --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/model_databaseprincipalassignment.go @@ -0,0 +1,11 @@ +package databaseprincipalassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabasePrincipalAssignment struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DatabasePrincipalProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/databaseprincipalassignments/model_databaseprincipalassignmentchecknamerequest.go b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/model_databaseprincipalassignmentchecknamerequest.go new file mode 100644 index 00000000000..b6d7aca4027 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/model_databaseprincipalassignmentchecknamerequest.go @@ -0,0 +1,9 @@ +package databaseprincipalassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabasePrincipalAssignmentCheckNameRequest struct { + Name string `json:"name"` + Type DatabasePrincipalAssignmentType `json:"type"` +} diff --git a/resource-manager/kusto/2024-04-13/databaseprincipalassignments/model_databaseprincipalassignmentlistresult.go b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/model_databaseprincipalassignmentlistresult.go new file mode 100644 index 00000000000..da1331a2ccb --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/model_databaseprincipalassignmentlistresult.go @@ -0,0 +1,8 @@ +package databaseprincipalassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabasePrincipalAssignmentListResult struct { + Value *[]DatabasePrincipalAssignment `json:"value,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/databaseprincipalassignments/model_databaseprincipalproperties.go b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/model_databaseprincipalproperties.go new file mode 100644 index 00000000000..c183996eb06 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/model_databaseprincipalproperties.go @@ -0,0 +1,15 @@ +package databaseprincipalassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabasePrincipalProperties struct { + AadObjectId *string `json:"aadObjectId,omitempty"` + PrincipalId string `json:"principalId"` + PrincipalName *string `json:"principalName,omitempty"` + PrincipalType PrincipalType `json:"principalType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Role DatabasePrincipalRole `json:"role"` + TenantId *string `json:"tenantId,omitempty"` + TenantName *string `json:"tenantName,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/databaseprincipalassignments/version.go b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/version.go new file mode 100644 index 00000000000..f7ceebea10e --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databaseprincipalassignments/version.go @@ -0,0 +1,10 @@ +package databaseprincipalassignments + +// 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-04-13" + +func userAgent() string { + return "hashicorp/go-azure-sdk/databaseprincipalassignments/2024-04-13" +} diff --git a/resource-manager/kusto/2024-04-13/databases/README.md b/resource-manager/kusto/2024-04-13/databases/README.md new file mode 100644 index 00000000000..aa787f07e59 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/README.md @@ -0,0 +1,200 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/databases` Documentation + +The `databases` SDK allows for interaction with Azure Resource Manager `kusto` (API Version `2024-04-13`). + +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/kusto/2024-04-13/databases" +``` + + +### Client Initialization + +```go +client := databases.NewDatabasesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DatabasesClient.AddPrincipals` + +```go +ctx := context.TODO() +id := commonids.NewKustoDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName") + +payload := databases.DatabasePrincipalListRequest{ + // ... +} + + +read, err := client.AddPrincipals(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DatabasesClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +payload := databases.CheckNameRequest{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DatabasesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewKustoDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName") + +payload := databases.Database{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload, databases.DefaultCreateOrUpdateOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `DatabasesClient.DatabaseInviteFollower` + +```go +ctx := context.TODO() +id := commonids.NewKustoDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName") + +payload := databases.DatabaseInviteFollowerRequest{ + // ... +} + + +read, err := client.DatabaseInviteFollower(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DatabasesClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewKustoDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `DatabasesClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewKustoDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName") + +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: `DatabasesClient.ListByCluster` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +// alternatively `client.ListByCluster(ctx, id, databases.DefaultListByClusterOperationOptions())` can be used to do batched pagination +items, err := client.ListByClusterComplete(ctx, id, databases.DefaultListByClusterOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DatabasesClient.ListPrincipals` + +```go +ctx := context.TODO() +id := commonids.NewKustoDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName") + +read, err := client.ListPrincipals(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DatabasesClient.RemovePrincipals` + +```go +ctx := context.TODO() +id := commonids.NewKustoDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName") + +payload := databases.DatabasePrincipalListRequest{ + // ... +} + + +read, err := client.RemovePrincipals(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DatabasesClient.Update` + +```go +ctx := context.TODO() +id := commonids.NewKustoDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName") + +payload := databases.Database{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload, databases.DefaultUpdateOperationOptions()); err != nil { + // handle the error +} +``` diff --git a/resource-manager/kusto/2024-04-13/databases/client.go b/resource-manager/kusto/2024-04-13/databases/client.go new file mode 100644 index 00000000000..87de2d4fe59 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/client.go @@ -0,0 +1,26 @@ +package databases + +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 DatabasesClient struct { + Client *resourcemanager.Client +} + +func NewDatabasesClientWithBaseURI(sdkApi sdkEnv.Api) (*DatabasesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "databases", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DatabasesClient: %+v", err) + } + + return &DatabasesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/kusto/2024-04-13/databases/constants.go b/resource-manager/kusto/2024-04-13/databases/constants.go new file mode 100644 index 00000000000..fd46fa713d3 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/constants.go @@ -0,0 +1,415 @@ +package databases + +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 CallerRole string + +const ( + CallerRoleAdmin CallerRole = "Admin" + CallerRoleNone CallerRole = "None" +) + +func PossibleValuesForCallerRole() []string { + return []string{ + string(CallerRoleAdmin), + string(CallerRoleNone), + } +} + +func (s *CallerRole) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCallerRole(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCallerRole(input string) (*CallerRole, error) { + vals := map[string]CallerRole{ + "admin": CallerRoleAdmin, + "none": CallerRoleNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CallerRole(input) + return &out, nil +} + +type DatabasePrincipalRole string + +const ( + DatabasePrincipalRoleAdmin DatabasePrincipalRole = "Admin" + DatabasePrincipalRoleIngestor DatabasePrincipalRole = "Ingestor" + DatabasePrincipalRoleMonitor DatabasePrincipalRole = "Monitor" + DatabasePrincipalRoleUnrestrictedViewer DatabasePrincipalRole = "UnrestrictedViewer" + DatabasePrincipalRoleUser DatabasePrincipalRole = "User" + DatabasePrincipalRoleViewer DatabasePrincipalRole = "Viewer" +) + +func PossibleValuesForDatabasePrincipalRole() []string { + return []string{ + string(DatabasePrincipalRoleAdmin), + string(DatabasePrincipalRoleIngestor), + string(DatabasePrincipalRoleMonitor), + string(DatabasePrincipalRoleUnrestrictedViewer), + string(DatabasePrincipalRoleUser), + string(DatabasePrincipalRoleViewer), + } +} + +func (s *DatabasePrincipalRole) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDatabasePrincipalRole(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDatabasePrincipalRole(input string) (*DatabasePrincipalRole, error) { + vals := map[string]DatabasePrincipalRole{ + "admin": DatabasePrincipalRoleAdmin, + "ingestor": DatabasePrincipalRoleIngestor, + "monitor": DatabasePrincipalRoleMonitor, + "unrestrictedviewer": DatabasePrincipalRoleUnrestrictedViewer, + "user": DatabasePrincipalRoleUser, + "viewer": DatabasePrincipalRoleViewer, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DatabasePrincipalRole(input) + return &out, nil +} + +type DatabasePrincipalType string + +const ( + DatabasePrincipalTypeApp DatabasePrincipalType = "App" + DatabasePrincipalTypeGroup DatabasePrincipalType = "Group" + DatabasePrincipalTypeUser DatabasePrincipalType = "User" +) + +func PossibleValuesForDatabasePrincipalType() []string { + return []string{ + string(DatabasePrincipalTypeApp), + string(DatabasePrincipalTypeGroup), + string(DatabasePrincipalTypeUser), + } +} + +func (s *DatabasePrincipalType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDatabasePrincipalType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDatabasePrincipalType(input string) (*DatabasePrincipalType, error) { + vals := map[string]DatabasePrincipalType{ + "app": DatabasePrincipalTypeApp, + "group": DatabasePrincipalTypeGroup, + "user": DatabasePrincipalTypeUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DatabasePrincipalType(input) + return &out, nil +} + +type DatabaseShareOrigin string + +const ( + DatabaseShareOriginDataShare DatabaseShareOrigin = "DataShare" + DatabaseShareOriginDirect DatabaseShareOrigin = "Direct" + DatabaseShareOriginOther DatabaseShareOrigin = "Other" +) + +func PossibleValuesForDatabaseShareOrigin() []string { + return []string{ + string(DatabaseShareOriginDataShare), + string(DatabaseShareOriginDirect), + string(DatabaseShareOriginOther), + } +} + +func (s *DatabaseShareOrigin) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDatabaseShareOrigin(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDatabaseShareOrigin(input string) (*DatabaseShareOrigin, error) { + vals := map[string]DatabaseShareOrigin{ + "datashare": DatabaseShareOriginDataShare, + "direct": DatabaseShareOriginDirect, + "other": DatabaseShareOriginOther, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DatabaseShareOrigin(input) + return &out, nil +} + +type Kind string + +const ( + KindReadOnlyFollowing Kind = "ReadOnlyFollowing" + KindReadWrite Kind = "ReadWrite" +) + +func PossibleValuesForKind() []string { + return []string{ + string(KindReadOnlyFollowing), + string(KindReadWrite), + } +} + +func (s *Kind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKind(input string) (*Kind, error) { + vals := map[string]Kind{ + "readonlyfollowing": KindReadOnlyFollowing, + "readwrite": KindReadWrite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Kind(input) + return &out, nil +} + +type PrincipalsModificationKind string + +const ( + PrincipalsModificationKindNone PrincipalsModificationKind = "None" + PrincipalsModificationKindReplace PrincipalsModificationKind = "Replace" + PrincipalsModificationKindUnion PrincipalsModificationKind = "Union" +) + +func PossibleValuesForPrincipalsModificationKind() []string { + return []string{ + string(PrincipalsModificationKindNone), + string(PrincipalsModificationKindReplace), + string(PrincipalsModificationKindUnion), + } +} + +func (s *PrincipalsModificationKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrincipalsModificationKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrincipalsModificationKind(input string) (*PrincipalsModificationKind, error) { + vals := map[string]PrincipalsModificationKind{ + "none": PrincipalsModificationKindNone, + "replace": PrincipalsModificationKindReplace, + "union": PrincipalsModificationKindUnion, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrincipalsModificationKind(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateMoving ProvisioningState = "Moving" + ProvisioningStateRunning ProvisioningState = "Running" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateMoving), + string(ProvisioningStateRunning), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "moving": ProvisioningStateMoving, + "running": ProvisioningStateRunning, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type Reason string + +const ( + ReasonAlreadyExists Reason = "AlreadyExists" + ReasonInvalid Reason = "Invalid" +) + +func PossibleValuesForReason() []string { + return []string{ + string(ReasonAlreadyExists), + string(ReasonInvalid), + } +} + +func (s *Reason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReason(input string) (*Reason, error) { + vals := map[string]Reason{ + "alreadyexists": ReasonAlreadyExists, + "invalid": ReasonInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Reason(input) + return &out, nil +} + +type Type string + +const ( + TypeMicrosoftPointKustoClustersAttachedDatabaseConfigurations Type = "Microsoft.Kusto/clusters/attachedDatabaseConfigurations" + TypeMicrosoftPointKustoClustersDatabases Type = "Microsoft.Kusto/clusters/databases" +) + +func PossibleValuesForType() []string { + return []string{ + string(TypeMicrosoftPointKustoClustersAttachedDatabaseConfigurations), + string(TypeMicrosoftPointKustoClustersDatabases), + } +} + +func (s *Type) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseType(input string) (*Type, error) { + vals := map[string]Type{ + "microsoft.kusto/clusters/attacheddatabaseconfigurations": TypeMicrosoftPointKustoClustersAttachedDatabaseConfigurations, + "microsoft.kusto/clusters/databases": TypeMicrosoftPointKustoClustersDatabases, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Type(input) + return &out, nil +} diff --git a/resource-manager/kusto/2024-04-13/databases/method_addprincipals.go b/resource-manager/kusto/2024-04-13/databases/method_addprincipals.go new file mode 100644 index 00000000000..f9a6893b0c3 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/method_addprincipals.go @@ -0,0 +1,59 @@ +package databases + +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 AddPrincipalsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabasePrincipalListResult +} + +// AddPrincipals ... +func (c DatabasesClient) AddPrincipals(ctx context.Context, id commonids.KustoDatabaseId, input DatabasePrincipalListRequest) (result AddPrincipalsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/addPrincipals", 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 DatabasePrincipalListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/databases/method_checknameavailability.go b/resource-manager/kusto/2024-04-13/databases/method_checknameavailability.go new file mode 100644 index 00000000000..dd68c75ed53 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/method_checknameavailability.go @@ -0,0 +1,59 @@ +package databases + +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 CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameResult +} + +// CheckNameAvailability ... +func (c DatabasesClient) CheckNameAvailability(ctx context.Context, id commonids.KustoClusterId, input CheckNameRequest) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkNameAvailability", 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 CheckNameResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/databases/method_createorupdate.go b/resource-manager/kusto/2024-04-13/databases/method_createorupdate.go new file mode 100644 index 00000000000..1a667eb0fc4 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/method_createorupdate.go @@ -0,0 +1,106 @@ +package databases + +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 Database +} + +type CreateOrUpdateOperationOptions struct { + CallerRole *CallerRole +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.CallerRole != nil { + out.Append("callerRole", fmt.Sprintf("%v", *o.CallerRole)) + } + return &out +} + +// CreateOrUpdate ... +func (c DatabasesClient) CreateOrUpdate(ctx context.Context, id commonids.KustoDatabaseId, input Database, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + 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 DatabasesClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.KustoDatabaseId, input Database, options CreateOrUpdateOperationOptions) error { + result, err := c.CreateOrUpdate(ctx, id, input, options) + 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/kusto/2024-04-13/databases/method_databaseinvitefollower.go b/resource-manager/kusto/2024-04-13/databases/method_databaseinvitefollower.go new file mode 100644 index 00000000000..cc72a544f30 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/method_databaseinvitefollower.go @@ -0,0 +1,59 @@ +package databases + +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 DatabaseInviteFollowerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseInviteFollowerResult +} + +// DatabaseInviteFollower ... +func (c DatabasesClient) DatabaseInviteFollower(ctx context.Context, id commonids.KustoDatabaseId, input DatabaseInviteFollowerRequest) (result DatabaseInviteFollowerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/inviteFollower", 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 DatabaseInviteFollowerResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/databases/method_delete.go b/resource-manager/kusto/2024-04-13/databases/method_delete.go new file mode 100644 index 00000000000..3b7cd9785e1 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/method_delete.go @@ -0,0 +1,72 @@ +package databases + +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 DatabasesClient) Delete(ctx context.Context, id commonids.KustoDatabaseId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c DatabasesClient) DeleteThenPoll(ctx context.Context, id commonids.KustoDatabaseId) 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/kusto/2024-04-13/databases/method_get.go b/resource-manager/kusto/2024-04-13/databases/method_get.go new file mode 100644 index 00000000000..528a39c5f19 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/method_get.go @@ -0,0 +1,59 @@ +package databases + +import ( + "context" + "encoding/json" + "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 Database +} + +// Get ... +func (c DatabasesClient) Get(ctx context.Context, id commonids.KustoDatabaseId) (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 respObj json.RawMessage + if err = resp.Unmarshal(&respObj); err != nil { + return + } + model, err := UnmarshalDatabaseImplementation(respObj) + if err != nil { + return + } + result.Model = model + + return +} diff --git a/resource-manager/kusto/2024-04-13/databases/method_listbycluster.go b/resource-manager/kusto/2024-04-13/databases/method_listbycluster.go new file mode 100644 index 00000000000..2db8e7a3f3e --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/method_listbycluster.go @@ -0,0 +1,147 @@ +package databases + +import ( + "context" + "encoding/json" + "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 ListByClusterOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Database +} + +type ListByClusterCompleteResult struct { + LatestHttpResponse *http.Response + Items []Database +} + +type ListByClusterOperationOptions struct { + Top *int64 +} + +func DefaultListByClusterOperationOptions() ListByClusterOperationOptions { + return ListByClusterOperationOptions{} +} + +func (o ListByClusterOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByClusterOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByClusterOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListByClusterCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByClusterCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByCluster ... +func (c DatabasesClient) ListByCluster(ctx context.Context, id commonids.KustoClusterId, options ListByClusterOperationOptions) (result ListByClusterOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByClusterCustomPager{}, + Path: fmt.Sprintf("%s/databases", 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 *[]json.RawMessage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + temp := make([]Database, 0) + if values.Values != nil { + for i, v := range *values.Values { + val, err := UnmarshalDatabaseImplementation(v) + if err != nil { + err = fmt.Errorf("unmarshalling item %d for Database (%q): %+v", i, v, err) + return result, err + } + temp = append(temp, val) + } + } + result.Model = &temp + + return +} + +// ListByClusterComplete retrieves all the results into a single object +func (c DatabasesClient) ListByClusterComplete(ctx context.Context, id commonids.KustoClusterId, options ListByClusterOperationOptions) (ListByClusterCompleteResult, error) { + return c.ListByClusterCompleteMatchingPredicate(ctx, id, options, DatabaseOperationPredicate{}) +} + +// ListByClusterCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DatabasesClient) ListByClusterCompleteMatchingPredicate(ctx context.Context, id commonids.KustoClusterId, options ListByClusterOperationOptions, predicate DatabaseOperationPredicate) (result ListByClusterCompleteResult, err error) { + items := make([]Database, 0) + + resp, err := c.ListByCluster(ctx, id, options) + 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 = ListByClusterCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/kusto/2024-04-13/databases/method_listprincipals.go b/resource-manager/kusto/2024-04-13/databases/method_listprincipals.go new file mode 100644 index 00000000000..26417872959 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/method_listprincipals.go @@ -0,0 +1,55 @@ +package databases + +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 ListPrincipalsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabasePrincipalListResult +} + +// ListPrincipals ... +func (c DatabasesClient) ListPrincipals(ctx context.Context, id commonids.KustoDatabaseId) (result ListPrincipalsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listPrincipals", 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 DatabasePrincipalListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/databases/method_removeprincipals.go b/resource-manager/kusto/2024-04-13/databases/method_removeprincipals.go new file mode 100644 index 00000000000..24ee4c78839 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/method_removeprincipals.go @@ -0,0 +1,59 @@ +package databases + +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 RemovePrincipalsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabasePrincipalListResult +} + +// RemovePrincipals ... +func (c DatabasesClient) RemovePrincipals(ctx context.Context, id commonids.KustoDatabaseId, input DatabasePrincipalListRequest) (result RemovePrincipalsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/removePrincipals", 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 DatabasePrincipalListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/databases/method_update.go b/resource-manager/kusto/2024-04-13/databases/method_update.go new file mode 100644 index 00000000000..e0685518bd6 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/method_update.go @@ -0,0 +1,106 @@ +package databases + +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 Database +} + +type UpdateOperationOptions struct { + CallerRole *CallerRole +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.CallerRole != nil { + out.Append("callerRole", fmt.Sprintf("%v", *o.CallerRole)) + } + return &out +} + +// Update ... +func (c DatabasesClient) Update(ctx context.Context, id commonids.KustoDatabaseId, input Database, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + OptionsObject: options, + 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 DatabasesClient) UpdateThenPoll(ctx context.Context, id commonids.KustoDatabaseId, input Database, options UpdateOperationOptions) error { + result, err := c.Update(ctx, id, input, options) + 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/kusto/2024-04-13/databases/model_checknamerequest.go b/resource-manager/kusto/2024-04-13/databases/model_checknamerequest.go new file mode 100644 index 00000000000..105535ee536 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/model_checknamerequest.go @@ -0,0 +1,9 @@ +package databases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameRequest struct { + Name string `json:"name"` + Type Type `json:"type"` +} diff --git a/resource-manager/kusto/2024-04-13/databases/model_checknameresult.go b/resource-manager/kusto/2024-04-13/databases/model_checknameresult.go new file mode 100644 index 00000000000..2939f2274a5 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/model_checknameresult.go @@ -0,0 +1,11 @@ +package databases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameResult struct { + Message *string `json:"message,omitempty"` + Name *string `json:"name,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *Reason `json:"reason,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/databases/model_database.go b/resource-manager/kusto/2024-04-13/databases/model_database.go new file mode 100644 index 00000000000..265196f31f4 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/model_database.go @@ -0,0 +1,87 @@ +package databases + +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 Database interface { + Database() BaseDatabaseImpl +} + +var _ Database = BaseDatabaseImpl{} + +type BaseDatabaseImpl struct { + Id *string `json:"id,omitempty"` + Kind Kind `json:"kind"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +func (s BaseDatabaseImpl) Database() BaseDatabaseImpl { + return s +} + +var _ Database = RawDatabaseImpl{} + +// RawDatabaseImpl 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 RawDatabaseImpl struct { + database BaseDatabaseImpl + Type string + Values map[string]interface{} +} + +func (s RawDatabaseImpl) Database() BaseDatabaseImpl { + return s.database +} + +func UnmarshalDatabaseImplementation(input []byte) (Database, 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 Database into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["kind"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "ReadOnlyFollowing") { + var out ReadOnlyFollowingDatabase + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ReadOnlyFollowingDatabase: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ReadWrite") { + var out ReadWriteDatabase + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ReadWriteDatabase: %+v", err) + } + return out, nil + } + + var parent BaseDatabaseImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseDatabaseImpl: %+v", err) + } + + return RawDatabaseImpl{ + database: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/kusto/2024-04-13/databases/model_databaseinvitefollowerrequest.go b/resource-manager/kusto/2024-04-13/databases/model_databaseinvitefollowerrequest.go new file mode 100644 index 00000000000..6c47e32a6aa --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/model_databaseinvitefollowerrequest.go @@ -0,0 +1,9 @@ +package databases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseInviteFollowerRequest struct { + InviteeEmail string `json:"inviteeEmail"` + TableLevelSharingProperties *TableLevelSharingProperties `json:"tableLevelSharingProperties,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/databases/model_databaseinvitefollowerresult.go b/resource-manager/kusto/2024-04-13/databases/model_databaseinvitefollowerresult.go new file mode 100644 index 00000000000..d52c55a8f0f --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/model_databaseinvitefollowerresult.go @@ -0,0 +1,8 @@ +package databases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseInviteFollowerResult struct { + GeneratedInvitation *string `json:"generatedInvitation,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/databases/model_databaseprincipal.go b/resource-manager/kusto/2024-04-13/databases/model_databaseprincipal.go new file mode 100644 index 00000000000..221f188d7c4 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/model_databaseprincipal.go @@ -0,0 +1,14 @@ +package databases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabasePrincipal struct { + AppId *string `json:"appId,omitempty"` + Email *string `json:"email,omitempty"` + Fqn *string `json:"fqn,omitempty"` + Name string `json:"name"` + Role DatabasePrincipalRole `json:"role"` + TenantName *string `json:"tenantName,omitempty"` + Type DatabasePrincipalType `json:"type"` +} diff --git a/resource-manager/kusto/2024-04-13/databases/model_databaseprincipallistrequest.go b/resource-manager/kusto/2024-04-13/databases/model_databaseprincipallistrequest.go new file mode 100644 index 00000000000..c640d6f914b --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/model_databaseprincipallistrequest.go @@ -0,0 +1,8 @@ +package databases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabasePrincipalListRequest struct { + Value *[]DatabasePrincipal `json:"value,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/databases/model_databaseprincipallistresult.go b/resource-manager/kusto/2024-04-13/databases/model_databaseprincipallistresult.go new file mode 100644 index 00000000000..65247b9f69a --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/model_databaseprincipallistresult.go @@ -0,0 +1,8 @@ +package databases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabasePrincipalListResult struct { + Value *[]DatabasePrincipal `json:"value,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/databases/model_databasestatistics.go b/resource-manager/kusto/2024-04-13/databases/model_databasestatistics.go new file mode 100644 index 00000000000..8cda1deb8e9 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/model_databasestatistics.go @@ -0,0 +1,8 @@ +package databases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseStatistics struct { + Size *float64 `json:"size,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/databases/model_keyvaultproperties.go b/resource-manager/kusto/2024-04-13/databases/model_keyvaultproperties.go new file mode 100644 index 00000000000..ade31e22074 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/model_keyvaultproperties.go @@ -0,0 +1,11 @@ +package databases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultProperties struct { + KeyName *string `json:"keyName,omitempty"` + KeyVaultUri *string `json:"keyVaultUri,omitempty"` + KeyVersion *string `json:"keyVersion,omitempty"` + UserIdentity *string `json:"userIdentity,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/databases/model_readonlyfollowingdatabase.go b/resource-manager/kusto/2024-04-13/databases/model_readonlyfollowingdatabase.go new file mode 100644 index 00000000000..69a2a96411d --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/model_readonlyfollowingdatabase.go @@ -0,0 +1,58 @@ +package databases + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Database = ReadOnlyFollowingDatabase{} + +type ReadOnlyFollowingDatabase struct { + Properties *ReadOnlyFollowingDatabaseProperties `json:"properties,omitempty"` + + // Fields inherited from Database + + Id *string `json:"id,omitempty"` + Kind Kind `json:"kind"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +func (s ReadOnlyFollowingDatabase) Database() BaseDatabaseImpl { + return BaseDatabaseImpl{ + Id: s.Id, + Kind: s.Kind, + Location: s.Location, + Name: s.Name, + Type: s.Type, + } +} + +var _ json.Marshaler = ReadOnlyFollowingDatabase{} + +func (s ReadOnlyFollowingDatabase) MarshalJSON() ([]byte, error) { + type wrapper ReadOnlyFollowingDatabase + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ReadOnlyFollowingDatabase: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ReadOnlyFollowingDatabase: %+v", err) + } + + decoded["kind"] = "ReadOnlyFollowing" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ReadOnlyFollowingDatabase: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/kusto/2024-04-13/databases/model_readonlyfollowingdatabaseproperties.go b/resource-manager/kusto/2024-04-13/databases/model_readonlyfollowingdatabaseproperties.go new file mode 100644 index 00000000000..279507a275c --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/model_readonlyfollowingdatabaseproperties.go @@ -0,0 +1,18 @@ +package databases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReadOnlyFollowingDatabaseProperties struct { + AttachedDatabaseConfigurationName *string `json:"attachedDatabaseConfigurationName,omitempty"` + DatabaseShareOrigin *DatabaseShareOrigin `json:"databaseShareOrigin,omitempty"` + HotCachePeriod *string `json:"hotCachePeriod,omitempty"` + LeaderClusterResourceId *string `json:"leaderClusterResourceId,omitempty"` + OriginalDatabaseName *string `json:"originalDatabaseName,omitempty"` + PrincipalsModificationKind *PrincipalsModificationKind `json:"principalsModificationKind,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SoftDeletePeriod *string `json:"softDeletePeriod,omitempty"` + Statistics *DatabaseStatistics `json:"statistics,omitempty"` + SuspensionDetails *SuspensionDetails `json:"suspensionDetails,omitempty"` + TableLevelSharingProperties *TableLevelSharingProperties `json:"tableLevelSharingProperties,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/databases/model_readwritedatabase.go b/resource-manager/kusto/2024-04-13/databases/model_readwritedatabase.go new file mode 100644 index 00000000000..441baecd65d --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/model_readwritedatabase.go @@ -0,0 +1,58 @@ +package databases + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Database = ReadWriteDatabase{} + +type ReadWriteDatabase struct { + Properties *ReadWriteDatabaseProperties `json:"properties,omitempty"` + + // Fields inherited from Database + + Id *string `json:"id,omitempty"` + Kind Kind `json:"kind"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +func (s ReadWriteDatabase) Database() BaseDatabaseImpl { + return BaseDatabaseImpl{ + Id: s.Id, + Kind: s.Kind, + Location: s.Location, + Name: s.Name, + Type: s.Type, + } +} + +var _ json.Marshaler = ReadWriteDatabase{} + +func (s ReadWriteDatabase) MarshalJSON() ([]byte, error) { + type wrapper ReadWriteDatabase + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ReadWriteDatabase: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ReadWriteDatabase: %+v", err) + } + + decoded["kind"] = "ReadWrite" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ReadWriteDatabase: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/kusto/2024-04-13/databases/model_readwritedatabaseproperties.go b/resource-manager/kusto/2024-04-13/databases/model_readwritedatabaseproperties.go new file mode 100644 index 00000000000..320eefedec6 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/model_readwritedatabaseproperties.go @@ -0,0 +1,14 @@ +package databases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReadWriteDatabaseProperties struct { + HotCachePeriod *string `json:"hotCachePeriod,omitempty"` + IsFollowed *bool `json:"isFollowed,omitempty"` + KeyVaultProperties *KeyVaultProperties `json:"keyVaultProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SoftDeletePeriod *string `json:"softDeletePeriod,omitempty"` + Statistics *DatabaseStatistics `json:"statistics,omitempty"` + SuspensionDetails *SuspensionDetails `json:"suspensionDetails,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/databases/model_suspensiondetails.go b/resource-manager/kusto/2024-04-13/databases/model_suspensiondetails.go new file mode 100644 index 00000000000..b5ea2e1f684 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/model_suspensiondetails.go @@ -0,0 +1,26 @@ +package databases + +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 SuspensionDetails struct { + SuspensionStartDate *string `json:"suspensionStartDate,omitempty"` +} + +func (o *SuspensionDetails) GetSuspensionStartDateAsTime() (*time.Time, error) { + if o.SuspensionStartDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SuspensionStartDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *SuspensionDetails) SetSuspensionStartDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SuspensionStartDate = &formatted +} diff --git a/resource-manager/kusto/2024-04-13/databases/model_tablelevelsharingproperties.go b/resource-manager/kusto/2024-04-13/databases/model_tablelevelsharingproperties.go new file mode 100644 index 00000000000..7fed07aec37 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/model_tablelevelsharingproperties.go @@ -0,0 +1,15 @@ +package databases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TableLevelSharingProperties struct { + ExternalTablesToExclude *[]string `json:"externalTablesToExclude,omitempty"` + ExternalTablesToInclude *[]string `json:"externalTablesToInclude,omitempty"` + FunctionsToExclude *[]string `json:"functionsToExclude,omitempty"` + FunctionsToInclude *[]string `json:"functionsToInclude,omitempty"` + MaterializedViewsToExclude *[]string `json:"materializedViewsToExclude,omitempty"` + MaterializedViewsToInclude *[]string `json:"materializedViewsToInclude,omitempty"` + TablesToExclude *[]string `json:"tablesToExclude,omitempty"` + TablesToInclude *[]string `json:"tablesToInclude,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/databases/predicates.go b/resource-manager/kusto/2024-04-13/databases/predicates.go new file mode 100644 index 00000000000..e234d724b56 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/predicates.go @@ -0,0 +1,12 @@ +package databases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseOperationPredicate struct { +} + +func (p DatabaseOperationPredicate) Matches(input Database) bool { + + return true +} diff --git a/resource-manager/kusto/2024-04-13/databases/version.go b/resource-manager/kusto/2024-04-13/databases/version.go new file mode 100644 index 00000000000..8fb3acb9607 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/databases/version.go @@ -0,0 +1,10 @@ +package databases + +// 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-04-13" + +func userAgent() string { + return "hashicorp/go-azure-sdk/databases/2024-04-13" +} diff --git a/resource-manager/kusto/2024-04-13/dataconnections/README.md b/resource-manager/kusto/2024-04-13/dataconnections/README.md new file mode 100644 index 00000000000..7974b263229 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/README.md @@ -0,0 +1,137 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/dataconnections` Documentation + +The `dataconnections` SDK allows for interaction with Azure Resource Manager `kusto` (API Version `2024-04-13`). + +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/kusto/2024-04-13/dataconnections" +``` + + +### Client Initialization + +```go +client := dataconnections.NewDataConnectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DataConnectionsClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := commonids.NewKustoDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName") + +payload := dataconnections.DataConnectionCheckNameRequest{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DataConnectionsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := dataconnections.NewDataConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName", "dataConnectionName") + +payload := dataconnections.DataConnection{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DataConnectionsClient.DataConnectionValidation` + +```go +ctx := context.TODO() +id := commonids.NewKustoDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName") + +payload := dataconnections.DataConnectionValidation{ + // ... +} + + +if err := client.DataConnectionValidationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DataConnectionsClient.Delete` + +```go +ctx := context.TODO() +id := dataconnections.NewDataConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName", "dataConnectionName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `DataConnectionsClient.Get` + +```go +ctx := context.TODO() +id := dataconnections.NewDataConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName", "dataConnectionName") + +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: `DataConnectionsClient.ListByDatabase` + +```go +ctx := context.TODO() +id := commonids.NewKustoDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName") + +read, err := client.ListByDatabase(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DataConnectionsClient.Update` + +```go +ctx := context.TODO() +id := dataconnections.NewDataConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName", "dataConnectionName") + +payload := dataconnections.DataConnection{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/kusto/2024-04-13/dataconnections/client.go b/resource-manager/kusto/2024-04-13/dataconnections/client.go new file mode 100644 index 00000000000..8b88ce58c7e --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/client.go @@ -0,0 +1,26 @@ +package dataconnections + +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 DataConnectionsClient struct { + Client *resourcemanager.Client +} + +func NewDataConnectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*DataConnectionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "dataconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DataConnectionsClient: %+v", err) + } + + return &DataConnectionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/kusto/2024-04-13/dataconnections/constants.go b/resource-manager/kusto/2024-04-13/dataconnections/constants.go new file mode 100644 index 00000000000..b8f76aed751 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/constants.go @@ -0,0 +1,564 @@ +package dataconnections + +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 BlobStorageEventType string + +const ( + BlobStorageEventTypeMicrosoftPointStoragePointBlobCreated BlobStorageEventType = "Microsoft.Storage.BlobCreated" + BlobStorageEventTypeMicrosoftPointStoragePointBlobRenamed BlobStorageEventType = "Microsoft.Storage.BlobRenamed" +) + +func PossibleValuesForBlobStorageEventType() []string { + return []string{ + string(BlobStorageEventTypeMicrosoftPointStoragePointBlobCreated), + string(BlobStorageEventTypeMicrosoftPointStoragePointBlobRenamed), + } +} + +func (s *BlobStorageEventType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBlobStorageEventType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBlobStorageEventType(input string) (*BlobStorageEventType, error) { + vals := map[string]BlobStorageEventType{ + "microsoft.storage.blobcreated": BlobStorageEventTypeMicrosoftPointStoragePointBlobCreated, + "microsoft.storage.blobrenamed": BlobStorageEventTypeMicrosoftPointStoragePointBlobRenamed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BlobStorageEventType(input) + return &out, nil +} + +type Compression string + +const ( + CompressionGZip Compression = "GZip" + CompressionNone Compression = "None" +) + +func PossibleValuesForCompression() []string { + return []string{ + string(CompressionGZip), + string(CompressionNone), + } +} + +func (s *Compression) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCompression(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCompression(input string) (*Compression, error) { + vals := map[string]Compression{ + "gzip": CompressionGZip, + "none": CompressionNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Compression(input) + return &out, nil +} + +type DataConnectionKind string + +const ( + DataConnectionKindCosmosDb DataConnectionKind = "CosmosDb" + DataConnectionKindEventGrid DataConnectionKind = "EventGrid" + DataConnectionKindEventHub DataConnectionKind = "EventHub" + DataConnectionKindIotHub DataConnectionKind = "IotHub" +) + +func PossibleValuesForDataConnectionKind() []string { + return []string{ + string(DataConnectionKindCosmosDb), + string(DataConnectionKindEventGrid), + string(DataConnectionKindEventHub), + string(DataConnectionKindIotHub), + } +} + +func (s *DataConnectionKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataConnectionKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataConnectionKind(input string) (*DataConnectionKind, error) { + vals := map[string]DataConnectionKind{ + "cosmosdb": DataConnectionKindCosmosDb, + "eventgrid": DataConnectionKindEventGrid, + "eventhub": DataConnectionKindEventHub, + "iothub": DataConnectionKindIotHub, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataConnectionKind(input) + return &out, nil +} + +type DataConnectionType string + +const ( + DataConnectionTypeMicrosoftPointKustoClustersDatabasesDataConnections DataConnectionType = "Microsoft.Kusto/clusters/databases/dataConnections" +) + +func PossibleValuesForDataConnectionType() []string { + return []string{ + string(DataConnectionTypeMicrosoftPointKustoClustersDatabasesDataConnections), + } +} + +func (s *DataConnectionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataConnectionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataConnectionType(input string) (*DataConnectionType, error) { + vals := map[string]DataConnectionType{ + "microsoft.kusto/clusters/databases/dataconnections": DataConnectionTypeMicrosoftPointKustoClustersDatabasesDataConnections, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataConnectionType(input) + return &out, nil +} + +type DatabaseRouting string + +const ( + DatabaseRoutingMulti DatabaseRouting = "Multi" + DatabaseRoutingSingle DatabaseRouting = "Single" +) + +func PossibleValuesForDatabaseRouting() []string { + return []string{ + string(DatabaseRoutingMulti), + string(DatabaseRoutingSingle), + } +} + +func (s *DatabaseRouting) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDatabaseRouting(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDatabaseRouting(input string) (*DatabaseRouting, error) { + vals := map[string]DatabaseRouting{ + "multi": DatabaseRoutingMulti, + "single": DatabaseRoutingSingle, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DatabaseRouting(input) + return &out, nil +} + +type EventGridDataFormat string + +const ( + EventGridDataFormatAPACHEAVRO EventGridDataFormat = "APACHEAVRO" + EventGridDataFormatAVRO EventGridDataFormat = "AVRO" + EventGridDataFormatCSV EventGridDataFormat = "CSV" + EventGridDataFormatJSON EventGridDataFormat = "JSON" + EventGridDataFormatMULTIJSON EventGridDataFormat = "MULTIJSON" + EventGridDataFormatORC EventGridDataFormat = "ORC" + EventGridDataFormatPARQUET EventGridDataFormat = "PARQUET" + EventGridDataFormatPSV EventGridDataFormat = "PSV" + EventGridDataFormatRAW EventGridDataFormat = "RAW" + EventGridDataFormatSCSV EventGridDataFormat = "SCSV" + EventGridDataFormatSINGLEJSON EventGridDataFormat = "SINGLEJSON" + EventGridDataFormatSOHSV EventGridDataFormat = "SOHSV" + EventGridDataFormatTSV EventGridDataFormat = "TSV" + EventGridDataFormatTSVE EventGridDataFormat = "TSVE" + EventGridDataFormatTXT EventGridDataFormat = "TXT" + EventGridDataFormatWThreeCLOGFILE EventGridDataFormat = "W3CLOGFILE" +) + +func PossibleValuesForEventGridDataFormat() []string { + return []string{ + string(EventGridDataFormatAPACHEAVRO), + string(EventGridDataFormatAVRO), + string(EventGridDataFormatCSV), + string(EventGridDataFormatJSON), + string(EventGridDataFormatMULTIJSON), + string(EventGridDataFormatORC), + string(EventGridDataFormatPARQUET), + string(EventGridDataFormatPSV), + string(EventGridDataFormatRAW), + string(EventGridDataFormatSCSV), + string(EventGridDataFormatSINGLEJSON), + string(EventGridDataFormatSOHSV), + string(EventGridDataFormatTSV), + string(EventGridDataFormatTSVE), + string(EventGridDataFormatTXT), + string(EventGridDataFormatWThreeCLOGFILE), + } +} + +func (s *EventGridDataFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEventGridDataFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEventGridDataFormat(input string) (*EventGridDataFormat, error) { + vals := map[string]EventGridDataFormat{ + "apacheavro": EventGridDataFormatAPACHEAVRO, + "avro": EventGridDataFormatAVRO, + "csv": EventGridDataFormatCSV, + "json": EventGridDataFormatJSON, + "multijson": EventGridDataFormatMULTIJSON, + "orc": EventGridDataFormatORC, + "parquet": EventGridDataFormatPARQUET, + "psv": EventGridDataFormatPSV, + "raw": EventGridDataFormatRAW, + "scsv": EventGridDataFormatSCSV, + "singlejson": EventGridDataFormatSINGLEJSON, + "sohsv": EventGridDataFormatSOHSV, + "tsv": EventGridDataFormatTSV, + "tsve": EventGridDataFormatTSVE, + "txt": EventGridDataFormatTXT, + "w3clogfile": EventGridDataFormatWThreeCLOGFILE, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EventGridDataFormat(input) + return &out, nil +} + +type EventHubDataFormat string + +const ( + EventHubDataFormatAPACHEAVRO EventHubDataFormat = "APACHEAVRO" + EventHubDataFormatAVRO EventHubDataFormat = "AVRO" + EventHubDataFormatCSV EventHubDataFormat = "CSV" + EventHubDataFormatJSON EventHubDataFormat = "JSON" + EventHubDataFormatMULTIJSON EventHubDataFormat = "MULTIJSON" + EventHubDataFormatORC EventHubDataFormat = "ORC" + EventHubDataFormatPARQUET EventHubDataFormat = "PARQUET" + EventHubDataFormatPSV EventHubDataFormat = "PSV" + EventHubDataFormatRAW EventHubDataFormat = "RAW" + EventHubDataFormatSCSV EventHubDataFormat = "SCSV" + EventHubDataFormatSINGLEJSON EventHubDataFormat = "SINGLEJSON" + EventHubDataFormatSOHSV EventHubDataFormat = "SOHSV" + EventHubDataFormatTSV EventHubDataFormat = "TSV" + EventHubDataFormatTSVE EventHubDataFormat = "TSVE" + EventHubDataFormatTXT EventHubDataFormat = "TXT" + EventHubDataFormatWThreeCLOGFILE EventHubDataFormat = "W3CLOGFILE" +) + +func PossibleValuesForEventHubDataFormat() []string { + return []string{ + string(EventHubDataFormatAPACHEAVRO), + string(EventHubDataFormatAVRO), + string(EventHubDataFormatCSV), + string(EventHubDataFormatJSON), + string(EventHubDataFormatMULTIJSON), + string(EventHubDataFormatORC), + string(EventHubDataFormatPARQUET), + string(EventHubDataFormatPSV), + string(EventHubDataFormatRAW), + string(EventHubDataFormatSCSV), + string(EventHubDataFormatSINGLEJSON), + string(EventHubDataFormatSOHSV), + string(EventHubDataFormatTSV), + string(EventHubDataFormatTSVE), + string(EventHubDataFormatTXT), + string(EventHubDataFormatWThreeCLOGFILE), + } +} + +func (s *EventHubDataFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEventHubDataFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEventHubDataFormat(input string) (*EventHubDataFormat, error) { + vals := map[string]EventHubDataFormat{ + "apacheavro": EventHubDataFormatAPACHEAVRO, + "avro": EventHubDataFormatAVRO, + "csv": EventHubDataFormatCSV, + "json": EventHubDataFormatJSON, + "multijson": EventHubDataFormatMULTIJSON, + "orc": EventHubDataFormatORC, + "parquet": EventHubDataFormatPARQUET, + "psv": EventHubDataFormatPSV, + "raw": EventHubDataFormatRAW, + "scsv": EventHubDataFormatSCSV, + "singlejson": EventHubDataFormatSINGLEJSON, + "sohsv": EventHubDataFormatSOHSV, + "tsv": EventHubDataFormatTSV, + "tsve": EventHubDataFormatTSVE, + "txt": EventHubDataFormatTXT, + "w3clogfile": EventHubDataFormatWThreeCLOGFILE, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EventHubDataFormat(input) + return &out, nil +} + +type IotHubDataFormat string + +const ( + IotHubDataFormatAPACHEAVRO IotHubDataFormat = "APACHEAVRO" + IotHubDataFormatAVRO IotHubDataFormat = "AVRO" + IotHubDataFormatCSV IotHubDataFormat = "CSV" + IotHubDataFormatJSON IotHubDataFormat = "JSON" + IotHubDataFormatMULTIJSON IotHubDataFormat = "MULTIJSON" + IotHubDataFormatORC IotHubDataFormat = "ORC" + IotHubDataFormatPARQUET IotHubDataFormat = "PARQUET" + IotHubDataFormatPSV IotHubDataFormat = "PSV" + IotHubDataFormatRAW IotHubDataFormat = "RAW" + IotHubDataFormatSCSV IotHubDataFormat = "SCSV" + IotHubDataFormatSINGLEJSON IotHubDataFormat = "SINGLEJSON" + IotHubDataFormatSOHSV IotHubDataFormat = "SOHSV" + IotHubDataFormatTSV IotHubDataFormat = "TSV" + IotHubDataFormatTSVE IotHubDataFormat = "TSVE" + IotHubDataFormatTXT IotHubDataFormat = "TXT" + IotHubDataFormatWThreeCLOGFILE IotHubDataFormat = "W3CLOGFILE" +) + +func PossibleValuesForIotHubDataFormat() []string { + return []string{ + string(IotHubDataFormatAPACHEAVRO), + string(IotHubDataFormatAVRO), + string(IotHubDataFormatCSV), + string(IotHubDataFormatJSON), + string(IotHubDataFormatMULTIJSON), + string(IotHubDataFormatORC), + string(IotHubDataFormatPARQUET), + string(IotHubDataFormatPSV), + string(IotHubDataFormatRAW), + string(IotHubDataFormatSCSV), + string(IotHubDataFormatSINGLEJSON), + string(IotHubDataFormatSOHSV), + string(IotHubDataFormatTSV), + string(IotHubDataFormatTSVE), + string(IotHubDataFormatTXT), + string(IotHubDataFormatWThreeCLOGFILE), + } +} + +func (s *IotHubDataFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIotHubDataFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIotHubDataFormat(input string) (*IotHubDataFormat, error) { + vals := map[string]IotHubDataFormat{ + "apacheavro": IotHubDataFormatAPACHEAVRO, + "avro": IotHubDataFormatAVRO, + "csv": IotHubDataFormatCSV, + "json": IotHubDataFormatJSON, + "multijson": IotHubDataFormatMULTIJSON, + "orc": IotHubDataFormatORC, + "parquet": IotHubDataFormatPARQUET, + "psv": IotHubDataFormatPSV, + "raw": IotHubDataFormatRAW, + "scsv": IotHubDataFormatSCSV, + "singlejson": IotHubDataFormatSINGLEJSON, + "sohsv": IotHubDataFormatSOHSV, + "tsv": IotHubDataFormatTSV, + "tsve": IotHubDataFormatTSVE, + "txt": IotHubDataFormatTXT, + "w3clogfile": IotHubDataFormatWThreeCLOGFILE, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IotHubDataFormat(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateMoving ProvisioningState = "Moving" + ProvisioningStateRunning ProvisioningState = "Running" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateMoving), + string(ProvisioningStateRunning), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "moving": ProvisioningStateMoving, + "running": ProvisioningStateRunning, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type Reason string + +const ( + ReasonAlreadyExists Reason = "AlreadyExists" + ReasonInvalid Reason = "Invalid" +) + +func PossibleValuesForReason() []string { + return []string{ + string(ReasonAlreadyExists), + string(ReasonInvalid), + } +} + +func (s *Reason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReason(input string) (*Reason, error) { + vals := map[string]Reason{ + "alreadyexists": ReasonAlreadyExists, + "invalid": ReasonInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Reason(input) + return &out, nil +} diff --git a/resource-manager/kusto/2024-04-13/dataconnections/id_dataconnection.go b/resource-manager/kusto/2024-04-13/dataconnections/id_dataconnection.go new file mode 100644 index 00000000000..f7af43c5cc0 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/id_dataconnection.go @@ -0,0 +1,148 @@ +package dataconnections + +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(&DataConnectionId{}) +} + +var _ resourceids.ResourceId = &DataConnectionId{} + +// DataConnectionId is a struct representing the Resource ID for a Data Connection +type DataConnectionId struct { + SubscriptionId string + ResourceGroupName string + ClusterName string + DatabaseName string + DataConnectionName string +} + +// NewDataConnectionID returns a new DataConnectionId struct +func NewDataConnectionID(subscriptionId string, resourceGroupName string, clusterName string, databaseName string, dataConnectionName string) DataConnectionId { + return DataConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ClusterName: clusterName, + DatabaseName: databaseName, + DataConnectionName: dataConnectionName, + } +} + +// ParseDataConnectionID parses 'input' into a DataConnectionId +func ParseDataConnectionID(input string) (*DataConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDataConnectionIDInsensitively parses 'input' case-insensitively into a DataConnectionId +// note: this method should only be used for API response data and not user input +func ParseDataConnectionIDInsensitively(input string) (*DataConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DataConnectionId) 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.ClusterName, ok = input.Parsed["clusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "clusterName", input) + } + + if id.DatabaseName, ok = input.Parsed["databaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseName", input) + } + + if id.DataConnectionName, ok = input.Parsed["dataConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dataConnectionName", input) + } + + return nil +} + +// ValidateDataConnectionID checks that 'input' can be parsed as a Data Connection ID +func ValidateDataConnectionID(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 := ParseDataConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Data Connection ID +func (id DataConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Kusto/clusters/%s/databases/%s/dataConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName, id.DatabaseName, id.DataConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Data Connection ID +func (id DataConnectionId) 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("staticMicrosoftKusto", "Microsoft.Kusto", "Microsoft.Kusto"), + resourceids.StaticSegment("staticClusters", "clusters", "clusters"), + resourceids.UserSpecifiedSegment("clusterName", "clusterName"), + resourceids.StaticSegment("staticDatabases", "databases", "databases"), + resourceids.UserSpecifiedSegment("databaseName", "databaseName"), + resourceids.StaticSegment("staticDataConnections", "dataConnections", "dataConnections"), + resourceids.UserSpecifiedSegment("dataConnectionName", "dataConnectionName"), + } +} + +// String returns a human-readable description of this Data Connection ID +func (id DataConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cluster Name: %q", id.ClusterName), + fmt.Sprintf("Database Name: %q", id.DatabaseName), + fmt.Sprintf("Data Connection Name: %q", id.DataConnectionName), + } + return fmt.Sprintf("Data Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/kusto/2024-04-13/dataconnections/id_dataconnection_test.go b/resource-manager/kusto/2024-04-13/dataconnections/id_dataconnection_test.go new file mode 100644 index 00000000000..da57295c0c5 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/id_dataconnection_test.go @@ -0,0 +1,372 @@ +package dataconnections + +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 = &DataConnectionId{} + +func TestNewDataConnectionID(t *testing.T) { + id := NewDataConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName", "dataConnectionName") + + 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.ClusterName != "clusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterName") + } + + if id.DatabaseName != "databaseName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseName'", id.DatabaseName, "databaseName") + } + + if id.DataConnectionName != "dataConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'DataConnectionName'", id.DataConnectionName, "dataConnectionName") + } +} + +func TestFormatDataConnectionID(t *testing.T) { + actual := NewDataConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName", "dataConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName/dataConnections/dataConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDataConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName/dataConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName/dataConnections/dataConnectionName", + Expected: &DataConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + DatabaseName: "databaseName", + DataConnectionName: "dataConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName/dataConnections/dataConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataConnectionID(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.DatabaseName != v.Expected.DatabaseName { + t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) + } + + if actual.DataConnectionName != v.Expected.DataConnectionName { + t.Fatalf("Expected %q but got %q for DataConnectionName", v.Expected.DataConnectionName, actual.DataConnectionName) + } + + } +} + +func TestParseDataConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/dAtAbAsEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/dAtAbAsEs/dAtAbAsEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName/dataConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/dAtAbAsEs/dAtAbAsEnAmE/dAtAcOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName/dataConnections/dataConnectionName", + Expected: &DataConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + DatabaseName: "databaseName", + DataConnectionName: "dataConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName/dataConnections/dataConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/dAtAbAsEs/dAtAbAsEnAmE/dAtAcOnNeCtIoNs/dAtAcOnNeCtIoNnAmE", + Expected: &DataConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ClusterName: "cLuStErNaMe", + DatabaseName: "dAtAbAsEnAmE", + DataConnectionName: "dAtAcOnNeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/dAtAbAsEs/dAtAbAsEnAmE/dAtAcOnNeCtIoNs/dAtAcOnNeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataConnectionIDInsensitively(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.DatabaseName != v.Expected.DatabaseName { + t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) + } + + if actual.DataConnectionName != v.Expected.DataConnectionName { + t.Fatalf("Expected %q but got %q for DataConnectionName", v.Expected.DataConnectionName, actual.DataConnectionName) + } + + } +} + +func TestSegmentsForDataConnectionId(t *testing.T) { + segments := DataConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DataConnectionId 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/kusto/2024-04-13/dataconnections/method_checknameavailability.go b/resource-manager/kusto/2024-04-13/dataconnections/method_checknameavailability.go new file mode 100644 index 00000000000..b82af8b2538 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/method_checknameavailability.go @@ -0,0 +1,59 @@ +package dataconnections + +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 CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameResult +} + +// CheckNameAvailability ... +func (c DataConnectionsClient) CheckNameAvailability(ctx context.Context, id commonids.KustoDatabaseId, input DataConnectionCheckNameRequest) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkNameAvailability", 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 CheckNameResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/dataconnections/method_createorupdate.go b/resource-manager/kusto/2024-04-13/dataconnections/method_createorupdate.go new file mode 100644 index 00000000000..ea405aa6c14 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/method_createorupdate.go @@ -0,0 +1,76 @@ +package dataconnections + +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 DataConnection +} + +// CreateOrUpdate ... +func (c DataConnectionsClient) CreateOrUpdate(ctx context.Context, id DataConnectionId, input DataConnection) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c DataConnectionsClient) CreateOrUpdateThenPoll(ctx context.Context, id DataConnectionId, input DataConnection) 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/kusto/2024-04-13/dataconnections/method_dataconnectionvalidation.go b/resource-manager/kusto/2024-04-13/dataconnections/method_dataconnectionvalidation.go new file mode 100644 index 00000000000..4f4e7a9488d --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/method_dataconnectionvalidation.go @@ -0,0 +1,76 @@ +package dataconnections + +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 DataConnectionValidationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DataConnectionValidationListResult +} + +// DataConnectionValidation ... +func (c DataConnectionsClient) DataConnectionValidation(ctx context.Context, id commonids.KustoDatabaseId, input DataConnectionValidation) (result DataConnectionValidationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/dataConnectionValidation", 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 +} + +// DataConnectionValidationThenPoll performs DataConnectionValidation then polls until it's completed +func (c DataConnectionsClient) DataConnectionValidationThenPoll(ctx context.Context, id commonids.KustoDatabaseId, input DataConnectionValidation) error { + result, err := c.DataConnectionValidation(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DataConnectionValidation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DataConnectionValidation: %+v", err) + } + + return nil +} diff --git a/resource-manager/kusto/2024-04-13/dataconnections/method_delete.go b/resource-manager/kusto/2024-04-13/dataconnections/method_delete.go new file mode 100644 index 00000000000..22539c4c00e --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/method_delete.go @@ -0,0 +1,71 @@ +package dataconnections + +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 DataConnectionsClient) Delete(ctx context.Context, id DataConnectionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c DataConnectionsClient) DeleteThenPoll(ctx context.Context, id DataConnectionId) 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/kusto/2024-04-13/dataconnections/method_get.go b/resource-manager/kusto/2024-04-13/dataconnections/method_get.go new file mode 100644 index 00000000000..a1e4482154d --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/method_get.go @@ -0,0 +1,58 @@ +package dataconnections + +import ( + "context" + "encoding/json" + "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 DataConnection +} + +// Get ... +func (c DataConnectionsClient) Get(ctx context.Context, id DataConnectionId) (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 respObj json.RawMessage + if err = resp.Unmarshal(&respObj); err != nil { + return + } + model, err := UnmarshalDataConnectionImplementation(respObj) + if err != nil { + return + } + result.Model = model + + return +} diff --git a/resource-manager/kusto/2024-04-13/dataconnections/method_listbydatabase.go b/resource-manager/kusto/2024-04-13/dataconnections/method_listbydatabase.go new file mode 100644 index 00000000000..3ef4cd6af4e --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/method_listbydatabase.go @@ -0,0 +1,55 @@ +package dataconnections + +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 ListByDatabaseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DataConnectionListResult +} + +// ListByDatabase ... +func (c DataConnectionsClient) ListByDatabase(ctx context.Context, id commonids.KustoDatabaseId) (result ListByDatabaseOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/dataConnections", 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 DataConnectionListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/dataconnections/method_update.go b/resource-manager/kusto/2024-04-13/dataconnections/method_update.go new file mode 100644 index 00000000000..f45185a1307 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/method_update.go @@ -0,0 +1,76 @@ +package dataconnections + +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 DataConnection +} + +// Update ... +func (c DataConnectionsClient) Update(ctx context.Context, id DataConnectionId, input DataConnection) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + 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 DataConnectionsClient) UpdateThenPoll(ctx context.Context, id DataConnectionId, input DataConnection) 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/kusto/2024-04-13/dataconnections/model_checknameresult.go b/resource-manager/kusto/2024-04-13/dataconnections/model_checknameresult.go new file mode 100644 index 00000000000..68ee492fcf1 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/model_checknameresult.go @@ -0,0 +1,11 @@ +package dataconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameResult struct { + Message *string `json:"message,omitempty"` + Name *string `json:"name,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *Reason `json:"reason,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/dataconnections/model_cosmosdbdataconnection.go b/resource-manager/kusto/2024-04-13/dataconnections/model_cosmosdbdataconnection.go new file mode 100644 index 00000000000..06f15af3ac1 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/model_cosmosdbdataconnection.go @@ -0,0 +1,58 @@ +package dataconnections + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DataConnection = CosmosDbDataConnection{} + +type CosmosDbDataConnection struct { + Properties *CosmosDbDataConnectionProperties `json:"properties,omitempty"` + + // Fields inherited from DataConnection + + Id *string `json:"id,omitempty"` + Kind DataConnectionKind `json:"kind"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +func (s CosmosDbDataConnection) DataConnection() BaseDataConnectionImpl { + return BaseDataConnectionImpl{ + Id: s.Id, + Kind: s.Kind, + Location: s.Location, + Name: s.Name, + Type: s.Type, + } +} + +var _ json.Marshaler = CosmosDbDataConnection{} + +func (s CosmosDbDataConnection) MarshalJSON() ([]byte, error) { + type wrapper CosmosDbDataConnection + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CosmosDbDataConnection: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CosmosDbDataConnection: %+v", err) + } + + decoded["kind"] = "CosmosDb" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CosmosDbDataConnection: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/kusto/2024-04-13/dataconnections/model_cosmosdbdataconnectionproperties.go b/resource-manager/kusto/2024-04-13/dataconnections/model_cosmosdbdataconnectionproperties.go new file mode 100644 index 00000000000..4d03334cc52 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/model_cosmosdbdataconnectionproperties.go @@ -0,0 +1,34 @@ +package dataconnections + +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 CosmosDbDataConnectionProperties struct { + CosmosDbAccountResourceId string `json:"cosmosDbAccountResourceId"` + CosmosDbContainer string `json:"cosmosDbContainer"` + CosmosDbDatabase string `json:"cosmosDbDatabase"` + ManagedIdentityObjectId *string `json:"managedIdentityObjectId,omitempty"` + ManagedIdentityResourceId string `json:"managedIdentityResourceId"` + MappingRuleName *string `json:"mappingRuleName,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetrievalStartDate *string `json:"retrievalStartDate,omitempty"` + TableName string `json:"tableName"` +} + +func (o *CosmosDbDataConnectionProperties) GetRetrievalStartDateAsTime() (*time.Time, error) { + if o.RetrievalStartDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RetrievalStartDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CosmosDbDataConnectionProperties) SetRetrievalStartDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RetrievalStartDate = &formatted +} diff --git a/resource-manager/kusto/2024-04-13/dataconnections/model_dataconnection.go b/resource-manager/kusto/2024-04-13/dataconnections/model_dataconnection.go new file mode 100644 index 00000000000..c254a7b871c --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/model_dataconnection.go @@ -0,0 +1,103 @@ +package dataconnections + +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 DataConnection interface { + DataConnection() BaseDataConnectionImpl +} + +var _ DataConnection = BaseDataConnectionImpl{} + +type BaseDataConnectionImpl struct { + Id *string `json:"id,omitempty"` + Kind DataConnectionKind `json:"kind"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +func (s BaseDataConnectionImpl) DataConnection() BaseDataConnectionImpl { + return s +} + +var _ DataConnection = RawDataConnectionImpl{} + +// RawDataConnectionImpl 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 RawDataConnectionImpl struct { + dataConnection BaseDataConnectionImpl + Type string + Values map[string]interface{} +} + +func (s RawDataConnectionImpl) DataConnection() BaseDataConnectionImpl { + return s.dataConnection +} + +func UnmarshalDataConnectionImplementation(input []byte) (DataConnection, 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 DataConnection into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["kind"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "CosmosDb") { + var out CosmosDbDataConnection + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CosmosDbDataConnection: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "EventGrid") { + var out EventGridDataConnection + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into EventGridDataConnection: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "EventHub") { + var out EventHubDataConnection + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into EventHubDataConnection: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IotHub") { + var out IotHubDataConnection + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IotHubDataConnection: %+v", err) + } + return out, nil + } + + var parent BaseDataConnectionImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseDataConnectionImpl: %+v", err) + } + + return RawDataConnectionImpl{ + dataConnection: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/kusto/2024-04-13/dataconnections/model_dataconnectionchecknamerequest.go b/resource-manager/kusto/2024-04-13/dataconnections/model_dataconnectionchecknamerequest.go new file mode 100644 index 00000000000..10c0c2b2f43 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/model_dataconnectionchecknamerequest.go @@ -0,0 +1,9 @@ +package dataconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataConnectionCheckNameRequest struct { + Name string `json:"name"` + Type DataConnectionType `json:"type"` +} diff --git a/resource-manager/kusto/2024-04-13/dataconnections/model_dataconnectionlistresult.go b/resource-manager/kusto/2024-04-13/dataconnections/model_dataconnectionlistresult.go new file mode 100644 index 00000000000..6a645fcce93 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/model_dataconnectionlistresult.go @@ -0,0 +1,42 @@ +package dataconnections + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataConnectionListResult struct { + Value *[]DataConnection `json:"value,omitempty"` +} + +var _ json.Unmarshaler = &DataConnectionListResult{} + +func (s *DataConnectionListResult) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling DataConnectionListResult into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["value"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling Value into list []json.RawMessage: %+v", err) + } + + output := make([]DataConnection, 0) + for i, val := range listTemp { + impl, err := UnmarshalDataConnectionImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'Value' for 'DataConnectionListResult': %+v", i, err) + } + output = append(output, impl) + } + s.Value = &output + } + + return nil +} diff --git a/resource-manager/kusto/2024-04-13/dataconnections/model_dataconnectionvalidation.go b/resource-manager/kusto/2024-04-13/dataconnections/model_dataconnectionvalidation.go new file mode 100644 index 00000000000..3361aee987c --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/model_dataconnectionvalidation.go @@ -0,0 +1,42 @@ +package dataconnections + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataConnectionValidation struct { + DataConnectionName *string `json:"dataConnectionName,omitempty"` + Properties DataConnection `json:"properties"` +} + +var _ json.Unmarshaler = &DataConnectionValidation{} + +func (s *DataConnectionValidation) UnmarshalJSON(bytes []byte) error { + var decoded struct { + DataConnectionName *string `json:"dataConnectionName,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.DataConnectionName = decoded.DataConnectionName + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling DataConnectionValidation into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalDataConnectionImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'DataConnectionValidation': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/kusto/2024-04-13/dataconnections/model_dataconnectionvalidationlistresult.go b/resource-manager/kusto/2024-04-13/dataconnections/model_dataconnectionvalidationlistresult.go new file mode 100644 index 00000000000..f73b6da6cd4 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/model_dataconnectionvalidationlistresult.go @@ -0,0 +1,8 @@ +package dataconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataConnectionValidationListResult struct { + Value *[]DataConnectionValidationResult `json:"value,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/dataconnections/model_dataconnectionvalidationresult.go b/resource-manager/kusto/2024-04-13/dataconnections/model_dataconnectionvalidationresult.go new file mode 100644 index 00000000000..df19e8199ef --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/model_dataconnectionvalidationresult.go @@ -0,0 +1,8 @@ +package dataconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataConnectionValidationResult struct { + ErrorMessage *string `json:"errorMessage,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/dataconnections/model_eventgridconnectionproperties.go b/resource-manager/kusto/2024-04-13/dataconnections/model_eventgridconnectionproperties.go new file mode 100644 index 00000000000..d489ab01307 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/model_eventgridconnectionproperties.go @@ -0,0 +1,20 @@ +package dataconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EventGridConnectionProperties struct { + BlobStorageEventType *BlobStorageEventType `json:"blobStorageEventType,omitempty"` + ConsumerGroup string `json:"consumerGroup"` + DataFormat *EventGridDataFormat `json:"dataFormat,omitempty"` + DatabaseRouting *DatabaseRouting `json:"databaseRouting,omitempty"` + EventGridResourceId *string `json:"eventGridResourceId,omitempty"` + EventHubResourceId string `json:"eventHubResourceId"` + IgnoreFirstRecord *bool `json:"ignoreFirstRecord,omitempty"` + ManagedIdentityObjectId *string `json:"managedIdentityObjectId,omitempty"` + ManagedIdentityResourceId *string `json:"managedIdentityResourceId,omitempty"` + MappingRuleName *string `json:"mappingRuleName,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + StorageAccountResourceId string `json:"storageAccountResourceId"` + TableName *string `json:"tableName,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/dataconnections/model_eventgriddataconnection.go b/resource-manager/kusto/2024-04-13/dataconnections/model_eventgriddataconnection.go new file mode 100644 index 00000000000..5fd8b60bc3e --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/model_eventgriddataconnection.go @@ -0,0 +1,58 @@ +package dataconnections + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DataConnection = EventGridDataConnection{} + +type EventGridDataConnection struct { + Properties *EventGridConnectionProperties `json:"properties,omitempty"` + + // Fields inherited from DataConnection + + Id *string `json:"id,omitempty"` + Kind DataConnectionKind `json:"kind"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +func (s EventGridDataConnection) DataConnection() BaseDataConnectionImpl { + return BaseDataConnectionImpl{ + Id: s.Id, + Kind: s.Kind, + Location: s.Location, + Name: s.Name, + Type: s.Type, + } +} + +var _ json.Marshaler = EventGridDataConnection{} + +func (s EventGridDataConnection) MarshalJSON() ([]byte, error) { + type wrapper EventGridDataConnection + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling EventGridDataConnection: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling EventGridDataConnection: %+v", err) + } + + decoded["kind"] = "EventGrid" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling EventGridDataConnection: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/kusto/2024-04-13/dataconnections/model_eventhubconnectionproperties.go b/resource-manager/kusto/2024-04-13/dataconnections/model_eventhubconnectionproperties.go new file mode 100644 index 00000000000..1770878de4a --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/model_eventhubconnectionproperties.go @@ -0,0 +1,37 @@ +package dataconnections + +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 EventHubConnectionProperties struct { + Compression *Compression `json:"compression,omitempty"` + ConsumerGroup string `json:"consumerGroup"` + DataFormat *EventHubDataFormat `json:"dataFormat,omitempty"` + DatabaseRouting *DatabaseRouting `json:"databaseRouting,omitempty"` + EventHubResourceId string `json:"eventHubResourceId"` + EventSystemProperties *[]string `json:"eventSystemProperties,omitempty"` + ManagedIdentityObjectId *string `json:"managedIdentityObjectId,omitempty"` + ManagedIdentityResourceId *string `json:"managedIdentityResourceId,omitempty"` + MappingRuleName *string `json:"mappingRuleName,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetrievalStartDate *string `json:"retrievalStartDate,omitempty"` + TableName *string `json:"tableName,omitempty"` +} + +func (o *EventHubConnectionProperties) GetRetrievalStartDateAsTime() (*time.Time, error) { + if o.RetrievalStartDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RetrievalStartDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *EventHubConnectionProperties) SetRetrievalStartDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RetrievalStartDate = &formatted +} diff --git a/resource-manager/kusto/2024-04-13/dataconnections/model_eventhubdataconnection.go b/resource-manager/kusto/2024-04-13/dataconnections/model_eventhubdataconnection.go new file mode 100644 index 00000000000..cc311f452e2 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/model_eventhubdataconnection.go @@ -0,0 +1,58 @@ +package dataconnections + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DataConnection = EventHubDataConnection{} + +type EventHubDataConnection struct { + Properties *EventHubConnectionProperties `json:"properties,omitempty"` + + // Fields inherited from DataConnection + + Id *string `json:"id,omitempty"` + Kind DataConnectionKind `json:"kind"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +func (s EventHubDataConnection) DataConnection() BaseDataConnectionImpl { + return BaseDataConnectionImpl{ + Id: s.Id, + Kind: s.Kind, + Location: s.Location, + Name: s.Name, + Type: s.Type, + } +} + +var _ json.Marshaler = EventHubDataConnection{} + +func (s EventHubDataConnection) MarshalJSON() ([]byte, error) { + type wrapper EventHubDataConnection + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling EventHubDataConnection: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling EventHubDataConnection: %+v", err) + } + + decoded["kind"] = "EventHub" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling EventHubDataConnection: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/kusto/2024-04-13/dataconnections/model_iothubconnectionproperties.go b/resource-manager/kusto/2024-04-13/dataconnections/model_iothubconnectionproperties.go new file mode 100644 index 00000000000..315a2258ef6 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/model_iothubconnectionproperties.go @@ -0,0 +1,35 @@ +package dataconnections + +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 IotHubConnectionProperties struct { + ConsumerGroup string `json:"consumerGroup"` + DataFormat *IotHubDataFormat `json:"dataFormat,omitempty"` + DatabaseRouting *DatabaseRouting `json:"databaseRouting,omitempty"` + EventSystemProperties *[]string `json:"eventSystemProperties,omitempty"` + IotHubResourceId string `json:"iotHubResourceId"` + MappingRuleName *string `json:"mappingRuleName,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetrievalStartDate *string `json:"retrievalStartDate,omitempty"` + SharedAccessPolicyName string `json:"sharedAccessPolicyName"` + TableName *string `json:"tableName,omitempty"` +} + +func (o *IotHubConnectionProperties) GetRetrievalStartDateAsTime() (*time.Time, error) { + if o.RetrievalStartDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RetrievalStartDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *IotHubConnectionProperties) SetRetrievalStartDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RetrievalStartDate = &formatted +} diff --git a/resource-manager/kusto/2024-04-13/dataconnections/model_iothubdataconnection.go b/resource-manager/kusto/2024-04-13/dataconnections/model_iothubdataconnection.go new file mode 100644 index 00000000000..ed2d9ec9054 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/model_iothubdataconnection.go @@ -0,0 +1,58 @@ +package dataconnections + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DataConnection = IotHubDataConnection{} + +type IotHubDataConnection struct { + Properties *IotHubConnectionProperties `json:"properties,omitempty"` + + // Fields inherited from DataConnection + + Id *string `json:"id,omitempty"` + Kind DataConnectionKind `json:"kind"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +func (s IotHubDataConnection) DataConnection() BaseDataConnectionImpl { + return BaseDataConnectionImpl{ + Id: s.Id, + Kind: s.Kind, + Location: s.Location, + Name: s.Name, + Type: s.Type, + } +} + +var _ json.Marshaler = IotHubDataConnection{} + +func (s IotHubDataConnection) MarshalJSON() ([]byte, error) { + type wrapper IotHubDataConnection + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IotHubDataConnection: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IotHubDataConnection: %+v", err) + } + + decoded["kind"] = "IotHub" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IotHubDataConnection: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/kusto/2024-04-13/dataconnections/version.go b/resource-manager/kusto/2024-04-13/dataconnections/version.go new file mode 100644 index 00000000000..5b96c205c8f --- /dev/null +++ b/resource-manager/kusto/2024-04-13/dataconnections/version.go @@ -0,0 +1,10 @@ +package dataconnections + +// 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-04-13" + +func userAgent() string { + return "hashicorp/go-azure-sdk/dataconnections/2024-04-13" +} diff --git a/resource-manager/kusto/2024-04-13/kusto/README.md b/resource-manager/kusto/2024-04-13/kusto/README.md new file mode 100644 index 00000000000..5fb4c544718 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/kusto/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/kusto` Documentation + +The `kusto` SDK allows for interaction with Azure Resource Manager `kusto` (API Version `2024-04-13`). + +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/kusto/2024-04-13/kusto" +``` + + +### Client Initialization + +```go +client := kusto.NewKustoClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `KustoClient.ClustersListSkus` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.ClustersListSkus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `KustoClient.SkusList` + +```go +ctx := context.TODO() +id := kusto.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +read, err := client.SkusList(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/kusto/2024-04-13/kusto/client.go b/resource-manager/kusto/2024-04-13/kusto/client.go new file mode 100644 index 00000000000..34e3605a09d --- /dev/null +++ b/resource-manager/kusto/2024-04-13/kusto/client.go @@ -0,0 +1,26 @@ +package kusto + +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 KustoClient struct { + Client *resourcemanager.Client +} + +func NewKustoClientWithBaseURI(sdkApi sdkEnv.Api) (*KustoClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "kusto", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating KustoClient: %+v", err) + } + + return &KustoClient{ + Client: client, + }, nil +} diff --git a/resource-manager/kusto/2024-04-13/kusto/id_location.go b/resource-manager/kusto/2024-04-13/kusto/id_location.go new file mode 100644 index 00000000000..95b29f0e783 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/kusto/id_location.go @@ -0,0 +1,121 @@ +package kusto + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Kusto/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("staticMicrosoftKusto", "Microsoft.Kusto", "Microsoft.Kusto"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// 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/kusto/2024-04-13/kusto/id_location_test.go b/resource-manager/kusto/2024-04-13/kusto/id_location_test.go new file mode 100644 index 00000000000..f2b8171a641 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/kusto/id_location_test.go @@ -0,0 +1,237 @@ +package kusto + +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", "locationName") + + 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 != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Kusto/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Kusto", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Kusto/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Kusto/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Kusto/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Kusto", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kUsTo", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Kusto/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kUsTo/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Kusto/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Kusto/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kUsTo/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.kUsTo/lOcAtIoNs/lOcAtIoNnAmE/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/kusto/2024-04-13/kusto/method_clusterslistskus.go b/resource-manager/kusto/2024-04-13/kusto/method_clusterslistskus.go new file mode 100644 index 00000000000..90806872300 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/kusto/method_clusterslistskus.go @@ -0,0 +1,55 @@ +package kusto + +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 ClustersListSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SkuDescriptionList +} + +// ClustersListSkus ... +func (c KustoClient) ClustersListSkus(ctx context.Context, id commonids.SubscriptionId) (result ClustersListSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Kusto/skus", 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 SkuDescriptionList + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/kusto/method_skuslist.go b/resource-manager/kusto/2024-04-13/kusto/method_skuslist.go new file mode 100644 index 00000000000..2025a2400d3 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/kusto/method_skuslist.go @@ -0,0 +1,54 @@ +package kusto + +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 SkusListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SkuDescriptionList +} + +// SkusList ... +func (c KustoClient) SkusList(ctx context.Context, id LocationId) (result SkusListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/skus", 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 SkuDescriptionList + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/kusto/model_resourceskucapabilities.go b/resource-manager/kusto/2024-04-13/kusto/model_resourceskucapabilities.go new file mode 100644 index 00000000000..6053c0d68d6 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/kusto/model_resourceskucapabilities.go @@ -0,0 +1,9 @@ +package kusto + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSkuCapabilities struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/kusto/model_resourceskuzonedetails.go b/resource-manager/kusto/2024-04-13/kusto/model_resourceskuzonedetails.go new file mode 100644 index 00000000000..d64241c8f9c --- /dev/null +++ b/resource-manager/kusto/2024-04-13/kusto/model_resourceskuzonedetails.go @@ -0,0 +1,9 @@ +package kusto + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSkuZoneDetails struct { + Capabilities *[]ResourceSkuCapabilities `json:"capabilities,omitempty"` + Name *[]string `json:"name,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/kusto/model_skudescription.go b/resource-manager/kusto/2024-04-13/kusto/model_skudescription.go new file mode 100644 index 00000000000..a51e20b50fb --- /dev/null +++ b/resource-manager/kusto/2024-04-13/kusto/model_skudescription.go @@ -0,0 +1,13 @@ +package kusto + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuDescription struct { + LocationInfo *[]SkuLocationInfoItem `json:"locationInfo,omitempty"` + Locations *[]string `json:"locations,omitempty"` + Name *string `json:"name,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + Restrictions *[]interface{} `json:"restrictions,omitempty"` + Tier *string `json:"tier,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/kusto/model_skudescriptionlist.go b/resource-manager/kusto/2024-04-13/kusto/model_skudescriptionlist.go new file mode 100644 index 00000000000..6d8d2d0b23c --- /dev/null +++ b/resource-manager/kusto/2024-04-13/kusto/model_skudescriptionlist.go @@ -0,0 +1,8 @@ +package kusto + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuDescriptionList struct { + Value *[]SkuDescription `json:"value,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/kusto/model_skulocationinfoitem.go b/resource-manager/kusto/2024-04-13/kusto/model_skulocationinfoitem.go new file mode 100644 index 00000000000..71648ddd535 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/kusto/model_skulocationinfoitem.go @@ -0,0 +1,14 @@ +package kusto + +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 SkuLocationInfoItem struct { + Location string `json:"location"` + ZoneDetails *[]ResourceSkuZoneDetails `json:"zoneDetails,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/kusto/version.go b/resource-manager/kusto/2024-04-13/kusto/version.go new file mode 100644 index 00000000000..9daba6580b7 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/kusto/version.go @@ -0,0 +1,10 @@ +package kusto + +// 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-04-13" + +func userAgent() string { + return "hashicorp/go-azure-sdk/kusto/2024-04-13" +} diff --git a/resource-manager/kusto/2024-04-13/managedprivateendpoints/README.md b/resource-manager/kusto/2024-04-13/managedprivateendpoints/README.md new file mode 100644 index 00000000000..3846972346e --- /dev/null +++ b/resource-manager/kusto/2024-04-13/managedprivateendpoints/README.md @@ -0,0 +1,120 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/managedprivateendpoints` Documentation + +The `managedprivateendpoints` SDK allows for interaction with Azure Resource Manager `kusto` (API Version `2024-04-13`). + +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/kusto/2024-04-13/managedprivateendpoints" +``` + + +### Client Initialization + +```go +client := managedprivateendpoints.NewManagedPrivateEndpointsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedPrivateEndpointsClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +payload := managedprivateendpoints.ManagedPrivateEndpointsCheckNameRequest{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedPrivateEndpointsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := managedprivateendpoints.NewManagedPrivateEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "managedPrivateEndpointName") + +payload := managedprivateendpoints.ManagedPrivateEndpoint{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedPrivateEndpointsClient.Delete` + +```go +ctx := context.TODO() +id := managedprivateendpoints.NewManagedPrivateEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "managedPrivateEndpointName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedPrivateEndpointsClient.Get` + +```go +ctx := context.TODO() +id := managedprivateendpoints.NewManagedPrivateEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "managedPrivateEndpointName") + +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: `ManagedPrivateEndpointsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +read, err := client.List(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedPrivateEndpointsClient.Update` + +```go +ctx := context.TODO() +id := managedprivateendpoints.NewManagedPrivateEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "managedPrivateEndpointName") + +payload := managedprivateendpoints.ManagedPrivateEndpoint{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/kusto/2024-04-13/managedprivateendpoints/client.go b/resource-manager/kusto/2024-04-13/managedprivateendpoints/client.go new file mode 100644 index 00000000000..e02237558e4 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/managedprivateendpoints/client.go @@ -0,0 +1,26 @@ +package managedprivateendpoints + +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 ManagedPrivateEndpointsClient struct { + Client *resourcemanager.Client +} + +func NewManagedPrivateEndpointsClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedPrivateEndpointsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "managedprivateendpoints", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedPrivateEndpointsClient: %+v", err) + } + + return &ManagedPrivateEndpointsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/kusto/2024-04-13/managedprivateendpoints/constants.go b/resource-manager/kusto/2024-04-13/managedprivateendpoints/constants.go new file mode 100644 index 00000000000..2673f5e7f30 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/managedprivateendpoints/constants.go @@ -0,0 +1,145 @@ +package managedprivateendpoints + +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 ManagedPrivateEndpointsType string + +const ( + ManagedPrivateEndpointsTypeMicrosoftPointKustoClustersManagedPrivateEndpoints ManagedPrivateEndpointsType = "Microsoft.Kusto/clusters/managedPrivateEndpoints" +) + +func PossibleValuesForManagedPrivateEndpointsType() []string { + return []string{ + string(ManagedPrivateEndpointsTypeMicrosoftPointKustoClustersManagedPrivateEndpoints), + } +} + +func (s *ManagedPrivateEndpointsType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedPrivateEndpointsType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedPrivateEndpointsType(input string) (*ManagedPrivateEndpointsType, error) { + vals := map[string]ManagedPrivateEndpointsType{ + "microsoft.kusto/clusters/managedprivateendpoints": ManagedPrivateEndpointsTypeMicrosoftPointKustoClustersManagedPrivateEndpoints, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedPrivateEndpointsType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateMoving ProvisioningState = "Moving" + ProvisioningStateRunning ProvisioningState = "Running" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateMoving), + string(ProvisioningStateRunning), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "moving": ProvisioningStateMoving, + "running": ProvisioningStateRunning, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type Reason string + +const ( + ReasonAlreadyExists Reason = "AlreadyExists" + ReasonInvalid Reason = "Invalid" +) + +func PossibleValuesForReason() []string { + return []string{ + string(ReasonAlreadyExists), + string(ReasonInvalid), + } +} + +func (s *Reason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReason(input string) (*Reason, error) { + vals := map[string]Reason{ + "alreadyexists": ReasonAlreadyExists, + "invalid": ReasonInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Reason(input) + return &out, nil +} diff --git a/resource-manager/kusto/2024-04-13/managedprivateendpoints/id_managedprivateendpoint.go b/resource-manager/kusto/2024-04-13/managedprivateendpoints/id_managedprivateendpoint.go new file mode 100644 index 00000000000..d6ad8095bff --- /dev/null +++ b/resource-manager/kusto/2024-04-13/managedprivateendpoints/id_managedprivateendpoint.go @@ -0,0 +1,139 @@ +package managedprivateendpoints + +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(&ManagedPrivateEndpointId{}) +} + +var _ resourceids.ResourceId = &ManagedPrivateEndpointId{} + +// ManagedPrivateEndpointId is a struct representing the Resource ID for a Managed Private Endpoint +type ManagedPrivateEndpointId struct { + SubscriptionId string + ResourceGroupName string + ClusterName string + ManagedPrivateEndpointName string +} + +// NewManagedPrivateEndpointID returns a new ManagedPrivateEndpointId struct +func NewManagedPrivateEndpointID(subscriptionId string, resourceGroupName string, clusterName string, managedPrivateEndpointName string) ManagedPrivateEndpointId { + return ManagedPrivateEndpointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ClusterName: clusterName, + ManagedPrivateEndpointName: managedPrivateEndpointName, + } +} + +// ParseManagedPrivateEndpointID parses 'input' into a ManagedPrivateEndpointId +func ParseManagedPrivateEndpointID(input string) (*ManagedPrivateEndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedPrivateEndpointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedPrivateEndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagedPrivateEndpointIDInsensitively parses 'input' case-insensitively into a ManagedPrivateEndpointId +// note: this method should only be used for API response data and not user input +func ParseManagedPrivateEndpointIDInsensitively(input string) (*ManagedPrivateEndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedPrivateEndpointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedPrivateEndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagedPrivateEndpointId) 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.ClusterName, ok = input.Parsed["clusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "clusterName", input) + } + + if id.ManagedPrivateEndpointName, ok = input.Parsed["managedPrivateEndpointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedPrivateEndpointName", input) + } + + return nil +} + +// ValidateManagedPrivateEndpointID checks that 'input' can be parsed as a Managed Private Endpoint ID +func ValidateManagedPrivateEndpointID(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 := ParseManagedPrivateEndpointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Managed Private Endpoint ID +func (id ManagedPrivateEndpointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Kusto/clusters/%s/managedPrivateEndpoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName, id.ManagedPrivateEndpointName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Managed Private Endpoint ID +func (id ManagedPrivateEndpointId) 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("staticMicrosoftKusto", "Microsoft.Kusto", "Microsoft.Kusto"), + resourceids.StaticSegment("staticClusters", "clusters", "clusters"), + resourceids.UserSpecifiedSegment("clusterName", "clusterName"), + resourceids.StaticSegment("staticManagedPrivateEndpoints", "managedPrivateEndpoints", "managedPrivateEndpoints"), + resourceids.UserSpecifiedSegment("managedPrivateEndpointName", "managedPrivateEndpointName"), + } +} + +// String returns a human-readable description of this Managed Private Endpoint ID +func (id ManagedPrivateEndpointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cluster Name: %q", id.ClusterName), + fmt.Sprintf("Managed Private Endpoint Name: %q", id.ManagedPrivateEndpointName), + } + return fmt.Sprintf("Managed Private Endpoint (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/kusto/2024-04-13/managedprivateendpoints/id_managedprivateendpoint_test.go b/resource-manager/kusto/2024-04-13/managedprivateendpoints/id_managedprivateendpoint_test.go new file mode 100644 index 00000000000..a7769ac1970 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/managedprivateendpoints/id_managedprivateendpoint_test.go @@ -0,0 +1,327 @@ +package managedprivateendpoints + +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 = &ManagedPrivateEndpointId{} + +func TestNewManagedPrivateEndpointID(t *testing.T) { + id := NewManagedPrivateEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "managedPrivateEndpointName") + + 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.ClusterName != "clusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterName") + } + + if id.ManagedPrivateEndpointName != "managedPrivateEndpointName" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedPrivateEndpointName'", id.ManagedPrivateEndpointName, "managedPrivateEndpointName") + } +} + +func TestFormatManagedPrivateEndpointID(t *testing.T) { + actual := NewManagedPrivateEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "managedPrivateEndpointName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/managedPrivateEndpoints/managedPrivateEndpointName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagedPrivateEndpointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedPrivateEndpointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/managedPrivateEndpoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/managedPrivateEndpoints/managedPrivateEndpointName", + Expected: &ManagedPrivateEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + ManagedPrivateEndpointName: "managedPrivateEndpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/managedPrivateEndpoints/managedPrivateEndpointName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedPrivateEndpointID(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.ManagedPrivateEndpointName != v.Expected.ManagedPrivateEndpointName { + t.Fatalf("Expected %q but got %q for ManagedPrivateEndpointName", v.Expected.ManagedPrivateEndpointName, actual.ManagedPrivateEndpointName) + } + + } +} + +func TestParseManagedPrivateEndpointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedPrivateEndpointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/managedPrivateEndpoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/mAnAgEdPrIvAtEeNdPoInTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/managedPrivateEndpoints/managedPrivateEndpointName", + Expected: &ManagedPrivateEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + ManagedPrivateEndpointName: "managedPrivateEndpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/managedPrivateEndpoints/managedPrivateEndpointName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/mAnAgEdPrIvAtEeNdPoInTs/mAnAgEdPrIvAtEeNdPoInTnAmE", + Expected: &ManagedPrivateEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ClusterName: "cLuStErNaMe", + ManagedPrivateEndpointName: "mAnAgEdPrIvAtEeNdPoInTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/mAnAgEdPrIvAtEeNdPoInTs/mAnAgEdPrIvAtEeNdPoInTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedPrivateEndpointIDInsensitively(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.ManagedPrivateEndpointName != v.Expected.ManagedPrivateEndpointName { + t.Fatalf("Expected %q but got %q for ManagedPrivateEndpointName", v.Expected.ManagedPrivateEndpointName, actual.ManagedPrivateEndpointName) + } + + } +} + +func TestSegmentsForManagedPrivateEndpointId(t *testing.T) { + segments := ManagedPrivateEndpointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagedPrivateEndpointId 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/kusto/2024-04-13/managedprivateendpoints/method_checknameavailability.go b/resource-manager/kusto/2024-04-13/managedprivateendpoints/method_checknameavailability.go new file mode 100644 index 00000000000..06e1c7c5a28 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/managedprivateendpoints/method_checknameavailability.go @@ -0,0 +1,59 @@ +package managedprivateendpoints + +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 CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameResult +} + +// CheckNameAvailability ... +func (c ManagedPrivateEndpointsClient) CheckNameAvailability(ctx context.Context, id commonids.KustoClusterId, input ManagedPrivateEndpointsCheckNameRequest) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/managedPrivateEndpointsCheckNameAvailability", 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 CheckNameResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/managedprivateendpoints/method_createorupdate.go b/resource-manager/kusto/2024-04-13/managedprivateendpoints/method_createorupdate.go new file mode 100644 index 00000000000..6eea13ac3ca --- /dev/null +++ b/resource-manager/kusto/2024-04-13/managedprivateendpoints/method_createorupdate.go @@ -0,0 +1,76 @@ +package managedprivateendpoints + +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 *ManagedPrivateEndpoint +} + +// CreateOrUpdate ... +func (c ManagedPrivateEndpointsClient) CreateOrUpdate(ctx context.Context, id ManagedPrivateEndpointId, input ManagedPrivateEndpoint) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ManagedPrivateEndpointsClient) CreateOrUpdateThenPoll(ctx context.Context, id ManagedPrivateEndpointId, input ManagedPrivateEndpoint) 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/kusto/2024-04-13/managedprivateendpoints/method_delete.go b/resource-manager/kusto/2024-04-13/managedprivateendpoints/method_delete.go new file mode 100644 index 00000000000..98a0990b10a --- /dev/null +++ b/resource-manager/kusto/2024-04-13/managedprivateendpoints/method_delete.go @@ -0,0 +1,71 @@ +package managedprivateendpoints + +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 ManagedPrivateEndpointsClient) Delete(ctx context.Context, id ManagedPrivateEndpointId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ManagedPrivateEndpointsClient) DeleteThenPoll(ctx context.Context, id ManagedPrivateEndpointId) 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/kusto/2024-04-13/managedprivateendpoints/method_get.go b/resource-manager/kusto/2024-04-13/managedprivateendpoints/method_get.go new file mode 100644 index 00000000000..d34ac2dec7b --- /dev/null +++ b/resource-manager/kusto/2024-04-13/managedprivateendpoints/method_get.go @@ -0,0 +1,53 @@ +package managedprivateendpoints + +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 *ManagedPrivateEndpoint +} + +// Get ... +func (c ManagedPrivateEndpointsClient) Get(ctx context.Context, id ManagedPrivateEndpointId) (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 ManagedPrivateEndpoint + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/managedprivateendpoints/method_list.go b/resource-manager/kusto/2024-04-13/managedprivateendpoints/method_list.go new file mode 100644 index 00000000000..acccfe08ca8 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/managedprivateendpoints/method_list.go @@ -0,0 +1,55 @@ +package managedprivateendpoints + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedPrivateEndpointListResult +} + +// List ... +func (c ManagedPrivateEndpointsClient) List(ctx context.Context, id commonids.KustoClusterId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/managedPrivateEndpoints", 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 ManagedPrivateEndpointListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/managedprivateendpoints/method_update.go b/resource-manager/kusto/2024-04-13/managedprivateendpoints/method_update.go new file mode 100644 index 00000000000..34cf97979d6 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/managedprivateendpoints/method_update.go @@ -0,0 +1,75 @@ +package managedprivateendpoints + +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 *ManagedPrivateEndpoint +} + +// Update ... +func (c ManagedPrivateEndpointsClient) Update(ctx context.Context, id ManagedPrivateEndpointId, input ManagedPrivateEndpoint) (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 ManagedPrivateEndpointsClient) UpdateThenPoll(ctx context.Context, id ManagedPrivateEndpointId, input ManagedPrivateEndpoint) 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/kusto/2024-04-13/managedprivateendpoints/model_checknameresult.go b/resource-manager/kusto/2024-04-13/managedprivateendpoints/model_checknameresult.go new file mode 100644 index 00000000000..59c1ab235d2 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/managedprivateendpoints/model_checknameresult.go @@ -0,0 +1,11 @@ +package managedprivateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameResult struct { + Message *string `json:"message,omitempty"` + Name *string `json:"name,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *Reason `json:"reason,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/managedprivateendpoints/model_managedprivateendpoint.go b/resource-manager/kusto/2024-04-13/managedprivateendpoints/model_managedprivateendpoint.go new file mode 100644 index 00000000000..90b630e3170 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/managedprivateendpoints/model_managedprivateendpoint.go @@ -0,0 +1,16 @@ +package managedprivateendpoints + +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 ManagedPrivateEndpoint struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ManagedPrivateEndpointProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/managedprivateendpoints/model_managedprivateendpointlistresult.go b/resource-manager/kusto/2024-04-13/managedprivateendpoints/model_managedprivateendpointlistresult.go new file mode 100644 index 00000000000..f5116adfade --- /dev/null +++ b/resource-manager/kusto/2024-04-13/managedprivateendpoints/model_managedprivateendpointlistresult.go @@ -0,0 +1,8 @@ +package managedprivateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedPrivateEndpointListResult struct { + Value *[]ManagedPrivateEndpoint `json:"value,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/managedprivateendpoints/model_managedprivateendpointproperties.go b/resource-manager/kusto/2024-04-13/managedprivateendpoints/model_managedprivateendpointproperties.go new file mode 100644 index 00000000000..2af4568de55 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/managedprivateendpoints/model_managedprivateendpointproperties.go @@ -0,0 +1,12 @@ +package managedprivateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedPrivateEndpointProperties struct { + GroupId string `json:"groupId"` + PrivateLinkResourceId string `json:"privateLinkResourceId"` + PrivateLinkResourceRegion *string `json:"privateLinkResourceRegion,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/managedprivateendpoints/model_managedprivateendpointschecknamerequest.go b/resource-manager/kusto/2024-04-13/managedprivateendpoints/model_managedprivateendpointschecknamerequest.go new file mode 100644 index 00000000000..fe3a38bb88c --- /dev/null +++ b/resource-manager/kusto/2024-04-13/managedprivateendpoints/model_managedprivateendpointschecknamerequest.go @@ -0,0 +1,9 @@ +package managedprivateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedPrivateEndpointsCheckNameRequest struct { + Name string `json:"name"` + Type ManagedPrivateEndpointsType `json:"type"` +} diff --git a/resource-manager/kusto/2024-04-13/managedprivateendpoints/version.go b/resource-manager/kusto/2024-04-13/managedprivateendpoints/version.go new file mode 100644 index 00000000000..103ac1bd7bd --- /dev/null +++ b/resource-manager/kusto/2024-04-13/managedprivateendpoints/version.go @@ -0,0 +1,10 @@ +package managedprivateendpoints + +// 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-04-13" + +func userAgent() string { + return "hashicorp/go-azure-sdk/managedprivateendpoints/2024-04-13" +} diff --git a/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/README.md b/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/README.md new file mode 100644 index 00000000000..06e2f75dc6a --- /dev/null +++ b/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/README.md @@ -0,0 +1,38 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints` Documentation + +The `outboundnetworkdependenciesendpoints` SDK allows for interaction with Azure Resource Manager `kusto` (API Version `2024-04-13`). + +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/kusto/2024-04-13/outboundnetworkdependenciesendpoints" +``` + + +### Client Initialization + +```go +client := outboundnetworkdependenciesendpoints.NewOutboundNetworkDependenciesEndpointsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `OutboundNetworkDependenciesEndpointsClient.ClustersListOutboundNetworkDependenciesEndpoints` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +// alternatively `client.ClustersListOutboundNetworkDependenciesEndpoints(ctx, id)` can be used to do batched pagination +items, err := client.ClustersListOutboundNetworkDependenciesEndpointsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/client.go b/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/client.go new file mode 100644 index 00000000000..a8a36d8265e --- /dev/null +++ b/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/client.go @@ -0,0 +1,26 @@ +package outboundnetworkdependenciesendpoints + +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 OutboundNetworkDependenciesEndpointsClient struct { + Client *resourcemanager.Client +} + +func NewOutboundNetworkDependenciesEndpointsClientWithBaseURI(sdkApi sdkEnv.Api) (*OutboundNetworkDependenciesEndpointsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "outboundnetworkdependenciesendpoints", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating OutboundNetworkDependenciesEndpointsClient: %+v", err) + } + + return &OutboundNetworkDependenciesEndpointsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/constants.go b/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/constants.go new file mode 100644 index 00000000000..b05592186b8 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/constants.go @@ -0,0 +1,66 @@ +package outboundnetworkdependenciesendpoints + +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 ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateMoving ProvisioningState = "Moving" + ProvisioningStateRunning ProvisioningState = "Running" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateMoving), + string(ProvisioningStateRunning), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "moving": ProvisioningStateMoving, + "running": ProvisioningStateRunning, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/method_clusterslistoutboundnetworkdependenciesendpoints.go b/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/method_clusterslistoutboundnetworkdependenciesendpoints.go new file mode 100644 index 00000000000..60c72489241 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/method_clusterslistoutboundnetworkdependenciesendpoints.go @@ -0,0 +1,106 @@ +package outboundnetworkdependenciesendpoints + +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 ClustersListOutboundNetworkDependenciesEndpointsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]OutboundNetworkDependenciesEndpoint +} + +type ClustersListOutboundNetworkDependenciesEndpointsCompleteResult struct { + LatestHttpResponse *http.Response + Items []OutboundNetworkDependenciesEndpoint +} + +type ClustersListOutboundNetworkDependenciesEndpointsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ClustersListOutboundNetworkDependenciesEndpointsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ClustersListOutboundNetworkDependenciesEndpoints ... +func (c OutboundNetworkDependenciesEndpointsClient) ClustersListOutboundNetworkDependenciesEndpoints(ctx context.Context, id commonids.KustoClusterId) (result ClustersListOutboundNetworkDependenciesEndpointsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ClustersListOutboundNetworkDependenciesEndpointsCustomPager{}, + Path: fmt.Sprintf("%s/outboundNetworkDependenciesEndpoints", 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 *[]OutboundNetworkDependenciesEndpoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ClustersListOutboundNetworkDependenciesEndpointsComplete retrieves all the results into a single object +func (c OutboundNetworkDependenciesEndpointsClient) ClustersListOutboundNetworkDependenciesEndpointsComplete(ctx context.Context, id commonids.KustoClusterId) (ClustersListOutboundNetworkDependenciesEndpointsCompleteResult, error) { + return c.ClustersListOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx, id, OutboundNetworkDependenciesEndpointOperationPredicate{}) +} + +// ClustersListOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c OutboundNetworkDependenciesEndpointsClient) ClustersListOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx context.Context, id commonids.KustoClusterId, predicate OutboundNetworkDependenciesEndpointOperationPredicate) (result ClustersListOutboundNetworkDependenciesEndpointsCompleteResult, err error) { + items := make([]OutboundNetworkDependenciesEndpoint, 0) + + resp, err := c.ClustersListOutboundNetworkDependenciesEndpoints(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 = ClustersListOutboundNetworkDependenciesEndpointsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/model_endpointdependency.go b/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/model_endpointdependency.go new file mode 100644 index 00000000000..81feeb21f76 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/model_endpointdependency.go @@ -0,0 +1,9 @@ +package outboundnetworkdependenciesendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointDependency struct { + DomainName *string `json:"domainName,omitempty"` + EndpointDetails *[]EndpointDetail `json:"endpointDetails,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/model_endpointdetail.go b/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/model_endpointdetail.go new file mode 100644 index 00000000000..74031ba4beb --- /dev/null +++ b/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/model_endpointdetail.go @@ -0,0 +1,9 @@ +package outboundnetworkdependenciesendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointDetail struct { + IPAddress *string `json:"ipAddress,omitempty"` + Port *int64 `json:"port,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/model_outboundnetworkdependenciesendpoint.go b/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/model_outboundnetworkdependenciesendpoint.go new file mode 100644 index 00000000000..1362488a073 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/model_outboundnetworkdependenciesendpoint.go @@ -0,0 +1,12 @@ +package outboundnetworkdependenciesendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OutboundNetworkDependenciesEndpoint struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *OutboundNetworkDependenciesEndpointProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/model_outboundnetworkdependenciesendpointproperties.go b/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/model_outboundnetworkdependenciesendpointproperties.go new file mode 100644 index 00000000000..91302a8146e --- /dev/null +++ b/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/model_outboundnetworkdependenciesendpointproperties.go @@ -0,0 +1,10 @@ +package outboundnetworkdependenciesendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OutboundNetworkDependenciesEndpointProperties struct { + Category *string `json:"category,omitempty"` + Endpoints *[]EndpointDependency `json:"endpoints,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/predicates.go b/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/predicates.go new file mode 100644 index 00000000000..95ea4de4061 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/predicates.go @@ -0,0 +1,32 @@ +package outboundnetworkdependenciesendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OutboundNetworkDependenciesEndpointOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p OutboundNetworkDependenciesEndpointOperationPredicate) Matches(input OutboundNetworkDependenciesEndpoint) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/version.go b/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/version.go new file mode 100644 index 00000000000..c0c6ba83eee --- /dev/null +++ b/resource-manager/kusto/2024-04-13/outboundnetworkdependenciesendpoints/version.go @@ -0,0 +1,10 @@ +package outboundnetworkdependenciesendpoints + +// 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-04-13" + +func userAgent() string { + return "hashicorp/go-azure-sdk/outboundnetworkdependenciesendpoints/2024-04-13" +} diff --git a/resource-manager/kusto/2024-04-13/privateendpointconnections/README.md b/resource-manager/kusto/2024-04-13/privateendpointconnections/README.md new file mode 100644 index 00000000000..1e56f36abef --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privateendpointconnections/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/privateendpointconnections` Documentation + +The `privateendpointconnections` SDK allows for interaction with Azure Resource Manager `kusto` (API Version `2024-04-13`). + +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/kusto/2024-04-13/privateendpointconnections" +``` + + +### Client Initialization + +```go +client := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "privateEndpointConnectionName") + +payload := privateendpointconnections.PrivateEndpointConnection{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.Delete` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "privateEndpointConnectionName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.Get` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "privateEndpointConnectionName") + +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: `PrivateEndpointConnectionsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +read, err := client.List(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/kusto/2024-04-13/privateendpointconnections/client.go b/resource-manager/kusto/2024-04-13/privateendpointconnections/client.go new file mode 100644 index 00000000000..50eaf09dcce --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privateendpointconnections/client.go @@ -0,0 +1,26 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionsClient struct { + Client *resourcemanager.Client +} + +func NewPrivateEndpointConnectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*PrivateEndpointConnectionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "privateendpointconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateEndpointConnectionsClient: %+v", err) + } + + return &PrivateEndpointConnectionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/kusto/2024-04-13/privateendpointconnections/id_privateendpointconnection.go b/resource-manager/kusto/2024-04-13/privateendpointconnections/id_privateendpointconnection.go new file mode 100644 index 00000000000..0d7629c238e --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privateendpointconnections/id_privateendpointconnection.go @@ -0,0 +1,139 @@ +package privateendpointconnections + +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(&PrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection +type PrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + ClusterName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, clusterName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ClusterName: clusterName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId +func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateEndpointConnectionId) 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.ClusterName, ok = input.Parsed["clusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "clusterName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID +func ValidatePrivateEndpointConnectionID(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 := ParsePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Kusto/clusters/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) 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("staticMicrosoftKusto", "Microsoft.Kusto", "Microsoft.Kusto"), + resourceids.StaticSegment("staticClusters", "clusters", "clusters"), + resourceids.UserSpecifiedSegment("clusterName", "clusterName"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionName"), + } +} + +// String returns a human-readable description of this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cluster Name: %q", id.ClusterName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/kusto/2024-04-13/privateendpointconnections/id_privateendpointconnection_test.go b/resource-manager/kusto/2024-04-13/privateendpointconnections/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..786b6b32601 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privateendpointconnections/id_privateendpointconnection_test.go @@ -0,0 +1,327 @@ +package privateendpointconnections + +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 = &PrivateEndpointConnectionId{} + +func TestNewPrivateEndpointConnectionID(t *testing.T) { + id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "privateEndpointConnectionName") + + 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.ClusterName != "clusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterName") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionName") + } +} + +func TestFormatPrivateEndpointConnectionID(t *testing.T) { + actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "privateEndpointConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/privateEndpointConnections/privateEndpointConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionID(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParsePrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ClusterName: "cLuStErNaMe", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionIDInsensitively(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { + segments := PrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateEndpointConnectionId 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/kusto/2024-04-13/privateendpointconnections/method_createorupdate.go b/resource-manager/kusto/2024-04-13/privateendpointconnections/method_createorupdate.go new file mode 100644 index 00000000000..73fb1683a66 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privateendpointconnections/method_createorupdate.go @@ -0,0 +1,75 @@ +package privateendpointconnections + +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 *PrivateEndpointConnection +} + +// CreateOrUpdate ... +func (c PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (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 PrivateEndpointConnectionsClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) 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/kusto/2024-04-13/privateendpointconnections/method_delete.go b/resource-manager/kusto/2024-04-13/privateendpointconnections/method_delete.go new file mode 100644 index 00000000000..63c26e8f27f --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privateendpointconnections/method_delete.go @@ -0,0 +1,71 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionsClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c PrivateEndpointConnectionsClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) 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/kusto/2024-04-13/privateendpointconnections/method_get.go b/resource-manager/kusto/2024-04-13/privateendpointconnections/method_get.go new file mode 100644 index 00000000000..351242746d4 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privateendpointconnections/method_get.go @@ -0,0 +1,53 @@ +package privateendpointconnections + +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 *PrivateEndpointConnection +} + +// Get ... +func (c PrivateEndpointConnectionsClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (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 PrivateEndpointConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/privateendpointconnections/method_list.go b/resource-manager/kusto/2024-04-13/privateendpointconnections/method_list.go new file mode 100644 index 00000000000..00024c09837 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privateendpointconnections/method_list.go @@ -0,0 +1,55 @@ +package privateendpointconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnectionListResult +} + +// List ... +func (c PrivateEndpointConnectionsClient) List(ctx context.Context, id commonids.KustoClusterId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", 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 PrivateEndpointConnectionListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/privateendpointconnections/model_privateendpointconnection.go b/resource-manager/kusto/2024-04-13/privateendpointconnections/model_privateendpointconnection.go new file mode 100644 index 00000000000..977fe056fe3 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privateendpointconnections/model_privateendpointconnection.go @@ -0,0 +1,16 @@ +package privateendpointconnections + +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 PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/privateendpointconnections/model_privateendpointconnectionlistresult.go b/resource-manager/kusto/2024-04-13/privateendpointconnections/model_privateendpointconnectionlistresult.go new file mode 100644 index 00000000000..92a9ecb105a --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privateendpointconnections/model_privateendpointconnectionlistresult.go @@ -0,0 +1,8 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionListResult struct { + Value *[]PrivateEndpointConnection `json:"value,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/privateendpointconnections/model_privateendpointconnectionproperties.go b/resource-manager/kusto/2024-04-13/privateendpointconnections/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..87edd56e28c --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privateendpointconnections/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupId *string `json:"groupId,omitempty"` + PrivateEndpoint *PrivateEndpointProperty `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionStateProperty `json:"privateLinkServiceConnectionState"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/privateendpointconnections/model_privateendpointproperty.go b/resource-manager/kusto/2024-04-13/privateendpointconnections/model_privateendpointproperty.go new file mode 100644 index 00000000000..b0b0ff18482 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privateendpointconnections/model_privateendpointproperty.go @@ -0,0 +1,8 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperty struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/privateendpointconnections/model_privatelinkserviceconnectionstateproperty.go b/resource-manager/kusto/2024-04-13/privateendpointconnections/model_privatelinkserviceconnectionstateproperty.go new file mode 100644 index 00000000000..7f85d6bf04f --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privateendpointconnections/model_privatelinkserviceconnectionstateproperty.go @@ -0,0 +1,10 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionStateProperty struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/privateendpointconnections/version.go b/resource-manager/kusto/2024-04-13/privateendpointconnections/version.go new file mode 100644 index 00000000000..ad83f66707c --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privateendpointconnections/version.go @@ -0,0 +1,10 @@ +package privateendpointconnections + +// 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-04-13" + +func userAgent() string { + return "hashicorp/go-azure-sdk/privateendpointconnections/2024-04-13" +} diff --git a/resource-manager/kusto/2024-04-13/privatelinkresources/README.md b/resource-manager/kusto/2024-04-13/privatelinkresources/README.md new file mode 100644 index 00000000000..d18eafb4475 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privatelinkresources/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/privatelinkresources` Documentation + +The `privatelinkresources` SDK allows for interaction with Azure Resource Manager `kusto` (API Version `2024-04-13`). + +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/kusto/2024-04-13/privatelinkresources" +``` + + +### Client Initialization + +```go +client := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateLinkResourcesClient.Get` + +```go +ctx := context.TODO() +id := privatelinkresources.NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "privateLinkResourceName") + +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: `PrivateLinkResourcesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +read, err := client.List(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/kusto/2024-04-13/privatelinkresources/client.go b/resource-manager/kusto/2024-04-13/privatelinkresources/client.go new file mode 100644 index 00000000000..28c00b21f03 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privatelinkresources/client.go @@ -0,0 +1,26 @@ +package privatelinkresources + +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 PrivateLinkResourcesClient struct { + Client *resourcemanager.Client +} + +func NewPrivateLinkResourcesClientWithBaseURI(sdkApi sdkEnv.Api) (*PrivateLinkResourcesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "privatelinkresources", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateLinkResourcesClient: %+v", err) + } + + return &PrivateLinkResourcesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/kusto/2024-04-13/privatelinkresources/id_privatelinkresource.go b/resource-manager/kusto/2024-04-13/privatelinkresources/id_privatelinkresource.go new file mode 100644 index 00000000000..b507e1cd923 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privatelinkresources/id_privatelinkresource.go @@ -0,0 +1,139 @@ +package privatelinkresources + +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(&PrivateLinkResourceId{}) +} + +var _ resourceids.ResourceId = &PrivateLinkResourceId{} + +// PrivateLinkResourceId is a struct representing the Resource ID for a Private Link Resource +type PrivateLinkResourceId struct { + SubscriptionId string + ResourceGroupName string + ClusterName string + PrivateLinkResourceName string +} + +// NewPrivateLinkResourceID returns a new PrivateLinkResourceId struct +func NewPrivateLinkResourceID(subscriptionId string, resourceGroupName string, clusterName string, privateLinkResourceName string) PrivateLinkResourceId { + return PrivateLinkResourceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ClusterName: clusterName, + PrivateLinkResourceName: privateLinkResourceName, + } +} + +// ParsePrivateLinkResourceID parses 'input' into a PrivateLinkResourceId +func ParsePrivateLinkResourceID(input string) (*PrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateLinkResourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateLinkResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateLinkResourceIDInsensitively parses 'input' case-insensitively into a PrivateLinkResourceId +// note: this method should only be used for API response data and not user input +func ParsePrivateLinkResourceIDInsensitively(input string) (*PrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateLinkResourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateLinkResourceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateLinkResourceId) 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.ClusterName, ok = input.Parsed["clusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "clusterName", input) + } + + if id.PrivateLinkResourceName, ok = input.Parsed["privateLinkResourceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateLinkResourceName", input) + } + + return nil +} + +// ValidatePrivateLinkResourceID checks that 'input' can be parsed as a Private Link Resource ID +func ValidatePrivateLinkResourceID(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 := ParsePrivateLinkResourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Link Resource ID +func (id PrivateLinkResourceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Kusto/clusters/%s/privateLinkResources/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName, id.PrivateLinkResourceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Link Resource ID +func (id PrivateLinkResourceId) 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("staticMicrosoftKusto", "Microsoft.Kusto", "Microsoft.Kusto"), + resourceids.StaticSegment("staticClusters", "clusters", "clusters"), + resourceids.UserSpecifiedSegment("clusterName", "clusterName"), + resourceids.StaticSegment("staticPrivateLinkResources", "privateLinkResources", "privateLinkResources"), + resourceids.UserSpecifiedSegment("privateLinkResourceName", "privateLinkResourceName"), + } +} + +// String returns a human-readable description of this Private Link Resource ID +func (id PrivateLinkResourceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cluster Name: %q", id.ClusterName), + fmt.Sprintf("Private Link Resource Name: %q", id.PrivateLinkResourceName), + } + return fmt.Sprintf("Private Link Resource (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/kusto/2024-04-13/privatelinkresources/id_privatelinkresource_test.go b/resource-manager/kusto/2024-04-13/privatelinkresources/id_privatelinkresource_test.go new file mode 100644 index 00000000000..a3921e982fe --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privatelinkresources/id_privatelinkresource_test.go @@ -0,0 +1,327 @@ +package privatelinkresources + +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 = &PrivateLinkResourceId{} + +func TestNewPrivateLinkResourceID(t *testing.T) { + id := NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "privateLinkResourceName") + + 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.ClusterName != "clusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterName") + } + + if id.PrivateLinkResourceName != "privateLinkResourceName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateLinkResourceName'", id.PrivateLinkResourceName, "privateLinkResourceName") + } +} + +func TestFormatPrivateLinkResourceID(t *testing.T) { + actual := NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "privateLinkResourceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/privateLinkResources/privateLinkResourceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateLinkResourceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateLinkResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/privateLinkResources", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/privateLinkResources/privateLinkResourceName", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + PrivateLinkResourceName: "privateLinkResourceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/privateLinkResources/privateLinkResourceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateLinkResourceID(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.PrivateLinkResourceName != v.Expected.PrivateLinkResourceName { + t.Fatalf("Expected %q but got %q for PrivateLinkResourceName", v.Expected.PrivateLinkResourceName, actual.PrivateLinkResourceName) + } + + } +} + +func TestParsePrivateLinkResourceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateLinkResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/privateLinkResources", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/pRiVaTeLiNkReSoUrCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/privateLinkResources/privateLinkResourceName", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + PrivateLinkResourceName: "privateLinkResourceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/privateLinkResources/privateLinkResourceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/pRiVaTeLiNkReSoUrCeS/pRiVaTeLiNkReSoUrCeNaMe", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ClusterName: "cLuStErNaMe", + PrivateLinkResourceName: "pRiVaTeLiNkReSoUrCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/pRiVaTeLiNkReSoUrCeS/pRiVaTeLiNkReSoUrCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateLinkResourceIDInsensitively(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.PrivateLinkResourceName != v.Expected.PrivateLinkResourceName { + t.Fatalf("Expected %q but got %q for PrivateLinkResourceName", v.Expected.PrivateLinkResourceName, actual.PrivateLinkResourceName) + } + + } +} + +func TestSegmentsForPrivateLinkResourceId(t *testing.T) { + segments := PrivateLinkResourceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateLinkResourceId 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/kusto/2024-04-13/privatelinkresources/method_get.go b/resource-manager/kusto/2024-04-13/privatelinkresources/method_get.go new file mode 100644 index 00000000000..4fe26146181 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privatelinkresources/method_get.go @@ -0,0 +1,53 @@ +package privatelinkresources + +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 *PrivateLinkResource +} + +// Get ... +func (c PrivateLinkResourcesClient) Get(ctx context.Context, id PrivateLinkResourceId) (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 PrivateLinkResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/privatelinkresources/method_list.go b/resource-manager/kusto/2024-04-13/privatelinkresources/method_list.go new file mode 100644 index 00000000000..33aa33fe499 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privatelinkresources/method_list.go @@ -0,0 +1,55 @@ +package privatelinkresources + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourceListResult +} + +// List ... +func (c PrivateLinkResourcesClient) List(ctx context.Context, id commonids.KustoClusterId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", 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 PrivateLinkResourceListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/privatelinkresources/model_privatelinkresource.go b/resource-manager/kusto/2024-04-13/privatelinkresources/model_privatelinkresource.go new file mode 100644 index 00000000000..6e8c3d8148b --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privatelinkresources/model_privatelinkresource.go @@ -0,0 +1,16 @@ +package privatelinkresources + +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 PrivateLinkResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/privatelinkresources/model_privatelinkresourcelistresult.go b/resource-manager/kusto/2024-04-13/privatelinkresources/model_privatelinkresourcelistresult.go new file mode 100644 index 00000000000..fa950217c47 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privatelinkresources/model_privatelinkresourcelistresult.go @@ -0,0 +1,8 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceListResult struct { + Value *[]PrivateLinkResource `json:"value,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/privatelinkresources/model_privatelinkresourceproperties.go b/resource-manager/kusto/2024-04-13/privatelinkresources/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..3c98012cdd1 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privatelinkresources/model_privatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/privatelinkresources/version.go b/resource-manager/kusto/2024-04-13/privatelinkresources/version.go new file mode 100644 index 00000000000..db1fae29910 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/privatelinkresources/version.go @@ -0,0 +1,10 @@ +package privatelinkresources + +// 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-04-13" + +func userAgent() string { + return "hashicorp/go-azure-sdk/privatelinkresources/2024-04-13" +} diff --git a/resource-manager/kusto/2024-04-13/sandboxcustomimages/README.md b/resource-manager/kusto/2024-04-13/sandboxcustomimages/README.md new file mode 100644 index 00000000000..c4f092e7cfc --- /dev/null +++ b/resource-manager/kusto/2024-04-13/sandboxcustomimages/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/sandboxcustomimages` Documentation + +The `sandboxcustomimages` SDK allows for interaction with Azure Resource Manager `kusto` (API Version `2024-04-13`). + +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/kusto/2024-04-13/sandboxcustomimages" +``` + + +### Client Initialization + +```go +client := sandboxcustomimages.NewSandboxCustomImagesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SandboxCustomImagesClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +payload := sandboxcustomimages.SandboxCustomImagesCheckNameRequest{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SandboxCustomImagesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := sandboxcustomimages.NewSandboxCustomImageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "sandboxCustomImageName") + +payload := sandboxcustomimages.SandboxCustomImage{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SandboxCustomImagesClient.Delete` + +```go +ctx := context.TODO() +id := sandboxcustomimages.NewSandboxCustomImageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "sandboxCustomImageName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SandboxCustomImagesClient.Get` + +```go +ctx := context.TODO() +id := sandboxcustomimages.NewSandboxCustomImageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "sandboxCustomImageName") + +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: `SandboxCustomImagesClient.ListByCluster` + +```go +ctx := context.TODO() +id := commonids.NewKustoClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName") + +// alternatively `client.ListByCluster(ctx, id)` can be used to do batched pagination +items, err := client.ListByClusterComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SandboxCustomImagesClient.Update` + +```go +ctx := context.TODO() +id := sandboxcustomimages.NewSandboxCustomImageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "sandboxCustomImageName") + +payload := sandboxcustomimages.SandboxCustomImage{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/kusto/2024-04-13/sandboxcustomimages/client.go b/resource-manager/kusto/2024-04-13/sandboxcustomimages/client.go new file mode 100644 index 00000000000..64f5709a2f2 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/sandboxcustomimages/client.go @@ -0,0 +1,26 @@ +package sandboxcustomimages + +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 SandboxCustomImagesClient struct { + Client *resourcemanager.Client +} + +func NewSandboxCustomImagesClientWithBaseURI(sdkApi sdkEnv.Api) (*SandboxCustomImagesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "sandboxcustomimages", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SandboxCustomImagesClient: %+v", err) + } + + return &SandboxCustomImagesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/kusto/2024-04-13/sandboxcustomimages/constants.go b/resource-manager/kusto/2024-04-13/sandboxcustomimages/constants.go new file mode 100644 index 00000000000..fbacbd09052 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/sandboxcustomimages/constants.go @@ -0,0 +1,183 @@ +package sandboxcustomimages + +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 Language string + +const ( + LanguagePython Language = "Python" +) + +func PossibleValuesForLanguage() []string { + return []string{ + string(LanguagePython), + } +} + +func (s *Language) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLanguage(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLanguage(input string) (*Language, error) { + vals := map[string]Language{ + "python": LanguagePython, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Language(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateMoving ProvisioningState = "Moving" + ProvisioningStateRunning ProvisioningState = "Running" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateMoving), + string(ProvisioningStateRunning), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "moving": ProvisioningStateMoving, + "running": ProvisioningStateRunning, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type Reason string + +const ( + ReasonAlreadyExists Reason = "AlreadyExists" + ReasonInvalid Reason = "Invalid" +) + +func PossibleValuesForReason() []string { + return []string{ + string(ReasonAlreadyExists), + string(ReasonInvalid), + } +} + +func (s *Reason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReason(input string) (*Reason, error) { + vals := map[string]Reason{ + "alreadyexists": ReasonAlreadyExists, + "invalid": ReasonInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Reason(input) + return &out, nil +} + +type SandboxCustomImageType string + +const ( + SandboxCustomImageTypeMicrosoftPointKustoClustersSandboxCustomImages SandboxCustomImageType = "Microsoft.Kusto/clusters/sandboxCustomImages" +) + +func PossibleValuesForSandboxCustomImageType() []string { + return []string{ + string(SandboxCustomImageTypeMicrosoftPointKustoClustersSandboxCustomImages), + } +} + +func (s *SandboxCustomImageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSandboxCustomImageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSandboxCustomImageType(input string) (*SandboxCustomImageType, error) { + vals := map[string]SandboxCustomImageType{ + "microsoft.kusto/clusters/sandboxcustomimages": SandboxCustomImageTypeMicrosoftPointKustoClustersSandboxCustomImages, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SandboxCustomImageType(input) + return &out, nil +} diff --git a/resource-manager/kusto/2024-04-13/sandboxcustomimages/id_sandboxcustomimage.go b/resource-manager/kusto/2024-04-13/sandboxcustomimages/id_sandboxcustomimage.go new file mode 100644 index 00000000000..8fa74b12545 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/sandboxcustomimages/id_sandboxcustomimage.go @@ -0,0 +1,139 @@ +package sandboxcustomimages + +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(&SandboxCustomImageId{}) +} + +var _ resourceids.ResourceId = &SandboxCustomImageId{} + +// SandboxCustomImageId is a struct representing the Resource ID for a Sandbox Custom Image +type SandboxCustomImageId struct { + SubscriptionId string + ResourceGroupName string + ClusterName string + SandboxCustomImageName string +} + +// NewSandboxCustomImageID returns a new SandboxCustomImageId struct +func NewSandboxCustomImageID(subscriptionId string, resourceGroupName string, clusterName string, sandboxCustomImageName string) SandboxCustomImageId { + return SandboxCustomImageId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ClusterName: clusterName, + SandboxCustomImageName: sandboxCustomImageName, + } +} + +// ParseSandboxCustomImageID parses 'input' into a SandboxCustomImageId +func ParseSandboxCustomImageID(input string) (*SandboxCustomImageId, error) { + parser := resourceids.NewParserFromResourceIdType(&SandboxCustomImageId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SandboxCustomImageId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSandboxCustomImageIDInsensitively parses 'input' case-insensitively into a SandboxCustomImageId +// note: this method should only be used for API response data and not user input +func ParseSandboxCustomImageIDInsensitively(input string) (*SandboxCustomImageId, error) { + parser := resourceids.NewParserFromResourceIdType(&SandboxCustomImageId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SandboxCustomImageId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SandboxCustomImageId) 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.ClusterName, ok = input.Parsed["clusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "clusterName", input) + } + + if id.SandboxCustomImageName, ok = input.Parsed["sandboxCustomImageName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sandboxCustomImageName", input) + } + + return nil +} + +// ValidateSandboxCustomImageID checks that 'input' can be parsed as a Sandbox Custom Image ID +func ValidateSandboxCustomImageID(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 := ParseSandboxCustomImageID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sandbox Custom Image ID +func (id SandboxCustomImageId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Kusto/clusters/%s/sandboxCustomImages/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName, id.SandboxCustomImageName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sandbox Custom Image ID +func (id SandboxCustomImageId) 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("staticMicrosoftKusto", "Microsoft.Kusto", "Microsoft.Kusto"), + resourceids.StaticSegment("staticClusters", "clusters", "clusters"), + resourceids.UserSpecifiedSegment("clusterName", "clusterName"), + resourceids.StaticSegment("staticSandboxCustomImages", "sandboxCustomImages", "sandboxCustomImages"), + resourceids.UserSpecifiedSegment("sandboxCustomImageName", "sandboxCustomImageName"), + } +} + +// String returns a human-readable description of this Sandbox Custom Image ID +func (id SandboxCustomImageId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cluster Name: %q", id.ClusterName), + fmt.Sprintf("Sandbox Custom Image Name: %q", id.SandboxCustomImageName), + } + return fmt.Sprintf("Sandbox Custom Image (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/kusto/2024-04-13/sandboxcustomimages/id_sandboxcustomimage_test.go b/resource-manager/kusto/2024-04-13/sandboxcustomimages/id_sandboxcustomimage_test.go new file mode 100644 index 00000000000..4a63dcdff4d --- /dev/null +++ b/resource-manager/kusto/2024-04-13/sandboxcustomimages/id_sandboxcustomimage_test.go @@ -0,0 +1,327 @@ +package sandboxcustomimages + +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 = &SandboxCustomImageId{} + +func TestNewSandboxCustomImageID(t *testing.T) { + id := NewSandboxCustomImageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "sandboxCustomImageName") + + 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.ClusterName != "clusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterName") + } + + if id.SandboxCustomImageName != "sandboxCustomImageName" { + t.Fatalf("Expected %q but got %q for Segment 'SandboxCustomImageName'", id.SandboxCustomImageName, "sandboxCustomImageName") + } +} + +func TestFormatSandboxCustomImageID(t *testing.T) { + actual := NewSandboxCustomImageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "sandboxCustomImageName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/sandboxCustomImages/sandboxCustomImageName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSandboxCustomImageID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SandboxCustomImageId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/sandboxCustomImages", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/sandboxCustomImages/sandboxCustomImageName", + Expected: &SandboxCustomImageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + SandboxCustomImageName: "sandboxCustomImageName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/sandboxCustomImages/sandboxCustomImageName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSandboxCustomImageID(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.SandboxCustomImageName != v.Expected.SandboxCustomImageName { + t.Fatalf("Expected %q but got %q for SandboxCustomImageName", v.Expected.SandboxCustomImageName, actual.SandboxCustomImageName) + } + + } +} + +func TestParseSandboxCustomImageIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SandboxCustomImageId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/sandboxCustomImages", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/sAnDbOxCuStOmImAgEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/sandboxCustomImages/sandboxCustomImageName", + Expected: &SandboxCustomImageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + SandboxCustomImageName: "sandboxCustomImageName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/sandboxCustomImages/sandboxCustomImageName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/sAnDbOxCuStOmImAgEs/sAnDbOxCuStOmImAgEnAmE", + Expected: &SandboxCustomImageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ClusterName: "cLuStErNaMe", + SandboxCustomImageName: "sAnDbOxCuStOmImAgEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/sAnDbOxCuStOmImAgEs/sAnDbOxCuStOmImAgEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSandboxCustomImageIDInsensitively(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.SandboxCustomImageName != v.Expected.SandboxCustomImageName { + t.Fatalf("Expected %q but got %q for SandboxCustomImageName", v.Expected.SandboxCustomImageName, actual.SandboxCustomImageName) + } + + } +} + +func TestSegmentsForSandboxCustomImageId(t *testing.T) { + segments := SandboxCustomImageId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SandboxCustomImageId 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/kusto/2024-04-13/sandboxcustomimages/method_checknameavailability.go b/resource-manager/kusto/2024-04-13/sandboxcustomimages/method_checknameavailability.go new file mode 100644 index 00000000000..da82c657982 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/sandboxcustomimages/method_checknameavailability.go @@ -0,0 +1,59 @@ +package sandboxcustomimages + +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 CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameResult +} + +// CheckNameAvailability ... +func (c SandboxCustomImagesClient) CheckNameAvailability(ctx context.Context, id commonids.KustoClusterId, input SandboxCustomImagesCheckNameRequest) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sandboxCustomImagesCheckNameAvailability", 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 CheckNameResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/sandboxcustomimages/method_createorupdate.go b/resource-manager/kusto/2024-04-13/sandboxcustomimages/method_createorupdate.go new file mode 100644 index 00000000000..30930113875 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/sandboxcustomimages/method_createorupdate.go @@ -0,0 +1,75 @@ +package sandboxcustomimages + +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 *SandboxCustomImage +} + +// CreateOrUpdate ... +func (c SandboxCustomImagesClient) CreateOrUpdate(ctx context.Context, id SandboxCustomImageId, input SandboxCustomImage) (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 SandboxCustomImagesClient) CreateOrUpdateThenPoll(ctx context.Context, id SandboxCustomImageId, input SandboxCustomImage) 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/kusto/2024-04-13/sandboxcustomimages/method_delete.go b/resource-manager/kusto/2024-04-13/sandboxcustomimages/method_delete.go new file mode 100644 index 00000000000..89c6d1738bf --- /dev/null +++ b/resource-manager/kusto/2024-04-13/sandboxcustomimages/method_delete.go @@ -0,0 +1,71 @@ +package sandboxcustomimages + +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 SandboxCustomImagesClient) Delete(ctx context.Context, id SandboxCustomImageId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c SandboxCustomImagesClient) DeleteThenPoll(ctx context.Context, id SandboxCustomImageId) 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/kusto/2024-04-13/sandboxcustomimages/method_get.go b/resource-manager/kusto/2024-04-13/sandboxcustomimages/method_get.go new file mode 100644 index 00000000000..50744967980 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/sandboxcustomimages/method_get.go @@ -0,0 +1,53 @@ +package sandboxcustomimages + +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 *SandboxCustomImage +} + +// Get ... +func (c SandboxCustomImagesClient) Get(ctx context.Context, id SandboxCustomImageId) (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 SandboxCustomImage + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/sandboxcustomimages/method_listbycluster.go b/resource-manager/kusto/2024-04-13/sandboxcustomimages/method_listbycluster.go new file mode 100644 index 00000000000..81c7a4a2582 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/sandboxcustomimages/method_listbycluster.go @@ -0,0 +1,106 @@ +package sandboxcustomimages + +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 ListByClusterOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SandboxCustomImage +} + +type ListByClusterCompleteResult struct { + LatestHttpResponse *http.Response + Items []SandboxCustomImage +} + +type ListByClusterCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByClusterCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByCluster ... +func (c SandboxCustomImagesClient) ListByCluster(ctx context.Context, id commonids.KustoClusterId) (result ListByClusterOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByClusterCustomPager{}, + Path: fmt.Sprintf("%s/sandboxCustomImages", 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 *[]SandboxCustomImage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByClusterComplete retrieves all the results into a single object +func (c SandboxCustomImagesClient) ListByClusterComplete(ctx context.Context, id commonids.KustoClusterId) (ListByClusterCompleteResult, error) { + return c.ListByClusterCompleteMatchingPredicate(ctx, id, SandboxCustomImageOperationPredicate{}) +} + +// ListByClusterCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SandboxCustomImagesClient) ListByClusterCompleteMatchingPredicate(ctx context.Context, id commonids.KustoClusterId, predicate SandboxCustomImageOperationPredicate) (result ListByClusterCompleteResult, err error) { + items := make([]SandboxCustomImage, 0) + + resp, err := c.ListByCluster(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 = ListByClusterCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/kusto/2024-04-13/sandboxcustomimages/method_update.go b/resource-manager/kusto/2024-04-13/sandboxcustomimages/method_update.go new file mode 100644 index 00000000000..39cda96c21d --- /dev/null +++ b/resource-manager/kusto/2024-04-13/sandboxcustomimages/method_update.go @@ -0,0 +1,76 @@ +package sandboxcustomimages + +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 *SandboxCustomImage +} + +// Update ... +func (c SandboxCustomImagesClient) Update(ctx context.Context, id SandboxCustomImageId, input SandboxCustomImage) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + 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 SandboxCustomImagesClient) UpdateThenPoll(ctx context.Context, id SandboxCustomImageId, input SandboxCustomImage) 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/kusto/2024-04-13/sandboxcustomimages/model_checknameresult.go b/resource-manager/kusto/2024-04-13/sandboxcustomimages/model_checknameresult.go new file mode 100644 index 00000000000..9d2ea61b848 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/sandboxcustomimages/model_checknameresult.go @@ -0,0 +1,11 @@ +package sandboxcustomimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameResult struct { + Message *string `json:"message,omitempty"` + Name *string `json:"name,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *Reason `json:"reason,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/sandboxcustomimages/model_sandboxcustomimage.go b/resource-manager/kusto/2024-04-13/sandboxcustomimages/model_sandboxcustomimage.go new file mode 100644 index 00000000000..48593ffca05 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/sandboxcustomimages/model_sandboxcustomimage.go @@ -0,0 +1,11 @@ +package sandboxcustomimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SandboxCustomImage struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SandboxCustomImageProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/sandboxcustomimages/model_sandboxcustomimageproperties.go b/resource-manager/kusto/2024-04-13/sandboxcustomimages/model_sandboxcustomimageproperties.go new file mode 100644 index 00000000000..b6f407431e5 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/sandboxcustomimages/model_sandboxcustomimageproperties.go @@ -0,0 +1,12 @@ +package sandboxcustomimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SandboxCustomImageProperties struct { + BaseImageName *string `json:"baseImageName,omitempty"` + Language Language `json:"language"` + LanguageVersion *string `json:"languageVersion,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequirementsFileContent *string `json:"requirementsFileContent,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/sandboxcustomimages/model_sandboxcustomimageschecknamerequest.go b/resource-manager/kusto/2024-04-13/sandboxcustomimages/model_sandboxcustomimageschecknamerequest.go new file mode 100644 index 00000000000..c40629bdd44 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/sandboxcustomimages/model_sandboxcustomimageschecknamerequest.go @@ -0,0 +1,9 @@ +package sandboxcustomimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SandboxCustomImagesCheckNameRequest struct { + Name string `json:"name"` + Type SandboxCustomImageType `json:"type"` +} diff --git a/resource-manager/kusto/2024-04-13/sandboxcustomimages/predicates.go b/resource-manager/kusto/2024-04-13/sandboxcustomimages/predicates.go new file mode 100644 index 00000000000..9ee04621fcd --- /dev/null +++ b/resource-manager/kusto/2024-04-13/sandboxcustomimages/predicates.go @@ -0,0 +1,27 @@ +package sandboxcustomimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SandboxCustomImageOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SandboxCustomImageOperationPredicate) Matches(input SandboxCustomImage) 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/kusto/2024-04-13/sandboxcustomimages/version.go b/resource-manager/kusto/2024-04-13/sandboxcustomimages/version.go new file mode 100644 index 00000000000..6c40ecf0d46 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/sandboxcustomimages/version.go @@ -0,0 +1,10 @@ +package sandboxcustomimages + +// 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-04-13" + +func userAgent() string { + return "hashicorp/go-azure-sdk/sandboxcustomimages/2024-04-13" +} diff --git a/resource-manager/kusto/2024-04-13/scripts/README.md b/resource-manager/kusto/2024-04-13/scripts/README.md new file mode 100644 index 00000000000..da2b50efa85 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/scripts/README.md @@ -0,0 +1,120 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2024-04-13/scripts` Documentation + +The `scripts` SDK allows for interaction with Azure Resource Manager `kusto` (API Version `2024-04-13`). + +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/kusto/2024-04-13/scripts" +``` + + +### Client Initialization + +```go +client := scripts.NewScriptsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ScriptsClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := commonids.NewKustoDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName") + +payload := scripts.ScriptCheckNameRequest{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ScriptsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := scripts.NewScriptID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName", "scriptName") + +payload := scripts.Script{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ScriptsClient.Delete` + +```go +ctx := context.TODO() +id := scripts.NewScriptID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName", "scriptName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ScriptsClient.Get` + +```go +ctx := context.TODO() +id := scripts.NewScriptID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName", "scriptName") + +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: `ScriptsClient.ListByDatabase` + +```go +ctx := context.TODO() +id := commonids.NewKustoDatabaseID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName") + +read, err := client.ListByDatabase(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ScriptsClient.Update` + +```go +ctx := context.TODO() +id := scripts.NewScriptID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName", "scriptName") + +payload := scripts.Script{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/kusto/2024-04-13/scripts/client.go b/resource-manager/kusto/2024-04-13/scripts/client.go new file mode 100644 index 00000000000..6ef58a49ba4 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/scripts/client.go @@ -0,0 +1,26 @@ +package scripts + +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 ScriptsClient struct { + Client *resourcemanager.Client +} + +func NewScriptsClientWithBaseURI(sdkApi sdkEnv.Api) (*ScriptsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "scripts", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ScriptsClient: %+v", err) + } + + return &ScriptsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/kusto/2024-04-13/scripts/constants.go b/resource-manager/kusto/2024-04-13/scripts/constants.go new file mode 100644 index 00000000000..3fd8dfb2a0c --- /dev/null +++ b/resource-manager/kusto/2024-04-13/scripts/constants.go @@ -0,0 +1,227 @@ +package scripts + +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 PrincipalPermissionsAction string + +const ( + PrincipalPermissionsActionRemovePermissionOnScriptCompletion PrincipalPermissionsAction = "RemovePermissionOnScriptCompletion" + PrincipalPermissionsActionRetainPermissionOnScriptCompletion PrincipalPermissionsAction = "RetainPermissionOnScriptCompletion" +) + +func PossibleValuesForPrincipalPermissionsAction() []string { + return []string{ + string(PrincipalPermissionsActionRemovePermissionOnScriptCompletion), + string(PrincipalPermissionsActionRetainPermissionOnScriptCompletion), + } +} + +func (s *PrincipalPermissionsAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrincipalPermissionsAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrincipalPermissionsAction(input string) (*PrincipalPermissionsAction, error) { + vals := map[string]PrincipalPermissionsAction{ + "removepermissiononscriptcompletion": PrincipalPermissionsActionRemovePermissionOnScriptCompletion, + "retainpermissiononscriptcompletion": PrincipalPermissionsActionRetainPermissionOnScriptCompletion, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrincipalPermissionsAction(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateMoving ProvisioningState = "Moving" + ProvisioningStateRunning ProvisioningState = "Running" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateMoving), + string(ProvisioningStateRunning), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "moving": ProvisioningStateMoving, + "running": ProvisioningStateRunning, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type Reason string + +const ( + ReasonAlreadyExists Reason = "AlreadyExists" + ReasonInvalid Reason = "Invalid" +) + +func PossibleValuesForReason() []string { + return []string{ + string(ReasonAlreadyExists), + string(ReasonInvalid), + } +} + +func (s *Reason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReason(input string) (*Reason, error) { + vals := map[string]Reason{ + "alreadyexists": ReasonAlreadyExists, + "invalid": ReasonInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Reason(input) + return &out, nil +} + +type ScriptLevel string + +const ( + ScriptLevelCluster ScriptLevel = "Cluster" + ScriptLevelDatabase ScriptLevel = "Database" +) + +func PossibleValuesForScriptLevel() []string { + return []string{ + string(ScriptLevelCluster), + string(ScriptLevelDatabase), + } +} + +func (s *ScriptLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScriptLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScriptLevel(input string) (*ScriptLevel, error) { + vals := map[string]ScriptLevel{ + "cluster": ScriptLevelCluster, + "database": ScriptLevelDatabase, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScriptLevel(input) + return &out, nil +} + +type ScriptType string + +const ( + ScriptTypeMicrosoftPointKustoClustersDatabasesScripts ScriptType = "Microsoft.Kusto/clusters/databases/scripts" +) + +func PossibleValuesForScriptType() []string { + return []string{ + string(ScriptTypeMicrosoftPointKustoClustersDatabasesScripts), + } +} + +func (s *ScriptType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScriptType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScriptType(input string) (*ScriptType, error) { + vals := map[string]ScriptType{ + "microsoft.kusto/clusters/databases/scripts": ScriptTypeMicrosoftPointKustoClustersDatabasesScripts, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScriptType(input) + return &out, nil +} diff --git a/resource-manager/kusto/2024-04-13/scripts/id_script.go b/resource-manager/kusto/2024-04-13/scripts/id_script.go new file mode 100644 index 00000000000..cc8900790fa --- /dev/null +++ b/resource-manager/kusto/2024-04-13/scripts/id_script.go @@ -0,0 +1,148 @@ +package scripts + +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(&ScriptId{}) +} + +var _ resourceids.ResourceId = &ScriptId{} + +// ScriptId is a struct representing the Resource ID for a Script +type ScriptId struct { + SubscriptionId string + ResourceGroupName string + ClusterName string + DatabaseName string + ScriptName string +} + +// NewScriptID returns a new ScriptId struct +func NewScriptID(subscriptionId string, resourceGroupName string, clusterName string, databaseName string, scriptName string) ScriptId { + return ScriptId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ClusterName: clusterName, + DatabaseName: databaseName, + ScriptName: scriptName, + } +} + +// ParseScriptID parses 'input' into a ScriptId +func ParseScriptID(input string) (*ScriptId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScriptId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScriptId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseScriptIDInsensitively parses 'input' case-insensitively into a ScriptId +// note: this method should only be used for API response data and not user input +func ParseScriptIDInsensitively(input string) (*ScriptId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScriptId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScriptId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ScriptId) 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.ClusterName, ok = input.Parsed["clusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "clusterName", input) + } + + if id.DatabaseName, ok = input.Parsed["databaseName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseName", input) + } + + if id.ScriptName, ok = input.Parsed["scriptName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "scriptName", input) + } + + return nil +} + +// ValidateScriptID checks that 'input' can be parsed as a Script ID +func ValidateScriptID(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 := ParseScriptID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Script ID +func (id ScriptId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Kusto/clusters/%s/databases/%s/scripts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName, id.DatabaseName, id.ScriptName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Script ID +func (id ScriptId) 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("staticMicrosoftKusto", "Microsoft.Kusto", "Microsoft.Kusto"), + resourceids.StaticSegment("staticClusters", "clusters", "clusters"), + resourceids.UserSpecifiedSegment("clusterName", "clusterName"), + resourceids.StaticSegment("staticDatabases", "databases", "databases"), + resourceids.UserSpecifiedSegment("databaseName", "databaseName"), + resourceids.StaticSegment("staticScripts", "scripts", "scripts"), + resourceids.UserSpecifiedSegment("scriptName", "scriptName"), + } +} + +// String returns a human-readable description of this Script ID +func (id ScriptId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cluster Name: %q", id.ClusterName), + fmt.Sprintf("Database Name: %q", id.DatabaseName), + fmt.Sprintf("Script Name: %q", id.ScriptName), + } + return fmt.Sprintf("Script (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/kusto/2024-04-13/scripts/id_script_test.go b/resource-manager/kusto/2024-04-13/scripts/id_script_test.go new file mode 100644 index 00000000000..891be4759ea --- /dev/null +++ b/resource-manager/kusto/2024-04-13/scripts/id_script_test.go @@ -0,0 +1,372 @@ +package scripts + +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 = &ScriptId{} + +func TestNewScriptID(t *testing.T) { + id := NewScriptID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName", "scriptName") + + 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.ClusterName != "clusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterName") + } + + if id.DatabaseName != "databaseName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseName'", id.DatabaseName, "databaseName") + } + + if id.ScriptName != "scriptName" { + t.Fatalf("Expected %q but got %q for Segment 'ScriptName'", id.ScriptName, "scriptName") + } +} + +func TestFormatScriptID(t *testing.T) { + actual := NewScriptID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterName", "databaseName", "scriptName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName/scripts/scriptName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseScriptID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScriptId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName/scripts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName/scripts/scriptName", + Expected: &ScriptId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + DatabaseName: "databaseName", + ScriptName: "scriptName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName/scripts/scriptName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScriptID(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.DatabaseName != v.Expected.DatabaseName { + t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) + } + + if actual.ScriptName != v.Expected.ScriptName { + t.Fatalf("Expected %q but got %q for ScriptName", v.Expected.ScriptName, actual.ScriptName) + } + + } +} + +func TestParseScriptIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScriptId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/dAtAbAsEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/dAtAbAsEs/dAtAbAsEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName/scripts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/dAtAbAsEs/dAtAbAsEnAmE/sCrIpTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName/scripts/scriptName", + Expected: &ScriptId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ClusterName: "clusterName", + DatabaseName: "databaseName", + ScriptName: "scriptName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kusto/clusters/clusterName/databases/databaseName/scripts/scriptName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/dAtAbAsEs/dAtAbAsEnAmE/sCrIpTs/sCrIpTnAmE", + Expected: &ScriptId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ClusterName: "cLuStErNaMe", + DatabaseName: "dAtAbAsEnAmE", + ScriptName: "sCrIpTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUsTo/cLuStErS/cLuStErNaMe/dAtAbAsEs/dAtAbAsEnAmE/sCrIpTs/sCrIpTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScriptIDInsensitively(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.ClusterName != v.Expected.ClusterName { + t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + } + + if actual.DatabaseName != v.Expected.DatabaseName { + t.Fatalf("Expected %q but got %q for DatabaseName", v.Expected.DatabaseName, actual.DatabaseName) + } + + if actual.ScriptName != v.Expected.ScriptName { + t.Fatalf("Expected %q but got %q for ScriptName", v.Expected.ScriptName, actual.ScriptName) + } + + } +} + +func TestSegmentsForScriptId(t *testing.T) { + segments := ScriptId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ScriptId 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/kusto/2024-04-13/scripts/method_checknameavailability.go b/resource-manager/kusto/2024-04-13/scripts/method_checknameavailability.go new file mode 100644 index 00000000000..ed7cf0229b2 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/scripts/method_checknameavailability.go @@ -0,0 +1,59 @@ +package scripts + +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 CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameResult +} + +// CheckNameAvailability ... +func (c ScriptsClient) CheckNameAvailability(ctx context.Context, id commonids.KustoDatabaseId, input ScriptCheckNameRequest) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/scriptsCheckNameAvailability", 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 CheckNameResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/scripts/method_createorupdate.go b/resource-manager/kusto/2024-04-13/scripts/method_createorupdate.go new file mode 100644 index 00000000000..3e5928c5ea3 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/scripts/method_createorupdate.go @@ -0,0 +1,76 @@ +package scripts + +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 *Script +} + +// CreateOrUpdate ... +func (c ScriptsClient) CreateOrUpdate(ctx context.Context, id ScriptId, input Script) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ScriptsClient) CreateOrUpdateThenPoll(ctx context.Context, id ScriptId, input Script) 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/kusto/2024-04-13/scripts/method_delete.go b/resource-manager/kusto/2024-04-13/scripts/method_delete.go new file mode 100644 index 00000000000..c6d30e57ae6 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/scripts/method_delete.go @@ -0,0 +1,71 @@ +package scripts + +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 ScriptsClient) Delete(ctx context.Context, id ScriptId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ScriptsClient) DeleteThenPoll(ctx context.Context, id ScriptId) 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/kusto/2024-04-13/scripts/method_get.go b/resource-manager/kusto/2024-04-13/scripts/method_get.go new file mode 100644 index 00000000000..46a9dfe90a7 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/scripts/method_get.go @@ -0,0 +1,53 @@ +package scripts + +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 *Script +} + +// Get ... +func (c ScriptsClient) Get(ctx context.Context, id ScriptId) (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 Script + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/scripts/method_listbydatabase.go b/resource-manager/kusto/2024-04-13/scripts/method_listbydatabase.go new file mode 100644 index 00000000000..e3dfb29fefc --- /dev/null +++ b/resource-manager/kusto/2024-04-13/scripts/method_listbydatabase.go @@ -0,0 +1,55 @@ +package scripts + +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 ListByDatabaseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ScriptListResult +} + +// ListByDatabase ... +func (c ScriptsClient) ListByDatabase(ctx context.Context, id commonids.KustoDatabaseId) (result ListByDatabaseOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/scripts", 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 ScriptListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/kusto/2024-04-13/scripts/method_update.go b/resource-manager/kusto/2024-04-13/scripts/method_update.go new file mode 100644 index 00000000000..656fdc74404 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/scripts/method_update.go @@ -0,0 +1,75 @@ +package scripts + +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 *Script +} + +// Update ... +func (c ScriptsClient) Update(ctx context.Context, id ScriptId, input Script) (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 ScriptsClient) UpdateThenPoll(ctx context.Context, id ScriptId, input Script) 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/kusto/2024-04-13/scripts/model_checknameresult.go b/resource-manager/kusto/2024-04-13/scripts/model_checknameresult.go new file mode 100644 index 00000000000..f6390a72d51 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/scripts/model_checknameresult.go @@ -0,0 +1,11 @@ +package scripts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameResult struct { + Message *string `json:"message,omitempty"` + Name *string `json:"name,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *Reason `json:"reason,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/scripts/model_script.go b/resource-manager/kusto/2024-04-13/scripts/model_script.go new file mode 100644 index 00000000000..904bee61677 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/scripts/model_script.go @@ -0,0 +1,16 @@ +package scripts + +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 Script struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ScriptProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/scripts/model_scriptchecknamerequest.go b/resource-manager/kusto/2024-04-13/scripts/model_scriptchecknamerequest.go new file mode 100644 index 00000000000..7fa462b41d7 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/scripts/model_scriptchecknamerequest.go @@ -0,0 +1,9 @@ +package scripts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScriptCheckNameRequest struct { + Name string `json:"name"` + Type ScriptType `json:"type"` +} diff --git a/resource-manager/kusto/2024-04-13/scripts/model_scriptlistresult.go b/resource-manager/kusto/2024-04-13/scripts/model_scriptlistresult.go new file mode 100644 index 00000000000..caa95ca2324 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/scripts/model_scriptlistresult.go @@ -0,0 +1,8 @@ +package scripts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScriptListResult struct { + Value *[]Script `json:"value,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/scripts/model_scriptproperties.go b/resource-manager/kusto/2024-04-13/scripts/model_scriptproperties.go new file mode 100644 index 00000000000..25fa1fe5927 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/scripts/model_scriptproperties.go @@ -0,0 +1,15 @@ +package scripts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScriptProperties struct { + ContinueOnErrors *bool `json:"continueOnErrors,omitempty"` + ForceUpdateTag *string `json:"forceUpdateTag,omitempty"` + PrincipalPermissionsAction *PrincipalPermissionsAction `json:"principalPermissionsAction,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ScriptContent *string `json:"scriptContent,omitempty"` + ScriptLevel *ScriptLevel `json:"scriptLevel,omitempty"` + ScriptURL *string `json:"scriptUrl,omitempty"` + ScriptURLSasToken *string `json:"scriptUrlSasToken,omitempty"` +} diff --git a/resource-manager/kusto/2024-04-13/scripts/version.go b/resource-manager/kusto/2024-04-13/scripts/version.go new file mode 100644 index 00000000000..ff2b706a669 --- /dev/null +++ b/resource-manager/kusto/2024-04-13/scripts/version.go @@ -0,0 +1,10 @@ +package scripts + +// 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-04-13" + +func userAgent() string { + return "hashicorp/go-azure-sdk/scripts/2024-04-13" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/client.go new file mode 100644 index 00000000000..b3df993053d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/client.go @@ -0,0 +1,298 @@ +package v2024_10_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/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/operations" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + ClusterRecoveryPoint *clusterrecoverypoint.ClusterRecoveryPointClient + ClusterRecoveryPoints *clusterrecoverypoints.ClusterRecoveryPointsClient + MigrationRecoveryPoints *migrationrecoverypoints.MigrationRecoveryPointsClient + Operations *operations.OperationsClient + RecoveryPoints *recoverypoints.RecoveryPointsClient + ReplicationAlertSettings *replicationalertsettings.ReplicationAlertSettingsClient + ReplicationAppliances *replicationappliances.ReplicationAppliancesClient + ReplicationEligibilityResults *replicationeligibilityresults.ReplicationEligibilityResultsClient + ReplicationEvents *replicationevents.ReplicationEventsClient + ReplicationFabrics *replicationfabrics.ReplicationFabricsClient + ReplicationJobs *replicationjobs.ReplicationJobsClient + ReplicationLogicalNetworks *replicationlogicalnetworks.ReplicationLogicalNetworksClient + ReplicationMigrationItems *replicationmigrationitems.ReplicationMigrationItemsClient + ReplicationNetworkMappings *replicationnetworkmappings.ReplicationNetworkMappingsClient + ReplicationNetworks *replicationnetworks.ReplicationNetworksClient + ReplicationPolicies *replicationpolicies.ReplicationPoliciesClient + ReplicationProtectableItems *replicationprotectableitems.ReplicationProtectableItemsClient + ReplicationProtectedItems *replicationprotecteditems.ReplicationProtectedItemsClient + ReplicationProtectionClusters *replicationprotectionclusters.ReplicationProtectionClustersClient + ReplicationProtectionContainerMappings *replicationprotectioncontainermappings.ReplicationProtectionContainerMappingsClient + ReplicationProtectionContainers *replicationprotectioncontainers.ReplicationProtectionContainersClient + ReplicationProtectionIntents *replicationprotectionintents.ReplicationProtectionIntentsClient + ReplicationRecoveryPlans *replicationrecoveryplans.ReplicationRecoveryPlansClient + ReplicationRecoveryServicesProviders *replicationrecoveryservicesproviders.ReplicationRecoveryServicesProvidersClient + ReplicationStorageClassificationMappings *replicationstorageclassificationmappings.ReplicationStorageClassificationMappingsClient + ReplicationStorageClassifications *replicationstorageclassifications.ReplicationStorageClassificationsClient + ReplicationVaultHealth *replicationvaulthealth.ReplicationVaultHealthClient + ReplicationVaultSetting *replicationvaultsetting.ReplicationVaultSettingClient + ReplicationvCenters *replicationvcenters.ReplicationvCentersClient + SupportedOperatingSystems *supportedoperatingsystems.SupportedOperatingSystemsClient + TargetComputeSizes *targetcomputesizes.TargetComputeSizesClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + clusterRecoveryPointClient, err := clusterrecoverypoint.NewClusterRecoveryPointClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ClusterRecoveryPoint client: %+v", err) + } + configureFunc(clusterRecoveryPointClient.Client) + + clusterRecoveryPointsClient, err := clusterrecoverypoints.NewClusterRecoveryPointsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ClusterRecoveryPoints client: %+v", err) + } + configureFunc(clusterRecoveryPointsClient.Client) + + migrationRecoveryPointsClient, err := migrationrecoverypoints.NewMigrationRecoveryPointsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building MigrationRecoveryPoints client: %+v", err) + } + configureFunc(migrationRecoveryPointsClient.Client) + + operationsClient, err := operations.NewOperationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Operations client: %+v", err) + } + configureFunc(operationsClient.Client) + + recoveryPointsClient, err := recoverypoints.NewRecoveryPointsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building RecoveryPoints client: %+v", err) + } + configureFunc(recoveryPointsClient.Client) + + replicationAlertSettingsClient, err := replicationalertsettings.NewReplicationAlertSettingsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationAlertSettings client: %+v", err) + } + configureFunc(replicationAlertSettingsClient.Client) + + replicationAppliancesClient, err := replicationappliances.NewReplicationAppliancesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationAppliances client: %+v", err) + } + configureFunc(replicationAppliancesClient.Client) + + replicationEligibilityResultsClient, err := replicationeligibilityresults.NewReplicationEligibilityResultsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationEligibilityResults client: %+v", err) + } + configureFunc(replicationEligibilityResultsClient.Client) + + replicationEventsClient, err := replicationevents.NewReplicationEventsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationEvents client: %+v", err) + } + configureFunc(replicationEventsClient.Client) + + replicationFabricsClient, err := replicationfabrics.NewReplicationFabricsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationFabrics client: %+v", err) + } + configureFunc(replicationFabricsClient.Client) + + replicationJobsClient, err := replicationjobs.NewReplicationJobsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationJobs client: %+v", err) + } + configureFunc(replicationJobsClient.Client) + + replicationLogicalNetworksClient, err := replicationlogicalnetworks.NewReplicationLogicalNetworksClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationLogicalNetworks client: %+v", err) + } + configureFunc(replicationLogicalNetworksClient.Client) + + replicationMigrationItemsClient, err := replicationmigrationitems.NewReplicationMigrationItemsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationMigrationItems client: %+v", err) + } + configureFunc(replicationMigrationItemsClient.Client) + + replicationNetworkMappingsClient, err := replicationnetworkmappings.NewReplicationNetworkMappingsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationNetworkMappings client: %+v", err) + } + configureFunc(replicationNetworkMappingsClient.Client) + + replicationNetworksClient, err := replicationnetworks.NewReplicationNetworksClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationNetworks client: %+v", err) + } + configureFunc(replicationNetworksClient.Client) + + replicationPoliciesClient, err := replicationpolicies.NewReplicationPoliciesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationPolicies client: %+v", err) + } + configureFunc(replicationPoliciesClient.Client) + + replicationProtectableItemsClient, err := replicationprotectableitems.NewReplicationProtectableItemsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationProtectableItems client: %+v", err) + } + configureFunc(replicationProtectableItemsClient.Client) + + replicationProtectedItemsClient, err := replicationprotecteditems.NewReplicationProtectedItemsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationProtectedItems client: %+v", err) + } + configureFunc(replicationProtectedItemsClient.Client) + + replicationProtectionClustersClient, err := replicationprotectionclusters.NewReplicationProtectionClustersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationProtectionClusters client: %+v", err) + } + configureFunc(replicationProtectionClustersClient.Client) + + replicationProtectionContainerMappingsClient, err := replicationprotectioncontainermappings.NewReplicationProtectionContainerMappingsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationProtectionContainerMappings client: %+v", err) + } + configureFunc(replicationProtectionContainerMappingsClient.Client) + + replicationProtectionContainersClient, err := replicationprotectioncontainers.NewReplicationProtectionContainersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationProtectionContainers client: %+v", err) + } + configureFunc(replicationProtectionContainersClient.Client) + + replicationProtectionIntentsClient, err := replicationprotectionintents.NewReplicationProtectionIntentsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationProtectionIntents client: %+v", err) + } + configureFunc(replicationProtectionIntentsClient.Client) + + replicationRecoveryPlansClient, err := replicationrecoveryplans.NewReplicationRecoveryPlansClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationRecoveryPlans client: %+v", err) + } + configureFunc(replicationRecoveryPlansClient.Client) + + replicationRecoveryServicesProvidersClient, err := replicationrecoveryservicesproviders.NewReplicationRecoveryServicesProvidersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationRecoveryServicesProviders client: %+v", err) + } + configureFunc(replicationRecoveryServicesProvidersClient.Client) + + replicationStorageClassificationMappingsClient, err := replicationstorageclassificationmappings.NewReplicationStorageClassificationMappingsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationStorageClassificationMappings client: %+v", err) + } + configureFunc(replicationStorageClassificationMappingsClient.Client) + + replicationStorageClassificationsClient, err := replicationstorageclassifications.NewReplicationStorageClassificationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationStorageClassifications client: %+v", err) + } + configureFunc(replicationStorageClassificationsClient.Client) + + replicationVaultHealthClient, err := replicationvaulthealth.NewReplicationVaultHealthClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationVaultHealth client: %+v", err) + } + configureFunc(replicationVaultHealthClient.Client) + + replicationVaultSettingClient, err := replicationvaultsetting.NewReplicationVaultSettingClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationVaultSetting client: %+v", err) + } + configureFunc(replicationVaultSettingClient.Client) + + replicationvCentersClient, err := replicationvcenters.NewReplicationvCentersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationvCenters client: %+v", err) + } + configureFunc(replicationvCentersClient.Client) + + supportedOperatingSystemsClient, err := supportedoperatingsystems.NewSupportedOperatingSystemsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SupportedOperatingSystems client: %+v", err) + } + configureFunc(supportedOperatingSystemsClient.Client) + + targetComputeSizesClient, err := targetcomputesizes.NewTargetComputeSizesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building TargetComputeSizes client: %+v", err) + } + configureFunc(targetComputeSizesClient.Client) + + return &Client{ + ClusterRecoveryPoint: clusterRecoveryPointClient, + ClusterRecoveryPoints: clusterRecoveryPointsClient, + MigrationRecoveryPoints: migrationRecoveryPointsClient, + Operations: operationsClient, + RecoveryPoints: recoveryPointsClient, + ReplicationAlertSettings: replicationAlertSettingsClient, + ReplicationAppliances: replicationAppliancesClient, + ReplicationEligibilityResults: replicationEligibilityResultsClient, + ReplicationEvents: replicationEventsClient, + ReplicationFabrics: replicationFabricsClient, + ReplicationJobs: replicationJobsClient, + ReplicationLogicalNetworks: replicationLogicalNetworksClient, + ReplicationMigrationItems: replicationMigrationItemsClient, + ReplicationNetworkMappings: replicationNetworkMappingsClient, + ReplicationNetworks: replicationNetworksClient, + ReplicationPolicies: replicationPoliciesClient, + ReplicationProtectableItems: replicationProtectableItemsClient, + ReplicationProtectedItems: replicationProtectedItemsClient, + ReplicationProtectionClusters: replicationProtectionClustersClient, + ReplicationProtectionContainerMappings: replicationProtectionContainerMappingsClient, + ReplicationProtectionContainers: replicationProtectionContainersClient, + ReplicationProtectionIntents: replicationProtectionIntentsClient, + ReplicationRecoveryPlans: replicationRecoveryPlansClient, + ReplicationRecoveryServicesProviders: replicationRecoveryServicesProvidersClient, + ReplicationStorageClassificationMappings: replicationStorageClassificationMappingsClient, + ReplicationStorageClassifications: replicationStorageClassificationsClient, + ReplicationVaultHealth: replicationVaultHealthClient, + ReplicationVaultSetting: replicationVaultSettingClient, + ReplicationvCenters: replicationvCentersClient, + SupportedOperatingSystems: supportedOperatingSystemsClient, + TargetComputeSizes: targetComputeSizesClient, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/README.md new file mode 100644 index 00000000000..08cd03b5c49 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint` Documentation + +The `clusterrecoverypoint` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint" +``` + + +### Client Initialization + +```go +client := clusterrecoverypoint.NewClusterRecoveryPointClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ClusterRecoveryPointClient.Get` + +```go +ctx := context.TODO() +id := clusterrecoverypoint.NewReplicationProtectionClusterRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName", "recoveryPointName") + +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 +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/client.go new file mode 100644 index 00000000000..c1b0f34229e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/client.go @@ -0,0 +1,26 @@ +package clusterrecoverypoint + +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 ClusterRecoveryPointClient struct { + Client *resourcemanager.Client +} + +func NewClusterRecoveryPointClientWithBaseURI(sdkApi sdkEnv.Api) (*ClusterRecoveryPointClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "clusterrecoverypoint", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ClusterRecoveryPointClient: %+v", err) + } + + return &ClusterRecoveryPointClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/constants.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/constants.go new file mode 100644 index 00000000000..fc7e79ed34c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/constants.go @@ -0,0 +1,92 @@ +package clusterrecoverypoint + +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 ClusterRecoveryPointType string + +const ( + ClusterRecoveryPointTypeApplicationConsistent ClusterRecoveryPointType = "ApplicationConsistent" + ClusterRecoveryPointTypeCrashConsistent ClusterRecoveryPointType = "CrashConsistent" + ClusterRecoveryPointTypeNotSpecified ClusterRecoveryPointType = "NotSpecified" +) + +func PossibleValuesForClusterRecoveryPointType() []string { + return []string{ + string(ClusterRecoveryPointTypeApplicationConsistent), + string(ClusterRecoveryPointTypeCrashConsistent), + string(ClusterRecoveryPointTypeNotSpecified), + } +} + +func (s *ClusterRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterRecoveryPointType(input string) (*ClusterRecoveryPointType, error) { + vals := map[string]ClusterRecoveryPointType{ + "applicationconsistent": ClusterRecoveryPointTypeApplicationConsistent, + "crashconsistent": ClusterRecoveryPointTypeCrashConsistent, + "notspecified": ClusterRecoveryPointTypeNotSpecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterRecoveryPointType(input) + return &out, nil +} + +type RecoveryPointSyncType string + +const ( + RecoveryPointSyncTypeMultiVMSyncRecoveryPoint RecoveryPointSyncType = "MultiVmSyncRecoveryPoint" +) + +func PossibleValuesForRecoveryPointSyncType() []string { + return []string{ + string(RecoveryPointSyncTypeMultiVMSyncRecoveryPoint), + } +} + +func (s *RecoveryPointSyncType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecoveryPointSyncType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecoveryPointSyncType(input string) (*RecoveryPointSyncType, error) { + vals := map[string]RecoveryPointSyncType{ + "multivmsyncrecoverypoint": RecoveryPointSyncTypeMultiVMSyncRecoveryPoint, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointSyncType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/id_replicationprotectionclusterrecoverypoint.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/id_replicationprotectionclusterrecoverypoint.go new file mode 100644 index 00000000000..cb85902f9a5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/id_replicationprotectionclusterrecoverypoint.go @@ -0,0 +1,166 @@ +package clusterrecoverypoint + +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(&ReplicationProtectionClusterRecoveryPointId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectionClusterRecoveryPointId{} + +// ReplicationProtectionClusterRecoveryPointId is a struct representing the Resource ID for a Replication Protection Cluster Recovery Point +type ReplicationProtectionClusterRecoveryPointId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectionClusterName string + RecoveryPointName string +} + +// NewReplicationProtectionClusterRecoveryPointID returns a new ReplicationProtectionClusterRecoveryPointId struct +func NewReplicationProtectionClusterRecoveryPointID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectionClusterName string, recoveryPointName string) ReplicationProtectionClusterRecoveryPointId { + return ReplicationProtectionClusterRecoveryPointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectionClusterName: replicationProtectionClusterName, + RecoveryPointName: recoveryPointName, + } +} + +// ParseReplicationProtectionClusterRecoveryPointID parses 'input' into a ReplicationProtectionClusterRecoveryPointId +func ParseReplicationProtectionClusterRecoveryPointID(input string) (*ReplicationProtectionClusterRecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionClusterRecoveryPointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionClusterRecoveryPointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionClusterRecoveryPointIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionClusterRecoveryPointId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionClusterRecoveryPointIDInsensitively(input string) (*ReplicationProtectionClusterRecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionClusterRecoveryPointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionClusterRecoveryPointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionClusterRecoveryPointId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectionClusterName, ok = input.Parsed["replicationProtectionClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionClusterName", input) + } + + if id.RecoveryPointName, ok = input.Parsed["recoveryPointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "recoveryPointName", input) + } + + return nil +} + +// ValidateReplicationProtectionClusterRecoveryPointID checks that 'input' can be parsed as a Replication Protection Cluster Recovery Point ID +func ValidateReplicationProtectionClusterRecoveryPointID(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 := ParseReplicationProtectionClusterRecoveryPointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Cluster Recovery Point ID +func (id ReplicationProtectionClusterRecoveryPointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectionClusters/%s/recoveryPoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectionClusterName, id.RecoveryPointName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Cluster Recovery Point ID +func (id ReplicationProtectionClusterRecoveryPointId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationProtectionClusters", "replicationProtectionClusters", "replicationProtectionClusters"), + resourceids.UserSpecifiedSegment("replicationProtectionClusterName", "replicationProtectionClusterName"), + resourceids.StaticSegment("staticRecoveryPoints", "recoveryPoints", "recoveryPoints"), + resourceids.UserSpecifiedSegment("recoveryPointName", "recoveryPointName"), + } +} + +// String returns a human-readable description of this Replication Protection Cluster Recovery Point ID +func (id ReplicationProtectionClusterRecoveryPointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protection Cluster Name: %q", id.ReplicationProtectionClusterName), + fmt.Sprintf("Recovery Point Name: %q", id.RecoveryPointName), + } + return fmt.Sprintf("Replication Protection Cluster Recovery Point (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/id_replicationprotectionclusterrecoverypoint_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/id_replicationprotectionclusterrecoverypoint_test.go new file mode 100644 index 00000000000..976ddec572b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/id_replicationprotectionclusterrecoverypoint_test.go @@ -0,0 +1,462 @@ +package clusterrecoverypoint + +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 = &ReplicationProtectionClusterRecoveryPointId{} + +func TestNewReplicationProtectionClusterRecoveryPointID(t *testing.T) { + id := NewReplicationProtectionClusterRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName", "recoveryPointName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationProtectionClusterName != "replicationProtectionClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionClusterName'", id.ReplicationProtectionClusterName, "replicationProtectionClusterName") + } + + if id.RecoveryPointName != "recoveryPointName" { + t.Fatalf("Expected %q but got %q for Segment 'RecoveryPointName'", id.RecoveryPointName, "recoveryPointName") + } +} + +func TestFormatReplicationProtectionClusterRecoveryPointID(t *testing.T) { + actual := NewReplicationProtectionClusterRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName", "recoveryPointName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName/recoveryPoints/recoveryPointName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionClusterRecoveryPointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionClusterRecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName/recoveryPoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName/recoveryPoints/recoveryPointName", + Expected: &ReplicationProtectionClusterRecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectionClusterName: "replicationProtectionClusterName", + RecoveryPointName: "recoveryPointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName/recoveryPoints/recoveryPointName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionClusterRecoveryPointID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectionClusterName != v.Expected.ReplicationProtectionClusterName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionClusterName", v.Expected.ReplicationProtectionClusterName, actual.ReplicationProtectionClusterName) + } + + if actual.RecoveryPointName != v.Expected.RecoveryPointName { + t.Fatalf("Expected %q but got %q for RecoveryPointName", v.Expected.RecoveryPointName, actual.RecoveryPointName) + } + + } +} + +func TestParseReplicationProtectionClusterRecoveryPointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionClusterRecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnClUsTeRs/rEpLiCaTiOnPrOtEcTiOnClUsTeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName/recoveryPoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnClUsTeRs/rEpLiCaTiOnPrOtEcTiOnClUsTeRnAmE/rEcOvErYpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName/recoveryPoints/recoveryPointName", + Expected: &ReplicationProtectionClusterRecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectionClusterName: "replicationProtectionClusterName", + RecoveryPointName: "recoveryPointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName/recoveryPoints/recoveryPointName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnClUsTeRs/rEpLiCaTiOnPrOtEcTiOnClUsTeRnAmE/rEcOvErYpOiNtS/rEcOvErYpOiNtNaMe", + Expected: &ReplicationProtectionClusterRecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationProtectionClusterName: "rEpLiCaTiOnPrOtEcTiOnClUsTeRnAmE", + RecoveryPointName: "rEcOvErYpOiNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnClUsTeRs/rEpLiCaTiOnPrOtEcTiOnClUsTeRnAmE/rEcOvErYpOiNtS/rEcOvErYpOiNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionClusterRecoveryPointIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectionClusterName != v.Expected.ReplicationProtectionClusterName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionClusterName", v.Expected.ReplicationProtectionClusterName, actual.ReplicationProtectionClusterName) + } + + if actual.RecoveryPointName != v.Expected.RecoveryPointName { + t.Fatalf("Expected %q but got %q for RecoveryPointName", v.Expected.RecoveryPointName, actual.RecoveryPointName) + } + + } +} + +func TestSegmentsForReplicationProtectionClusterRecoveryPointId(t *testing.T) { + segments := ReplicationProtectionClusterRecoveryPointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionClusterRecoveryPointId 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/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/method_get.go new file mode 100644 index 00000000000..a7d9c730960 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/method_get.go @@ -0,0 +1,53 @@ +package clusterrecoverypoint + +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 *ClusterRecoveryPoint +} + +// Get ... +func (c ClusterRecoveryPointClient) Get(ctx context.Context, id ReplicationProtectionClusterRecoveryPointId) (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 ClusterRecoveryPoint + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/model_a2aclusterrecoverypointdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/model_a2aclusterrecoverypointdetails.go new file mode 100644 index 00000000000..db94ef72233 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/model_a2aclusterrecoverypointdetails.go @@ -0,0 +1,51 @@ +package clusterrecoverypoint + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ClusterProviderSpecificRecoveryPointDetails = A2AClusterRecoveryPointDetails{} + +type A2AClusterRecoveryPointDetails struct { + Nodes *[]string `json:"nodes,omitempty"` + RecoveryPointSyncType *RecoveryPointSyncType `json:"recoveryPointSyncType,omitempty"` + + // Fields inherited from ClusterProviderSpecificRecoveryPointDetails + + InstanceType string `json:"instanceType"` +} + +func (s A2AClusterRecoveryPointDetails) ClusterProviderSpecificRecoveryPointDetails() BaseClusterProviderSpecificRecoveryPointDetailsImpl { + return BaseClusterProviderSpecificRecoveryPointDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AClusterRecoveryPointDetails{} + +func (s A2AClusterRecoveryPointDetails) MarshalJSON() ([]byte, error) { + type wrapper A2AClusterRecoveryPointDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AClusterRecoveryPointDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AClusterRecoveryPointDetails: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AClusterRecoveryPointDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/model_clusterproviderspecificrecoverypointdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/model_clusterproviderspecificrecoverypointdetails.go new file mode 100644 index 00000000000..bfcc5f63051 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/model_clusterproviderspecificrecoverypointdetails.go @@ -0,0 +1,75 @@ +package clusterrecoverypoint + +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 ClusterProviderSpecificRecoveryPointDetails interface { + ClusterProviderSpecificRecoveryPointDetails() BaseClusterProviderSpecificRecoveryPointDetailsImpl +} + +var _ ClusterProviderSpecificRecoveryPointDetails = BaseClusterProviderSpecificRecoveryPointDetailsImpl{} + +type BaseClusterProviderSpecificRecoveryPointDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseClusterProviderSpecificRecoveryPointDetailsImpl) ClusterProviderSpecificRecoveryPointDetails() BaseClusterProviderSpecificRecoveryPointDetailsImpl { + return s +} + +var _ ClusterProviderSpecificRecoveryPointDetails = RawClusterProviderSpecificRecoveryPointDetailsImpl{} + +// RawClusterProviderSpecificRecoveryPointDetailsImpl 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 RawClusterProviderSpecificRecoveryPointDetailsImpl struct { + clusterProviderSpecificRecoveryPointDetails BaseClusterProviderSpecificRecoveryPointDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawClusterProviderSpecificRecoveryPointDetailsImpl) ClusterProviderSpecificRecoveryPointDetails() BaseClusterProviderSpecificRecoveryPointDetailsImpl { + return s.clusterProviderSpecificRecoveryPointDetails +} + +func UnmarshalClusterProviderSpecificRecoveryPointDetailsImplementation(input []byte) (ClusterProviderSpecificRecoveryPointDetails, 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 ClusterProviderSpecificRecoveryPointDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AClusterRecoveryPointDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AClusterRecoveryPointDetails: %+v", err) + } + return out, nil + } + + var parent BaseClusterProviderSpecificRecoveryPointDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseClusterProviderSpecificRecoveryPointDetailsImpl: %+v", err) + } + + return RawClusterProviderSpecificRecoveryPointDetailsImpl{ + clusterProviderSpecificRecoveryPointDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/model_clusterrecoverypoint.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/model_clusterrecoverypoint.go new file mode 100644 index 00000000000..26af7a4d2f4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/model_clusterrecoverypoint.go @@ -0,0 +1,11 @@ +package clusterrecoverypoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterRecoveryPoint struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ClusterRecoveryPointProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/model_clusterrecoverypointproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/model_clusterrecoverypointproperties.go new file mode 100644 index 00000000000..2ebe7e7f91a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/model_clusterrecoverypointproperties.go @@ -0,0 +1,60 @@ +package clusterrecoverypoint + +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. + +type ClusterRecoveryPointProperties struct { + ProviderSpecificDetails ClusterProviderSpecificRecoveryPointDetails `json:"providerSpecificDetails"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *ClusterRecoveryPointType `json:"recoveryPointType,omitempty"` +} + +func (o *ClusterRecoveryPointProperties) GetRecoveryPointTimeAsTime() (*time.Time, error) { + if o.RecoveryPointTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RecoveryPointTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ClusterRecoveryPointProperties) SetRecoveryPointTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RecoveryPointTime = &formatted +} + +var _ json.Unmarshaler = &ClusterRecoveryPointProperties{} + +func (s *ClusterRecoveryPointProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *ClusterRecoveryPointType `json:"recoveryPointType,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.RecoveryPointTime = decoded.RecoveryPointTime + s.RecoveryPointType = decoded.RecoveryPointType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ClusterRecoveryPointProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalClusterProviderSpecificRecoveryPointDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ClusterRecoveryPointProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/version.go new file mode 100644 index 00000000000..73700087172 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoint/version.go @@ -0,0 +1,10 @@ +package clusterrecoverypoint + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/clusterrecoverypoint/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/README.md new file mode 100644 index 00000000000..f073c0772b2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints` Documentation + +The `clusterrecoverypoints` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints" +``` + + +### Client Initialization + +```go +client := clusterrecoverypoints.NewClusterRecoveryPointsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ClusterRecoveryPointsClient.ListByReplicationProtectionCluster` + +```go +ctx := context.TODO() +id := clusterrecoverypoints.NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + +// alternatively `client.ListByReplicationProtectionCluster(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationProtectionClusterComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/client.go new file mode 100644 index 00000000000..9ffb1251268 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/client.go @@ -0,0 +1,26 @@ +package clusterrecoverypoints + +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 ClusterRecoveryPointsClient struct { + Client *resourcemanager.Client +} + +func NewClusterRecoveryPointsClientWithBaseURI(sdkApi sdkEnv.Api) (*ClusterRecoveryPointsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "clusterrecoverypoints", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ClusterRecoveryPointsClient: %+v", err) + } + + return &ClusterRecoveryPointsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/constants.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/constants.go new file mode 100644 index 00000000000..5c894467f6c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/constants.go @@ -0,0 +1,92 @@ +package clusterrecoverypoints + +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 ClusterRecoveryPointType string + +const ( + ClusterRecoveryPointTypeApplicationConsistent ClusterRecoveryPointType = "ApplicationConsistent" + ClusterRecoveryPointTypeCrashConsistent ClusterRecoveryPointType = "CrashConsistent" + ClusterRecoveryPointTypeNotSpecified ClusterRecoveryPointType = "NotSpecified" +) + +func PossibleValuesForClusterRecoveryPointType() []string { + return []string{ + string(ClusterRecoveryPointTypeApplicationConsistent), + string(ClusterRecoveryPointTypeCrashConsistent), + string(ClusterRecoveryPointTypeNotSpecified), + } +} + +func (s *ClusterRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterRecoveryPointType(input string) (*ClusterRecoveryPointType, error) { + vals := map[string]ClusterRecoveryPointType{ + "applicationconsistent": ClusterRecoveryPointTypeApplicationConsistent, + "crashconsistent": ClusterRecoveryPointTypeCrashConsistent, + "notspecified": ClusterRecoveryPointTypeNotSpecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterRecoveryPointType(input) + return &out, nil +} + +type RecoveryPointSyncType string + +const ( + RecoveryPointSyncTypeMultiVMSyncRecoveryPoint RecoveryPointSyncType = "MultiVmSyncRecoveryPoint" +) + +func PossibleValuesForRecoveryPointSyncType() []string { + return []string{ + string(RecoveryPointSyncTypeMultiVMSyncRecoveryPoint), + } +} + +func (s *RecoveryPointSyncType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecoveryPointSyncType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecoveryPointSyncType(input string) (*RecoveryPointSyncType, error) { + vals := map[string]RecoveryPointSyncType{ + "multivmsyncrecoverypoint": RecoveryPointSyncTypeMultiVMSyncRecoveryPoint, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointSyncType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/id_replicationprotectioncluster.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/id_replicationprotectioncluster.go new file mode 100644 index 00000000000..7e5b399bbfb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/id_replicationprotectioncluster.go @@ -0,0 +1,157 @@ +package clusterrecoverypoints + +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(&ReplicationProtectionClusterId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectionClusterId{} + +// ReplicationProtectionClusterId is a struct representing the Resource ID for a Replication Protection Cluster +type ReplicationProtectionClusterId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectionClusterName string +} + +// NewReplicationProtectionClusterID returns a new ReplicationProtectionClusterId struct +func NewReplicationProtectionClusterID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectionClusterName string) ReplicationProtectionClusterId { + return ReplicationProtectionClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectionClusterName: replicationProtectionClusterName, + } +} + +// ParseReplicationProtectionClusterID parses 'input' into a ReplicationProtectionClusterId +func ParseReplicationProtectionClusterID(input string) (*ReplicationProtectionClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionClusterIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionClusterId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionClusterIDInsensitively(input string) (*ReplicationProtectionClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionClusterId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectionClusterName, ok = input.Parsed["replicationProtectionClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionClusterName", input) + } + + return nil +} + +// ValidateReplicationProtectionClusterID checks that 'input' can be parsed as a Replication Protection Cluster ID +func ValidateReplicationProtectionClusterID(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 := ParseReplicationProtectionClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Cluster ID +func (id ReplicationProtectionClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectionClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectionClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Cluster ID +func (id ReplicationProtectionClusterId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationProtectionClusters", "replicationProtectionClusters", "replicationProtectionClusters"), + resourceids.UserSpecifiedSegment("replicationProtectionClusterName", "replicationProtectionClusterName"), + } +} + +// String returns a human-readable description of this Replication Protection Cluster ID +func (id ReplicationProtectionClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protection Cluster Name: %q", id.ReplicationProtectionClusterName), + } + return fmt.Sprintf("Replication Protection Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/id_replicationprotectioncluster_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/id_replicationprotectioncluster_test.go new file mode 100644 index 00000000000..37dd3a94fa4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/id_replicationprotectioncluster_test.go @@ -0,0 +1,417 @@ +package clusterrecoverypoints + +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 = &ReplicationProtectionClusterId{} + +func TestNewReplicationProtectionClusterID(t *testing.T) { + id := NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationProtectionClusterName != "replicationProtectionClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionClusterName'", id.ReplicationProtectionClusterName, "replicationProtectionClusterName") + } +} + +func TestFormatReplicationProtectionClusterID(t *testing.T) { + actual := NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName", + Expected: &ReplicationProtectionClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectionClusterName: "replicationProtectionClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionClusterID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectionClusterName != v.Expected.ReplicationProtectionClusterName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionClusterName", v.Expected.ReplicationProtectionClusterName, actual.ReplicationProtectionClusterName) + } + + } +} + +func TestParseReplicationProtectionClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnClUsTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName", + Expected: &ReplicationProtectionClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectionClusterName: "replicationProtectionClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnClUsTeRs/rEpLiCaTiOnPrOtEcTiOnClUsTeRnAmE", + Expected: &ReplicationProtectionClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationProtectionClusterName: "rEpLiCaTiOnPrOtEcTiOnClUsTeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnClUsTeRs/rEpLiCaTiOnPrOtEcTiOnClUsTeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionClusterIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectionClusterName != v.Expected.ReplicationProtectionClusterName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionClusterName", v.Expected.ReplicationProtectionClusterName, actual.ReplicationProtectionClusterName) + } + + } +} + +func TestSegmentsForReplicationProtectionClusterId(t *testing.T) { + segments := ReplicationProtectionClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionClusterId 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/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/method_listbyreplicationprotectioncluster.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/method_listbyreplicationprotectioncluster.go new file mode 100644 index 00000000000..57582dc9c9d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/method_listbyreplicationprotectioncluster.go @@ -0,0 +1,105 @@ +package clusterrecoverypoints + +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 ListByReplicationProtectionClusterOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ClusterRecoveryPoint +} + +type ListByReplicationProtectionClusterCompleteResult struct { + LatestHttpResponse *http.Response + Items []ClusterRecoveryPoint +} + +type ListByReplicationProtectionClusterCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationProtectionClusterCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationProtectionCluster ... +func (c ClusterRecoveryPointsClient) ListByReplicationProtectionCluster(ctx context.Context, id ReplicationProtectionClusterId) (result ListByReplicationProtectionClusterOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationProtectionClusterCustomPager{}, + Path: fmt.Sprintf("%s/recoveryPoints", 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 *[]ClusterRecoveryPoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationProtectionClusterComplete retrieves all the results into a single object +func (c ClusterRecoveryPointsClient) ListByReplicationProtectionClusterComplete(ctx context.Context, id ReplicationProtectionClusterId) (ListByReplicationProtectionClusterCompleteResult, error) { + return c.ListByReplicationProtectionClusterCompleteMatchingPredicate(ctx, id, ClusterRecoveryPointOperationPredicate{}) +} + +// ListByReplicationProtectionClusterCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ClusterRecoveryPointsClient) ListByReplicationProtectionClusterCompleteMatchingPredicate(ctx context.Context, id ReplicationProtectionClusterId, predicate ClusterRecoveryPointOperationPredicate) (result ListByReplicationProtectionClusterCompleteResult, err error) { + items := make([]ClusterRecoveryPoint, 0) + + resp, err := c.ListByReplicationProtectionCluster(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 = ListByReplicationProtectionClusterCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/model_a2aclusterrecoverypointdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/model_a2aclusterrecoverypointdetails.go new file mode 100644 index 00000000000..4769a41a9ed --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/model_a2aclusterrecoverypointdetails.go @@ -0,0 +1,51 @@ +package clusterrecoverypoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ClusterProviderSpecificRecoveryPointDetails = A2AClusterRecoveryPointDetails{} + +type A2AClusterRecoveryPointDetails struct { + Nodes *[]string `json:"nodes,omitempty"` + RecoveryPointSyncType *RecoveryPointSyncType `json:"recoveryPointSyncType,omitempty"` + + // Fields inherited from ClusterProviderSpecificRecoveryPointDetails + + InstanceType string `json:"instanceType"` +} + +func (s A2AClusterRecoveryPointDetails) ClusterProviderSpecificRecoveryPointDetails() BaseClusterProviderSpecificRecoveryPointDetailsImpl { + return BaseClusterProviderSpecificRecoveryPointDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AClusterRecoveryPointDetails{} + +func (s A2AClusterRecoveryPointDetails) MarshalJSON() ([]byte, error) { + type wrapper A2AClusterRecoveryPointDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AClusterRecoveryPointDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AClusterRecoveryPointDetails: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AClusterRecoveryPointDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/model_clusterproviderspecificrecoverypointdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/model_clusterproviderspecificrecoverypointdetails.go new file mode 100644 index 00000000000..2187d2eaceb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/model_clusterproviderspecificrecoverypointdetails.go @@ -0,0 +1,75 @@ +package clusterrecoverypoints + +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 ClusterProviderSpecificRecoveryPointDetails interface { + ClusterProviderSpecificRecoveryPointDetails() BaseClusterProviderSpecificRecoveryPointDetailsImpl +} + +var _ ClusterProviderSpecificRecoveryPointDetails = BaseClusterProviderSpecificRecoveryPointDetailsImpl{} + +type BaseClusterProviderSpecificRecoveryPointDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseClusterProviderSpecificRecoveryPointDetailsImpl) ClusterProviderSpecificRecoveryPointDetails() BaseClusterProviderSpecificRecoveryPointDetailsImpl { + return s +} + +var _ ClusterProviderSpecificRecoveryPointDetails = RawClusterProviderSpecificRecoveryPointDetailsImpl{} + +// RawClusterProviderSpecificRecoveryPointDetailsImpl 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 RawClusterProviderSpecificRecoveryPointDetailsImpl struct { + clusterProviderSpecificRecoveryPointDetails BaseClusterProviderSpecificRecoveryPointDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawClusterProviderSpecificRecoveryPointDetailsImpl) ClusterProviderSpecificRecoveryPointDetails() BaseClusterProviderSpecificRecoveryPointDetailsImpl { + return s.clusterProviderSpecificRecoveryPointDetails +} + +func UnmarshalClusterProviderSpecificRecoveryPointDetailsImplementation(input []byte) (ClusterProviderSpecificRecoveryPointDetails, 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 ClusterProviderSpecificRecoveryPointDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AClusterRecoveryPointDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AClusterRecoveryPointDetails: %+v", err) + } + return out, nil + } + + var parent BaseClusterProviderSpecificRecoveryPointDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseClusterProviderSpecificRecoveryPointDetailsImpl: %+v", err) + } + + return RawClusterProviderSpecificRecoveryPointDetailsImpl{ + clusterProviderSpecificRecoveryPointDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/model_clusterrecoverypoint.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/model_clusterrecoverypoint.go new file mode 100644 index 00000000000..9790bb86a63 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/model_clusterrecoverypoint.go @@ -0,0 +1,11 @@ +package clusterrecoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterRecoveryPoint struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ClusterRecoveryPointProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/model_clusterrecoverypointproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/model_clusterrecoverypointproperties.go new file mode 100644 index 00000000000..46ff451b24e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/model_clusterrecoverypointproperties.go @@ -0,0 +1,60 @@ +package clusterrecoverypoints + +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. + +type ClusterRecoveryPointProperties struct { + ProviderSpecificDetails ClusterProviderSpecificRecoveryPointDetails `json:"providerSpecificDetails"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *ClusterRecoveryPointType `json:"recoveryPointType,omitempty"` +} + +func (o *ClusterRecoveryPointProperties) GetRecoveryPointTimeAsTime() (*time.Time, error) { + if o.RecoveryPointTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RecoveryPointTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ClusterRecoveryPointProperties) SetRecoveryPointTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RecoveryPointTime = &formatted +} + +var _ json.Unmarshaler = &ClusterRecoveryPointProperties{} + +func (s *ClusterRecoveryPointProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *ClusterRecoveryPointType `json:"recoveryPointType,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.RecoveryPointTime = decoded.RecoveryPointTime + s.RecoveryPointType = decoded.RecoveryPointType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ClusterRecoveryPointProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalClusterProviderSpecificRecoveryPointDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ClusterRecoveryPointProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/predicates.go new file mode 100644 index 00000000000..acad5aeb606 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/predicates.go @@ -0,0 +1,27 @@ +package clusterrecoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterRecoveryPointOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ClusterRecoveryPointOperationPredicate) Matches(input ClusterRecoveryPoint) 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/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/version.go new file mode 100644 index 00000000000..340f161742d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/clusterrecoverypoints/version.go @@ -0,0 +1,10 @@ +package clusterrecoverypoints + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/clusterrecoverypoints/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/README.md new file mode 100644 index 00000000000..7fd91c40073 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints` Documentation + +The `migrationrecoverypoints` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints" +``` + + +### Client Initialization + +```go +client := migrationrecoverypoints.NewMigrationRecoveryPointsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `MigrationRecoveryPointsClient.Get` + +```go +ctx := context.TODO() +id := migrationrecoverypoints.NewMigrationRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName", "migrationRecoveryPointName") + +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: `MigrationRecoveryPointsClient.ListByReplicationMigrationItems` + +```go +ctx := context.TODO() +id := migrationrecoverypoints.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + +// alternatively `client.ListByReplicationMigrationItems(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationMigrationItemsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/client.go new file mode 100644 index 00000000000..a3234bd3411 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/client.go @@ -0,0 +1,26 @@ +package migrationrecoverypoints + +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 MigrationRecoveryPointsClient struct { + Client *resourcemanager.Client +} + +func NewMigrationRecoveryPointsClientWithBaseURI(sdkApi sdkEnv.Api) (*MigrationRecoveryPointsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "migrationrecoverypoints", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating MigrationRecoveryPointsClient: %+v", err) + } + + return &MigrationRecoveryPointsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/constants.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/constants.go new file mode 100644 index 00000000000..a4169de2a21 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/constants.go @@ -0,0 +1,54 @@ +package migrationrecoverypoints + +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 MigrationRecoveryPointType string + +const ( + MigrationRecoveryPointTypeApplicationConsistent MigrationRecoveryPointType = "ApplicationConsistent" + MigrationRecoveryPointTypeCrashConsistent MigrationRecoveryPointType = "CrashConsistent" + MigrationRecoveryPointTypeNotSpecified MigrationRecoveryPointType = "NotSpecified" +) + +func PossibleValuesForMigrationRecoveryPointType() []string { + return []string{ + string(MigrationRecoveryPointTypeApplicationConsistent), + string(MigrationRecoveryPointTypeCrashConsistent), + string(MigrationRecoveryPointTypeNotSpecified), + } +} + +func (s *MigrationRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMigrationRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMigrationRecoveryPointType(input string) (*MigrationRecoveryPointType, error) { + vals := map[string]MigrationRecoveryPointType{ + "applicationconsistent": MigrationRecoveryPointTypeApplicationConsistent, + "crashconsistent": MigrationRecoveryPointTypeCrashConsistent, + "notspecified": MigrationRecoveryPointTypeNotSpecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MigrationRecoveryPointType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/id_migrationrecoverypoint.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/id_migrationrecoverypoint.go new file mode 100644 index 00000000000..f0e9101261c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/id_migrationrecoverypoint.go @@ -0,0 +1,166 @@ +package migrationrecoverypoints + +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(&MigrationRecoveryPointId{}) +} + +var _ resourceids.ResourceId = &MigrationRecoveryPointId{} + +// MigrationRecoveryPointId is a struct representing the Resource ID for a Migration Recovery Point +type MigrationRecoveryPointId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationMigrationItemName string + MigrationRecoveryPointName string +} + +// NewMigrationRecoveryPointID returns a new MigrationRecoveryPointId struct +func NewMigrationRecoveryPointID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationMigrationItemName string, migrationRecoveryPointName string) MigrationRecoveryPointId { + return MigrationRecoveryPointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationMigrationItemName: replicationMigrationItemName, + MigrationRecoveryPointName: migrationRecoveryPointName, + } +} + +// ParseMigrationRecoveryPointID parses 'input' into a MigrationRecoveryPointId +func ParseMigrationRecoveryPointID(input string) (*MigrationRecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&MigrationRecoveryPointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MigrationRecoveryPointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMigrationRecoveryPointIDInsensitively parses 'input' case-insensitively into a MigrationRecoveryPointId +// note: this method should only be used for API response data and not user input +func ParseMigrationRecoveryPointIDInsensitively(input string) (*MigrationRecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&MigrationRecoveryPointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MigrationRecoveryPointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MigrationRecoveryPointId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationMigrationItemName, ok = input.Parsed["replicationMigrationItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationMigrationItemName", input) + } + + if id.MigrationRecoveryPointName, ok = input.Parsed["migrationRecoveryPointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "migrationRecoveryPointName", input) + } + + return nil +} + +// ValidateMigrationRecoveryPointID checks that 'input' can be parsed as a Migration Recovery Point ID +func ValidateMigrationRecoveryPointID(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 := ParseMigrationRecoveryPointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Migration Recovery Point ID +func (id MigrationRecoveryPointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationMigrationItems/%s/migrationRecoveryPoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationMigrationItemName, id.MigrationRecoveryPointName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Migration Recovery Point ID +func (id MigrationRecoveryPointId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationMigrationItems", "replicationMigrationItems", "replicationMigrationItems"), + resourceids.UserSpecifiedSegment("replicationMigrationItemName", "replicationMigrationItemName"), + resourceids.StaticSegment("staticMigrationRecoveryPoints", "migrationRecoveryPoints", "migrationRecoveryPoints"), + resourceids.UserSpecifiedSegment("migrationRecoveryPointName", "migrationRecoveryPointName"), + } +} + +// String returns a human-readable description of this Migration Recovery Point ID +func (id MigrationRecoveryPointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Migration Item Name: %q", id.ReplicationMigrationItemName), + fmt.Sprintf("Migration Recovery Point Name: %q", id.MigrationRecoveryPointName), + } + return fmt.Sprintf("Migration Recovery Point (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/id_migrationrecoverypoint_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/id_migrationrecoverypoint_test.go new file mode 100644 index 00000000000..d216774042c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/id_migrationrecoverypoint_test.go @@ -0,0 +1,462 @@ +package migrationrecoverypoints + +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 = &MigrationRecoveryPointId{} + +func TestNewMigrationRecoveryPointID(t *testing.T) { + id := NewMigrationRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName", "migrationRecoveryPointName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationMigrationItemName != "replicationMigrationItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationMigrationItemName'", id.ReplicationMigrationItemName, "replicationMigrationItemName") + } + + if id.MigrationRecoveryPointName != "migrationRecoveryPointName" { + t.Fatalf("Expected %q but got %q for Segment 'MigrationRecoveryPointName'", id.MigrationRecoveryPointName, "migrationRecoveryPointName") + } +} + +func TestFormatMigrationRecoveryPointID(t *testing.T) { + actual := NewMigrationRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName", "migrationRecoveryPointName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName/migrationRecoveryPoints/migrationRecoveryPointName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMigrationRecoveryPointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MigrationRecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName/migrationRecoveryPoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName/migrationRecoveryPoints/migrationRecoveryPointName", + Expected: &MigrationRecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationMigrationItemName: "replicationMigrationItemName", + MigrationRecoveryPointName: "migrationRecoveryPointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName/migrationRecoveryPoints/migrationRecoveryPointName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMigrationRecoveryPointID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationMigrationItemName != v.Expected.ReplicationMigrationItemName { + t.Fatalf("Expected %q but got %q for ReplicationMigrationItemName", v.Expected.ReplicationMigrationItemName, actual.ReplicationMigrationItemName) + } + + if actual.MigrationRecoveryPointName != v.Expected.MigrationRecoveryPointName { + t.Fatalf("Expected %q but got %q for MigrationRecoveryPointName", v.Expected.MigrationRecoveryPointName, actual.MigrationRecoveryPointName) + } + + } +} + +func TestParseMigrationRecoveryPointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MigrationRecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnMiGrAtIoNiTeMs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName/migrationRecoveryPoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMnAmE/mIgRaTiOnReCoVeRyPoInTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName/migrationRecoveryPoints/migrationRecoveryPointName", + Expected: &MigrationRecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationMigrationItemName: "replicationMigrationItemName", + MigrationRecoveryPointName: "migrationRecoveryPointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName/migrationRecoveryPoints/migrationRecoveryPointName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMnAmE/mIgRaTiOnReCoVeRyPoInTs/mIgRaTiOnReCoVeRyPoInTnAmE", + Expected: &MigrationRecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationMigrationItemName: "rEpLiCaTiOnMiGrAtIoNiTeMnAmE", + MigrationRecoveryPointName: "mIgRaTiOnReCoVeRyPoInTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMnAmE/mIgRaTiOnReCoVeRyPoInTs/mIgRaTiOnReCoVeRyPoInTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMigrationRecoveryPointIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationMigrationItemName != v.Expected.ReplicationMigrationItemName { + t.Fatalf("Expected %q but got %q for ReplicationMigrationItemName", v.Expected.ReplicationMigrationItemName, actual.ReplicationMigrationItemName) + } + + if actual.MigrationRecoveryPointName != v.Expected.MigrationRecoveryPointName { + t.Fatalf("Expected %q but got %q for MigrationRecoveryPointName", v.Expected.MigrationRecoveryPointName, actual.MigrationRecoveryPointName) + } + + } +} + +func TestSegmentsForMigrationRecoveryPointId(t *testing.T) { + segments := MigrationRecoveryPointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MigrationRecoveryPointId 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/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/id_replicationmigrationitem.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/id_replicationmigrationitem.go new file mode 100644 index 00000000000..9ccb9efa50b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/id_replicationmigrationitem.go @@ -0,0 +1,157 @@ +package migrationrecoverypoints + +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(&ReplicationMigrationItemId{}) +} + +var _ resourceids.ResourceId = &ReplicationMigrationItemId{} + +// ReplicationMigrationItemId is a struct representing the Resource ID for a Replication Migration Item +type ReplicationMigrationItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationMigrationItemName string +} + +// NewReplicationMigrationItemID returns a new ReplicationMigrationItemId struct +func NewReplicationMigrationItemID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationMigrationItemName string) ReplicationMigrationItemId { + return ReplicationMigrationItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationMigrationItemName: replicationMigrationItemName, + } +} + +// ParseReplicationMigrationItemID parses 'input' into a ReplicationMigrationItemId +func ParseReplicationMigrationItemID(input string) (*ReplicationMigrationItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationMigrationItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationMigrationItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationMigrationItemIDInsensitively parses 'input' case-insensitively into a ReplicationMigrationItemId +// note: this method should only be used for API response data and not user input +func ParseReplicationMigrationItemIDInsensitively(input string) (*ReplicationMigrationItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationMigrationItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationMigrationItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationMigrationItemId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationMigrationItemName, ok = input.Parsed["replicationMigrationItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationMigrationItemName", input) + } + + return nil +} + +// ValidateReplicationMigrationItemID checks that 'input' can be parsed as a Replication Migration Item ID +func ValidateReplicationMigrationItemID(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 := ParseReplicationMigrationItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Migration Item ID +func (id ReplicationMigrationItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationMigrationItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationMigrationItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Migration Item ID +func (id ReplicationMigrationItemId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationMigrationItems", "replicationMigrationItems", "replicationMigrationItems"), + resourceids.UserSpecifiedSegment("replicationMigrationItemName", "replicationMigrationItemName"), + } +} + +// String returns a human-readable description of this Replication Migration Item ID +func (id ReplicationMigrationItemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Migration Item Name: %q", id.ReplicationMigrationItemName), + } + return fmt.Sprintf("Replication Migration Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/id_replicationmigrationitem_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/id_replicationmigrationitem_test.go new file mode 100644 index 00000000000..dde2cd4e339 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/id_replicationmigrationitem_test.go @@ -0,0 +1,417 @@ +package migrationrecoverypoints + +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 = &ReplicationMigrationItemId{} + +func TestNewReplicationMigrationItemID(t *testing.T) { + id := NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationMigrationItemName != "replicationMigrationItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationMigrationItemName'", id.ReplicationMigrationItemName, "replicationMigrationItemName") + } +} + +func TestFormatReplicationMigrationItemID(t *testing.T) { + actual := NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationMigrationItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationMigrationItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName", + Expected: &ReplicationMigrationItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationMigrationItemName: "replicationMigrationItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationMigrationItemID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationMigrationItemName != v.Expected.ReplicationMigrationItemName { + t.Fatalf("Expected %q but got %q for ReplicationMigrationItemName", v.Expected.ReplicationMigrationItemName, actual.ReplicationMigrationItemName) + } + + } +} + +func TestParseReplicationMigrationItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationMigrationItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnMiGrAtIoNiTeMs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName", + Expected: &ReplicationMigrationItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationMigrationItemName: "replicationMigrationItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMnAmE", + Expected: &ReplicationMigrationItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationMigrationItemName: "rEpLiCaTiOnMiGrAtIoNiTeMnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationMigrationItemIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationMigrationItemName != v.Expected.ReplicationMigrationItemName { + t.Fatalf("Expected %q but got %q for ReplicationMigrationItemName", v.Expected.ReplicationMigrationItemName, actual.ReplicationMigrationItemName) + } + + } +} + +func TestSegmentsForReplicationMigrationItemId(t *testing.T) { + segments := ReplicationMigrationItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationMigrationItemId 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/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/method_get.go new file mode 100644 index 00000000000..dc4d09d6440 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/method_get.go @@ -0,0 +1,53 @@ +package migrationrecoverypoints + +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 *MigrationRecoveryPoint +} + +// Get ... +func (c MigrationRecoveryPointsClient) Get(ctx context.Context, id MigrationRecoveryPointId) (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 MigrationRecoveryPoint + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/method_listbyreplicationmigrationitems.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/method_listbyreplicationmigrationitems.go new file mode 100644 index 00000000000..a850052471e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/method_listbyreplicationmigrationitems.go @@ -0,0 +1,105 @@ +package migrationrecoverypoints + +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 ListByReplicationMigrationItemsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MigrationRecoveryPoint +} + +type ListByReplicationMigrationItemsCompleteResult struct { + LatestHttpResponse *http.Response + Items []MigrationRecoveryPoint +} + +type ListByReplicationMigrationItemsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationMigrationItemsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationMigrationItems ... +func (c MigrationRecoveryPointsClient) ListByReplicationMigrationItems(ctx context.Context, id ReplicationMigrationItemId) (result ListByReplicationMigrationItemsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationMigrationItemsCustomPager{}, + Path: fmt.Sprintf("%s/migrationRecoveryPoints", 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 *[]MigrationRecoveryPoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationMigrationItemsComplete retrieves all the results into a single object +func (c MigrationRecoveryPointsClient) ListByReplicationMigrationItemsComplete(ctx context.Context, id ReplicationMigrationItemId) (ListByReplicationMigrationItemsCompleteResult, error) { + return c.ListByReplicationMigrationItemsCompleteMatchingPredicate(ctx, id, MigrationRecoveryPointOperationPredicate{}) +} + +// ListByReplicationMigrationItemsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MigrationRecoveryPointsClient) ListByReplicationMigrationItemsCompleteMatchingPredicate(ctx context.Context, id ReplicationMigrationItemId, predicate MigrationRecoveryPointOperationPredicate) (result ListByReplicationMigrationItemsCompleteResult, err error) { + items := make([]MigrationRecoveryPoint, 0) + + resp, err := c.ListByReplicationMigrationItems(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 = ListByReplicationMigrationItemsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/model_migrationrecoverypoint.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/model_migrationrecoverypoint.go new file mode 100644 index 00000000000..6b0ba9fb2d1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/model_migrationrecoverypoint.go @@ -0,0 +1,12 @@ +package migrationrecoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationRecoveryPoint struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MigrationRecoveryPointProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/model_migrationrecoverypointproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/model_migrationrecoverypointproperties.go new file mode 100644 index 00000000000..65f481c3cb9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/model_migrationrecoverypointproperties.go @@ -0,0 +1,27 @@ +package migrationrecoverypoints + +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 MigrationRecoveryPointProperties struct { + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *MigrationRecoveryPointType `json:"recoveryPointType,omitempty"` +} + +func (o *MigrationRecoveryPointProperties) GetRecoveryPointTimeAsTime() (*time.Time, error) { + if o.RecoveryPointTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RecoveryPointTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MigrationRecoveryPointProperties) SetRecoveryPointTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RecoveryPointTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/predicates.go new file mode 100644 index 00000000000..62a451ad032 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/predicates.go @@ -0,0 +1,32 @@ +package migrationrecoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationRecoveryPointOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p MigrationRecoveryPointOperationPredicate) Matches(input MigrationRecoveryPoint) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/version.go new file mode 100644 index 00000000000..17097027d58 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/migrationrecoverypoints/version.go @@ -0,0 +1,10 @@ +package migrationrecoverypoints + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/migrationrecoverypoints/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/operations/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/operations/README.md new file mode 100644 index 00000000000..b6903275e8f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/operations/README.md @@ -0,0 +1,38 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/operations` Documentation + +The `operations` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/operations" +``` + + +### Client Initialization + +```go +client := operations.NewOperationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `OperationsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/operations/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/operations/client.go new file mode 100644 index 00000000000..5afee8af6f7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/operations/client.go @@ -0,0 +1,26 @@ +package operations + +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 OperationsClient struct { + Client *resourcemanager.Client +} + +func NewOperationsClientWithBaseURI(sdkApi sdkEnv.Api) (*OperationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "operations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating OperationsClient: %+v", err) + } + + return &OperationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/operations/method_list.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/operations/method_list.go new file mode 100644 index 00000000000..b83b36e2e63 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/operations/method_list.go @@ -0,0 +1,106 @@ +package operations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]OperationsDiscovery +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []OperationsDiscovery +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c OperationsClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.RecoveryServices/operations", 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 *[]OperationsDiscovery `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c OperationsClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, OperationsDiscoveryOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c OperationsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate OperationsDiscoveryOperationPredicate) (result ListCompleteResult, err error) { + items := make([]OperationsDiscovery, 0) + + resp, err := c.List(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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/operations/model_display.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/operations/model_display.go new file mode 100644 index 00000000000..9b13c14d48d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/operations/model_display.go @@ -0,0 +1,11 @@ +package operations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Display struct { + Description *string `json:"description,omitempty"` + Operation *string `json:"operation,omitempty"` + Provider *string `json:"provider,omitempty"` + Resource *string `json:"resource,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/operations/model_operationsdiscovery.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/operations/model_operationsdiscovery.go new file mode 100644 index 00000000000..fbd67f9e9f4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/operations/model_operationsdiscovery.go @@ -0,0 +1,11 @@ +package operations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OperationsDiscovery struct { + Display *Display `json:"display,omitempty"` + Name *string `json:"name,omitempty"` + Origin *string `json:"origin,omitempty"` + Properties *interface{} `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/operations/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/operations/predicates.go new file mode 100644 index 00000000000..6c9c733282f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/operations/predicates.go @@ -0,0 +1,27 @@ +package operations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OperationsDiscoveryOperationPredicate struct { + Name *string + Origin *string + Properties *interface{} +} + +func (p OperationsDiscoveryOperationPredicate) Matches(input OperationsDiscovery) bool { + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Origin != nil && (input.Origin == nil || *p.Origin != *input.Origin) { + return false + } + + if p.Properties != nil && (input.Properties == nil || *p.Properties != *input.Properties) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/operations/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/operations/version.go new file mode 100644 index 00000000000..1bd04f63c1b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/operations/version.go @@ -0,0 +1,10 @@ +package operations + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/operations/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/README.md new file mode 100644 index 00000000000..41faf6a12bd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints` Documentation + +The `recoverypoints` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/recoverypoints" +``` + + +### Client Initialization + +```go +client := recoverypoints.NewRecoveryPointsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RecoveryPointsClient.Get` + +```go +ctx := context.TODO() +id := recoverypoints.NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName", "recoveryPointName") + +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: `RecoveryPointsClient.ListByReplicationProtectedItems` + +```go +ctx := context.TODO() +id := recoverypoints.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +// alternatively `client.ListByReplicationProtectedItems(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationProtectedItemsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/client.go new file mode 100644 index 00000000000..56e764beced --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/client.go @@ -0,0 +1,26 @@ +package recoverypoints + +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 RecoveryPointsClient struct { + Client *resourcemanager.Client +} + +func NewRecoveryPointsClientWithBaseURI(sdkApi sdkEnv.Api) (*RecoveryPointsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "recoverypoints", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RecoveryPointsClient: %+v", err) + } + + return &RecoveryPointsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/constants.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/constants.go new file mode 100644 index 00000000000..db07d9b75c9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/constants.go @@ -0,0 +1,51 @@ +package recoverypoints + +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 RecoveryPointSyncType string + +const ( + RecoveryPointSyncTypeMultiVMSyncRecoveryPoint RecoveryPointSyncType = "MultiVmSyncRecoveryPoint" + RecoveryPointSyncTypePerVMRecoveryPoint RecoveryPointSyncType = "PerVmRecoveryPoint" +) + +func PossibleValuesForRecoveryPointSyncType() []string { + return []string{ + string(RecoveryPointSyncTypeMultiVMSyncRecoveryPoint), + string(RecoveryPointSyncTypePerVMRecoveryPoint), + } +} + +func (s *RecoveryPointSyncType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecoveryPointSyncType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecoveryPointSyncType(input string) (*RecoveryPointSyncType, error) { + vals := map[string]RecoveryPointSyncType{ + "multivmsyncrecoverypoint": RecoveryPointSyncTypeMultiVMSyncRecoveryPoint, + "pervmrecoverypoint": RecoveryPointSyncTypePerVMRecoveryPoint, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointSyncType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/id_recoverypoint.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/id_recoverypoint.go new file mode 100644 index 00000000000..961edec2d6d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/id_recoverypoint.go @@ -0,0 +1,166 @@ +package recoverypoints + +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(&RecoveryPointId{}) +} + +var _ resourceids.ResourceId = &RecoveryPointId{} + +// RecoveryPointId is a struct representing the Resource ID for a Recovery Point +type RecoveryPointId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectedItemName string + RecoveryPointName string +} + +// NewRecoveryPointID returns a new RecoveryPointId struct +func NewRecoveryPointID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectedItemName string, recoveryPointName string) RecoveryPointId { + return RecoveryPointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectedItemName: replicationProtectedItemName, + RecoveryPointName: recoveryPointName, + } +} + +// ParseRecoveryPointID parses 'input' into a RecoveryPointId +func ParseRecoveryPointID(input string) (*RecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecoveryPointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecoveryPointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRecoveryPointIDInsensitively parses 'input' case-insensitively into a RecoveryPointId +// note: this method should only be used for API response data and not user input +func ParseRecoveryPointIDInsensitively(input string) (*RecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecoveryPointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecoveryPointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RecoveryPointId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectedItemName, ok = input.Parsed["replicationProtectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectedItemName", input) + } + + if id.RecoveryPointName, ok = input.Parsed["recoveryPointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "recoveryPointName", input) + } + + return nil +} + +// ValidateRecoveryPointID checks that 'input' can be parsed as a Recovery Point ID +func ValidateRecoveryPointID(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 := ParseRecoveryPointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Recovery Point ID +func (id RecoveryPointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectedItems/%s/recoveryPoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectedItemName, id.RecoveryPointName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Recovery Point ID +func (id RecoveryPointId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationProtectedItems", "replicationProtectedItems", "replicationProtectedItems"), + resourceids.UserSpecifiedSegment("replicationProtectedItemName", "replicationProtectedItemName"), + resourceids.StaticSegment("staticRecoveryPoints", "recoveryPoints", "recoveryPoints"), + resourceids.UserSpecifiedSegment("recoveryPointName", "recoveryPointName"), + } +} + +// String returns a human-readable description of this Recovery Point ID +func (id RecoveryPointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protected Item Name: %q", id.ReplicationProtectedItemName), + fmt.Sprintf("Recovery Point Name: %q", id.RecoveryPointName), + } + return fmt.Sprintf("Recovery Point (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/id_recoverypoint_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/id_recoverypoint_test.go new file mode 100644 index 00000000000..f7195561c72 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/id_recoverypoint_test.go @@ -0,0 +1,462 @@ +package recoverypoints + +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 = &RecoveryPointId{} + +func TestNewRecoveryPointID(t *testing.T) { + id := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName", "recoveryPointName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationProtectedItemName != "replicationProtectedItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectedItemName'", id.ReplicationProtectedItemName, "replicationProtectedItemName") + } + + if id.RecoveryPointName != "recoveryPointName" { + t.Fatalf("Expected %q but got %q for Segment 'RecoveryPointName'", id.RecoveryPointName, "recoveryPointName") + } +} + +func TestFormatRecoveryPointID(t *testing.T) { + actual := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName", "recoveryPointName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/recoveryPoints/recoveryPointName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRecoveryPointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/recoveryPoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/recoveryPoints/recoveryPointName", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectedItemName: "replicationProtectedItemName", + RecoveryPointName: "recoveryPointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/recoveryPoints/recoveryPointName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecoveryPointID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + if actual.RecoveryPointName != v.Expected.RecoveryPointName { + t.Fatalf("Expected %q but got %q for RecoveryPointName", v.Expected.RecoveryPointName, actual.RecoveryPointName) + } + + } +} + +func TestParseRecoveryPointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/recoveryPoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMnAmE/rEcOvErYpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/recoveryPoints/recoveryPointName", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectedItemName: "replicationProtectedItemName", + RecoveryPointName: "recoveryPointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/recoveryPoints/recoveryPointName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMnAmE/rEcOvErYpOiNtS/rEcOvErYpOiNtNaMe", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationProtectedItemName: "rEpLiCaTiOnPrOtEcTeDiTeMnAmE", + RecoveryPointName: "rEcOvErYpOiNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMnAmE/rEcOvErYpOiNtS/rEcOvErYpOiNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecoveryPointIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + if actual.RecoveryPointName != v.Expected.RecoveryPointName { + t.Fatalf("Expected %q but got %q for RecoveryPointName", v.Expected.RecoveryPointName, actual.RecoveryPointName) + } + + } +} + +func TestSegmentsForRecoveryPointId(t *testing.T) { + segments := RecoveryPointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RecoveryPointId 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/recoveryservicessiterecovery/2024-10-01/recoverypoints/id_replicationprotecteditem.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/id_replicationprotecteditem.go new file mode 100644 index 00000000000..6c0d7acae11 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/id_replicationprotecteditem.go @@ -0,0 +1,157 @@ +package recoverypoints + +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(&ReplicationProtectedItemId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectedItemId{} + +// ReplicationProtectedItemId is a struct representing the Resource ID for a Replication Protected Item +type ReplicationProtectedItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectedItemName string +} + +// NewReplicationProtectedItemID returns a new ReplicationProtectedItemId struct +func NewReplicationProtectedItemID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectedItemName string) ReplicationProtectedItemId { + return ReplicationProtectedItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectedItemName: replicationProtectedItemName, + } +} + +// ParseReplicationProtectedItemID parses 'input' into a ReplicationProtectedItemId +func ParseReplicationProtectedItemID(input string) (*ReplicationProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectedItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectedItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectedItemIDInsensitively parses 'input' case-insensitively into a ReplicationProtectedItemId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectedItemIDInsensitively(input string) (*ReplicationProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectedItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectedItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectedItemId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectedItemName, ok = input.Parsed["replicationProtectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectedItemName", input) + } + + return nil +} + +// ValidateReplicationProtectedItemID checks that 'input' can be parsed as a Replication Protected Item ID +func ValidateReplicationProtectedItemID(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 := ParseReplicationProtectedItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protected Item ID +func (id ReplicationProtectedItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectedItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectedItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protected Item ID +func (id ReplicationProtectedItemId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationProtectedItems", "replicationProtectedItems", "replicationProtectedItems"), + resourceids.UserSpecifiedSegment("replicationProtectedItemName", "replicationProtectedItemName"), + } +} + +// String returns a human-readable description of this Replication Protected Item ID +func (id ReplicationProtectedItemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protected Item Name: %q", id.ReplicationProtectedItemName), + } + return fmt.Sprintf("Replication Protected Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/id_replicationprotecteditem_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/id_replicationprotecteditem_test.go new file mode 100644 index 00000000000..f60a0f6a4a3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/id_replicationprotecteditem_test.go @@ -0,0 +1,417 @@ +package recoverypoints + +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 = &ReplicationProtectedItemId{} + +func TestNewReplicationProtectedItemID(t *testing.T) { + id := NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationProtectedItemName != "replicationProtectedItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectedItemName'", id.ReplicationProtectedItemName, "replicationProtectedItemName") + } +} + +func TestFormatReplicationProtectedItemID(t *testing.T) { + actual := NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectedItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectedItemName: "replicationProtectedItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectedItemID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + } +} + +func TestParseReplicationProtectedItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectedItemName: "replicationProtectedItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMnAmE", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationProtectedItemName: "rEpLiCaTiOnPrOtEcTeDiTeMnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectedItemIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + } +} + +func TestSegmentsForReplicationProtectedItemId(t *testing.T) { + segments := ReplicationProtectedItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectedItemId 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/recoveryservicessiterecovery/2024-10-01/recoverypoints/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/method_get.go new file mode 100644 index 00000000000..843b463fac6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/method_get.go @@ -0,0 +1,53 @@ +package recoverypoints + +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 *RecoveryPoint +} + +// Get ... +func (c RecoveryPointsClient) Get(ctx context.Context, id RecoveryPointId) (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 RecoveryPoint + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/method_listbyreplicationprotecteditems.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/method_listbyreplicationprotecteditems.go new file mode 100644 index 00000000000..dd0de009d18 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/method_listbyreplicationprotecteditems.go @@ -0,0 +1,105 @@ +package recoverypoints + +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 ListByReplicationProtectedItemsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RecoveryPoint +} + +type ListByReplicationProtectedItemsCompleteResult struct { + LatestHttpResponse *http.Response + Items []RecoveryPoint +} + +type ListByReplicationProtectedItemsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationProtectedItemsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationProtectedItems ... +func (c RecoveryPointsClient) ListByReplicationProtectedItems(ctx context.Context, id ReplicationProtectedItemId) (result ListByReplicationProtectedItemsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationProtectedItemsCustomPager{}, + Path: fmt.Sprintf("%s/recoveryPoints", 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 *[]RecoveryPoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationProtectedItemsComplete retrieves all the results into a single object +func (c RecoveryPointsClient) ListByReplicationProtectedItemsComplete(ctx context.Context, id ReplicationProtectedItemId) (ListByReplicationProtectedItemsCompleteResult, error) { + return c.ListByReplicationProtectedItemsCompleteMatchingPredicate(ctx, id, RecoveryPointOperationPredicate{}) +} + +// ListByReplicationProtectedItemsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecoveryPointsClient) ListByReplicationProtectedItemsCompleteMatchingPredicate(ctx context.Context, id ReplicationProtectedItemId, predicate RecoveryPointOperationPredicate) (result ListByReplicationProtectedItemsCompleteResult, err error) { + items := make([]RecoveryPoint, 0) + + resp, err := c.ListByReplicationProtectedItems(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 = ListByReplicationProtectedItemsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/model_a2arecoverypointdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/model_a2arecoverypointdetails.go new file mode 100644 index 00000000000..339b8f2d0a7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/model_a2arecoverypointdetails.go @@ -0,0 +1,51 @@ +package recoverypoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProviderSpecificRecoveryPointDetails = A2ARecoveryPointDetails{} + +type A2ARecoveryPointDetails struct { + Disks *[]string `json:"disks,omitempty"` + RecoveryPointSyncType *RecoveryPointSyncType `json:"recoveryPointSyncType,omitempty"` + + // Fields inherited from ProviderSpecificRecoveryPointDetails + + InstanceType string `json:"instanceType"` +} + +func (s A2ARecoveryPointDetails) ProviderSpecificRecoveryPointDetails() BaseProviderSpecificRecoveryPointDetailsImpl { + return BaseProviderSpecificRecoveryPointDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ARecoveryPointDetails{} + +func (s A2ARecoveryPointDetails) MarshalJSON() ([]byte, error) { + type wrapper A2ARecoveryPointDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ARecoveryPointDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ARecoveryPointDetails: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ARecoveryPointDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/model_inmageazurev2recoverypointdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/model_inmageazurev2recoverypointdetails.go new file mode 100644 index 00000000000..d97d0651905 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/model_inmageazurev2recoverypointdetails.go @@ -0,0 +1,50 @@ +package recoverypoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProviderSpecificRecoveryPointDetails = InMageAzureV2RecoveryPointDetails{} + +type InMageAzureV2RecoveryPointDetails struct { + IsMultiVMSyncPoint *string `json:"isMultiVmSyncPoint,omitempty"` + + // Fields inherited from ProviderSpecificRecoveryPointDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2RecoveryPointDetails) ProviderSpecificRecoveryPointDetails() BaseProviderSpecificRecoveryPointDetailsImpl { + return BaseProviderSpecificRecoveryPointDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2RecoveryPointDetails{} + +func (s InMageAzureV2RecoveryPointDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2RecoveryPointDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2RecoveryPointDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2RecoveryPointDetails: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2RecoveryPointDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/model_inmagercmrecoverypointdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/model_inmagercmrecoverypointdetails.go new file mode 100644 index 00000000000..f0dcc4811be --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/model_inmagercmrecoverypointdetails.go @@ -0,0 +1,50 @@ +package recoverypoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProviderSpecificRecoveryPointDetails = InMageRcmRecoveryPointDetails{} + +type InMageRcmRecoveryPointDetails struct { + IsMultiVMSyncPoint *string `json:"isMultiVmSyncPoint,omitempty"` + + // Fields inherited from ProviderSpecificRecoveryPointDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmRecoveryPointDetails) ProviderSpecificRecoveryPointDetails() BaseProviderSpecificRecoveryPointDetailsImpl { + return BaseProviderSpecificRecoveryPointDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmRecoveryPointDetails{} + +func (s InMageRcmRecoveryPointDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmRecoveryPointDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmRecoveryPointDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmRecoveryPointDetails: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmRecoveryPointDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/model_providerspecificrecoverypointdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/model_providerspecificrecoverypointdetails.go new file mode 100644 index 00000000000..8ba70b192af --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/model_providerspecificrecoverypointdetails.go @@ -0,0 +1,91 @@ +package recoverypoints + +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 ProviderSpecificRecoveryPointDetails interface { + ProviderSpecificRecoveryPointDetails() BaseProviderSpecificRecoveryPointDetailsImpl +} + +var _ ProviderSpecificRecoveryPointDetails = BaseProviderSpecificRecoveryPointDetailsImpl{} + +type BaseProviderSpecificRecoveryPointDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseProviderSpecificRecoveryPointDetailsImpl) ProviderSpecificRecoveryPointDetails() BaseProviderSpecificRecoveryPointDetailsImpl { + return s +} + +var _ ProviderSpecificRecoveryPointDetails = RawProviderSpecificRecoveryPointDetailsImpl{} + +// RawProviderSpecificRecoveryPointDetailsImpl 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 RawProviderSpecificRecoveryPointDetailsImpl struct { + providerSpecificRecoveryPointDetails BaseProviderSpecificRecoveryPointDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawProviderSpecificRecoveryPointDetailsImpl) ProviderSpecificRecoveryPointDetails() BaseProviderSpecificRecoveryPointDetailsImpl { + return s.providerSpecificRecoveryPointDetails +} + +func UnmarshalProviderSpecificRecoveryPointDetailsImplementation(input []byte) (ProviderSpecificRecoveryPointDetails, 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 ProviderSpecificRecoveryPointDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2ARecoveryPointDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ARecoveryPointDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2RecoveryPointDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2RecoveryPointDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmRecoveryPointDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmRecoveryPointDetails: %+v", err) + } + return out, nil + } + + var parent BaseProviderSpecificRecoveryPointDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseProviderSpecificRecoveryPointDetailsImpl: %+v", err) + } + + return RawProviderSpecificRecoveryPointDetailsImpl{ + providerSpecificRecoveryPointDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/model_recoverypoint.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/model_recoverypoint.go new file mode 100644 index 00000000000..cd0df01a0a3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/model_recoverypoint.go @@ -0,0 +1,12 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPoint struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RecoveryPointProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/model_recoverypointproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/model_recoverypointproperties.go new file mode 100644 index 00000000000..c993201bfb7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/model_recoverypointproperties.go @@ -0,0 +1,60 @@ +package recoverypoints + +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. + +type RecoveryPointProperties struct { + ProviderSpecificDetails ProviderSpecificRecoveryPointDetails `json:"providerSpecificDetails"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *string `json:"recoveryPointType,omitempty"` +} + +func (o *RecoveryPointProperties) GetRecoveryPointTimeAsTime() (*time.Time, error) { + if o.RecoveryPointTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RecoveryPointTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryPointProperties) SetRecoveryPointTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RecoveryPointTime = &formatted +} + +var _ json.Unmarshaler = &RecoveryPointProperties{} + +func (s *RecoveryPointProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *string `json:"recoveryPointType,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.RecoveryPointTime = decoded.RecoveryPointTime + s.RecoveryPointType = decoded.RecoveryPointType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RecoveryPointProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalProviderSpecificRecoveryPointDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'RecoveryPointProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/predicates.go new file mode 100644 index 00000000000..599a0311cbf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/predicates.go @@ -0,0 +1,32 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p RecoveryPointOperationPredicate) Matches(input RecoveryPoint) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/version.go new file mode 100644 index 00000000000..0e706ef7a72 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/recoverypoints/version.go @@ -0,0 +1,10 @@ +package recoverypoints + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/recoverypoints/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/README.md new file mode 100644 index 00000000000..d2887e73843 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/README.md @@ -0,0 +1,74 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings` Documentation + +The `replicationalertsettings` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationalertsettings" +``` + + +### Client Initialization + +```go +client := replicationalertsettings.NewReplicationAlertSettingsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationAlertSettingsClient.Create` + +```go +ctx := context.TODO() +id := replicationalertsettings.NewReplicationAlertSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationAlertSettingName") + +payload := replicationalertsettings.ConfigureAlertRequest{ + // ... +} + + +read, err := client.Create(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ReplicationAlertSettingsClient.Get` + +```go +ctx := context.TODO() +id := replicationalertsettings.NewReplicationAlertSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationAlertSettingName") + +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: `ReplicationAlertSettingsClient.List` + +```go +ctx := context.TODO() +id := replicationalertsettings.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/client.go new file mode 100644 index 00000000000..6150bc2ecfa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/client.go @@ -0,0 +1,26 @@ +package replicationalertsettings + +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 ReplicationAlertSettingsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationAlertSettingsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationAlertSettingsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationalertsettings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationAlertSettingsClient: %+v", err) + } + + return &ReplicationAlertSettingsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/id_replicationalertsetting.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/id_replicationalertsetting.go new file mode 100644 index 00000000000..58cedfe08d3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/id_replicationalertsetting.go @@ -0,0 +1,139 @@ +package replicationalertsettings + +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(&ReplicationAlertSettingId{}) +} + +var _ resourceids.ResourceId = &ReplicationAlertSettingId{} + +// ReplicationAlertSettingId is a struct representing the Resource ID for a Replication Alert Setting +type ReplicationAlertSettingId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationAlertSettingName string +} + +// NewReplicationAlertSettingID returns a new ReplicationAlertSettingId struct +func NewReplicationAlertSettingID(subscriptionId string, resourceGroupName string, vaultName string, replicationAlertSettingName string) ReplicationAlertSettingId { + return ReplicationAlertSettingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationAlertSettingName: replicationAlertSettingName, + } +} + +// ParseReplicationAlertSettingID parses 'input' into a ReplicationAlertSettingId +func ParseReplicationAlertSettingID(input string) (*ReplicationAlertSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationAlertSettingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationAlertSettingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationAlertSettingIDInsensitively parses 'input' case-insensitively into a ReplicationAlertSettingId +// note: this method should only be used for API response data and not user input +func ParseReplicationAlertSettingIDInsensitively(input string) (*ReplicationAlertSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationAlertSettingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationAlertSettingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationAlertSettingId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationAlertSettingName, ok = input.Parsed["replicationAlertSettingName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationAlertSettingName", input) + } + + return nil +} + +// ValidateReplicationAlertSettingID checks that 'input' can be parsed as a Replication Alert Setting ID +func ValidateReplicationAlertSettingID(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 := ParseReplicationAlertSettingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Alert Setting ID +func (id ReplicationAlertSettingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationAlertSettings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationAlertSettingName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Alert Setting ID +func (id ReplicationAlertSettingId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationAlertSettings", "replicationAlertSettings", "replicationAlertSettings"), + resourceids.UserSpecifiedSegment("replicationAlertSettingName", "replicationAlertSettingName"), + } +} + +// String returns a human-readable description of this Replication Alert Setting ID +func (id ReplicationAlertSettingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Alert Setting Name: %q", id.ReplicationAlertSettingName), + } + return fmt.Sprintf("Replication Alert Setting (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/id_replicationalertsetting_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/id_replicationalertsetting_test.go new file mode 100644 index 00000000000..56e5094c009 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/id_replicationalertsetting_test.go @@ -0,0 +1,327 @@ +package replicationalertsettings + +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 = &ReplicationAlertSettingId{} + +func TestNewReplicationAlertSettingID(t *testing.T) { + id := NewReplicationAlertSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationAlertSettingName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationAlertSettingName != "replicationAlertSettingName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationAlertSettingName'", id.ReplicationAlertSettingName, "replicationAlertSettingName") + } +} + +func TestFormatReplicationAlertSettingID(t *testing.T) { + actual := NewReplicationAlertSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationAlertSettingName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationAlertSettings/replicationAlertSettingName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationAlertSettingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationAlertSettingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationAlertSettings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationAlertSettings/replicationAlertSettingName", + Expected: &ReplicationAlertSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationAlertSettingName: "replicationAlertSettingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationAlertSettings/replicationAlertSettingName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationAlertSettingID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationAlertSettingName != v.Expected.ReplicationAlertSettingName { + t.Fatalf("Expected %q but got %q for ReplicationAlertSettingName", v.Expected.ReplicationAlertSettingName, actual.ReplicationAlertSettingName) + } + + } +} + +func TestParseReplicationAlertSettingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationAlertSettingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationAlertSettings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnAlErTsEtTiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationAlertSettings/replicationAlertSettingName", + Expected: &ReplicationAlertSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationAlertSettingName: "replicationAlertSettingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationAlertSettings/replicationAlertSettingName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnAlErTsEtTiNgS/rEpLiCaTiOnAlErTsEtTiNgNaMe", + Expected: &ReplicationAlertSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationAlertSettingName: "rEpLiCaTiOnAlErTsEtTiNgNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnAlErTsEtTiNgS/rEpLiCaTiOnAlErTsEtTiNgNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationAlertSettingIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationAlertSettingName != v.Expected.ReplicationAlertSettingName { + t.Fatalf("Expected %q but got %q for ReplicationAlertSettingName", v.Expected.ReplicationAlertSettingName, actual.ReplicationAlertSettingName) + } + + } +} + +func TestSegmentsForReplicationAlertSettingId(t *testing.T) { + segments := ReplicationAlertSettingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationAlertSettingId 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/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/id_vault.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/id_vault.go new file mode 100644 index 00000000000..4d0e369d238 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/id_vault.go @@ -0,0 +1,130 @@ +package replicationalertsettings + +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(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(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 := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/id_vault_test.go new file mode 100644 index 00000000000..9d66b7eb7e7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationalertsettings + +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 = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId 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/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/method_create.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/method_create.go new file mode 100644 index 00000000000..8f2a9586892 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/method_create.go @@ -0,0 +1,57 @@ +package replicationalertsettings + +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 CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Alert +} + +// Create ... +func (c ReplicationAlertSettingsClient) Create(ctx context.Context, id ReplicationAlertSettingId, input ConfigureAlertRequest) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model Alert + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/method_get.go new file mode 100644 index 00000000000..78834c0d17f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/method_get.go @@ -0,0 +1,53 @@ +package replicationalertsettings + +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 *Alert +} + +// Get ... +func (c ReplicationAlertSettingsClient) Get(ctx context.Context, id ReplicationAlertSettingId) (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 Alert + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/method_list.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/method_list.go new file mode 100644 index 00000000000..3d9e40c5690 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/method_list.go @@ -0,0 +1,105 @@ +package replicationalertsettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Alert +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Alert +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ReplicationAlertSettingsClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/replicationAlertSettings", 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 *[]Alert `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationAlertSettingsClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, AlertOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationAlertSettingsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate AlertOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Alert, 0) + + resp, err := c.List(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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/model_alert.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/model_alert.go new file mode 100644 index 00000000000..003e317d3b9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/model_alert.go @@ -0,0 +1,12 @@ +package replicationalertsettings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Alert struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AlertProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/model_alertproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/model_alertproperties.go new file mode 100644 index 00000000000..470729facab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/model_alertproperties.go @@ -0,0 +1,10 @@ +package replicationalertsettings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AlertProperties struct { + CustomEmailAddresses *[]string `json:"customEmailAddresses,omitempty"` + Locale *string `json:"locale,omitempty"` + SendToOwners *string `json:"sendToOwners,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/model_configurealertrequest.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/model_configurealertrequest.go new file mode 100644 index 00000000000..b914ebe04a9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/model_configurealertrequest.go @@ -0,0 +1,8 @@ +package replicationalertsettings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConfigureAlertRequest struct { + Properties *ConfigureAlertRequestProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/model_configurealertrequestproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/model_configurealertrequestproperties.go new file mode 100644 index 00000000000..d5a6752d183 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/model_configurealertrequestproperties.go @@ -0,0 +1,10 @@ +package replicationalertsettings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConfigureAlertRequestProperties struct { + CustomEmailAddresses *[]string `json:"customEmailAddresses,omitempty"` + Locale *string `json:"locale,omitempty"` + SendToOwners *string `json:"sendToOwners,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/predicates.go new file mode 100644 index 00000000000..456cd1b810e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/predicates.go @@ -0,0 +1,32 @@ +package replicationalertsettings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AlertOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p AlertOperationPredicate) Matches(input Alert) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/version.go new file mode 100644 index 00000000000..39db7a2b0ec --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationalertsettings/version.go @@ -0,0 +1,10 @@ +package replicationalertsettings + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationalertsettings/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/README.md new file mode 100644 index 00000000000..eafa92c48ab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances` Documentation + +The `replicationappliances` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationappliances" +``` + + +### Client Initialization + +```go +client := replicationappliances.NewReplicationAppliancesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationAppliancesClient.List` + +```go +ctx := context.TODO() +id := replicationappliances.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id, replicationappliances.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, replicationappliances.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/client.go new file mode 100644 index 00000000000..6a851868099 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/client.go @@ -0,0 +1,26 @@ +package replicationappliances + +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 ReplicationAppliancesClient struct { + Client *resourcemanager.Client +} + +func NewReplicationAppliancesClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationAppliancesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationappliances", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationAppliancesClient: %+v", err) + } + + return &ReplicationAppliancesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/constants.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/constants.go new file mode 100644 index 00000000000..55e598cf7dc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/constants.go @@ -0,0 +1,145 @@ +package replicationappliances + +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 HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} + +type ProtectionHealth string + +const ( + ProtectionHealthCritical ProtectionHealth = "Critical" + ProtectionHealthNone ProtectionHealth = "None" + ProtectionHealthNormal ProtectionHealth = "Normal" + ProtectionHealthWarning ProtectionHealth = "Warning" +) + +func PossibleValuesForProtectionHealth() []string { + return []string{ + string(ProtectionHealthCritical), + string(ProtectionHealthNone), + string(ProtectionHealthNormal), + string(ProtectionHealthWarning), + } +} + +func (s *ProtectionHealth) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProtectionHealth(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProtectionHealth(input string) (*ProtectionHealth, error) { + vals := map[string]ProtectionHealth{ + "critical": ProtectionHealthCritical, + "none": ProtectionHealthNone, + "normal": ProtectionHealthNormal, + "warning": ProtectionHealthWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionHealth(input) + return &out, nil +} + +type RcmComponentStatus string + +const ( + RcmComponentStatusCritical RcmComponentStatus = "Critical" + RcmComponentStatusHealthy RcmComponentStatus = "Healthy" + RcmComponentStatusUnknown RcmComponentStatus = "Unknown" + RcmComponentStatusWarning RcmComponentStatus = "Warning" +) + +func PossibleValuesForRcmComponentStatus() []string { + return []string{ + string(RcmComponentStatusCritical), + string(RcmComponentStatusHealthy), + string(RcmComponentStatusUnknown), + string(RcmComponentStatusWarning), + } +} + +func (s *RcmComponentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRcmComponentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRcmComponentStatus(input string) (*RcmComponentStatus, error) { + vals := map[string]RcmComponentStatus{ + "critical": RcmComponentStatusCritical, + "healthy": RcmComponentStatusHealthy, + "unknown": RcmComponentStatusUnknown, + "warning": RcmComponentStatusWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RcmComponentStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/id_vault.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/id_vault.go new file mode 100644 index 00000000000..840bc253579 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/id_vault.go @@ -0,0 +1,130 @@ +package replicationappliances + +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(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(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 := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/id_vault_test.go new file mode 100644 index 00000000000..b55e9882b37 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationappliances + +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 = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId 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/recoveryservicessiterecovery/2024-10-01/replicationappliances/method_list.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/method_list.go new file mode 100644 index 00000000000..a8a0449c5c0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/method_list.go @@ -0,0 +1,134 @@ +package replicationappliances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReplicationAppliance +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ReplicationAppliance +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ReplicationAppliancesClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/replicationAppliances", 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 *[]ReplicationAppliance `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationAppliancesClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ReplicationApplianceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationAppliancesClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate ReplicationApplianceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ReplicationAppliance, 0) + + resp, err := c.List(ctx, id, options) + 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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_appliancespecificdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_appliancespecificdetails.go new file mode 100644 index 00000000000..e74fab76d77 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_appliancespecificdetails.go @@ -0,0 +1,75 @@ +package replicationappliances + +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 ApplianceSpecificDetails interface { + ApplianceSpecificDetails() BaseApplianceSpecificDetailsImpl +} + +var _ ApplianceSpecificDetails = BaseApplianceSpecificDetailsImpl{} + +type BaseApplianceSpecificDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseApplianceSpecificDetailsImpl) ApplianceSpecificDetails() BaseApplianceSpecificDetailsImpl { + return s +} + +var _ ApplianceSpecificDetails = RawApplianceSpecificDetailsImpl{} + +// RawApplianceSpecificDetailsImpl 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 RawApplianceSpecificDetailsImpl struct { + applianceSpecificDetails BaseApplianceSpecificDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawApplianceSpecificDetailsImpl) ApplianceSpecificDetails() BaseApplianceSpecificDetailsImpl { + return s.applianceSpecificDetails +} + +func UnmarshalApplianceSpecificDetailsImplementation(input []byte) (ApplianceSpecificDetails, 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 ApplianceSpecificDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmApplianceSpecificDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmApplianceSpecificDetails: %+v", err) + } + return out, nil + } + + var parent BaseApplianceSpecificDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseApplianceSpecificDetailsImpl: %+v", err) + } + + return RawApplianceSpecificDetailsImpl{ + applianceSpecificDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_dradetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_dradetails.go new file mode 100644 index 00000000000..fcde153537f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_dradetails.go @@ -0,0 +1,34 @@ +package replicationappliances + +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 DraDetails struct { + BiosId *string `json:"biosId,omitempty"` + ForwardProtectedItemCount *int64 `json:"forwardProtectedItemCount,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + ReverseProtectedItemCount *int64 `json:"reverseProtectedItemCount,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *DraDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *DraDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_healtherror.go new file mode 100644 index 00000000000..1780f919219 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationappliances + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_inmagercmappliancedetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_inmagercmappliancedetails.go new file mode 100644 index 00000000000..df2d5e14881 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_inmagercmappliancedetails.go @@ -0,0 +1,18 @@ +package replicationappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmApplianceDetails struct { + Dra *DraDetails `json:"dra,omitempty"` + FabricArmId *string `json:"fabricArmId,omitempty"` + Id *string `json:"id,omitempty"` + MarsAgent *MarsAgentDetails `json:"marsAgent,omitempty"` + Name *string `json:"name,omitempty"` + ProcessServer *ProcessServerDetails `json:"processServer,omitempty"` + PushInstaller *PushInstallerDetails `json:"pushInstaller,omitempty"` + RcmProxy *RcmProxyDetails `json:"rcmProxy,omitempty"` + ReplicationAgent *ReplicationAgentDetails `json:"replicationAgent,omitempty"` + ReprotectAgent *ReprotectAgentDetails `json:"reprotectAgent,omitempty"` + SwitchProviderBlockingErrorDetails *[]InMageRcmFabricSwitchProviderBlockingErrorDetails `json:"switchProviderBlockingErrorDetails,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_inmagercmappliancespecificdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_inmagercmappliancespecificdetails.go new file mode 100644 index 00000000000..1dc38a9db93 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_inmagercmappliancespecificdetails.go @@ -0,0 +1,50 @@ +package replicationappliances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ApplianceSpecificDetails = InMageRcmApplianceSpecificDetails{} + +type InMageRcmApplianceSpecificDetails struct { + Appliances *[]InMageRcmApplianceDetails `json:"appliances,omitempty"` + + // Fields inherited from ApplianceSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmApplianceSpecificDetails) ApplianceSpecificDetails() BaseApplianceSpecificDetailsImpl { + return BaseApplianceSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmApplianceSpecificDetails{} + +func (s InMageRcmApplianceSpecificDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmApplianceSpecificDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmApplianceSpecificDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmApplianceSpecificDetails: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmApplianceSpecificDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_inmagercmfabricswitchproviderblockingerrordetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_inmagercmfabricswitchproviderblockingerrordetails.go new file mode 100644 index 00000000000..84a5830cb6b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_inmagercmfabricswitchproviderblockingerrordetails.go @@ -0,0 +1,13 @@ +package replicationappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmFabricSwitchProviderBlockingErrorDetails struct { + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorMessageParameters *map[string]string `json:"errorMessageParameters,omitempty"` + ErrorTags *map[string]string `json:"errorTags,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_innerhealtherror.go new file mode 100644 index 00000000000..76f31c711be --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationappliances + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_marsagentdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_marsagentdetails.go new file mode 100644 index 00000000000..edf0158b990 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_marsagentdetails.go @@ -0,0 +1,34 @@ +package replicationappliances + +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 MarsAgentDetails struct { + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *MarsAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *MarsAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_processserverdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_processserverdetails.go new file mode 100644 index 00000000000..43de3ca2697 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_processserverdetails.go @@ -0,0 +1,54 @@ +package replicationappliances + +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 ProcessServerDetails struct { + AvailableMemoryInBytes *int64 `json:"availableMemoryInBytes,omitempty"` + AvailableSpaceInBytes *int64 `json:"availableSpaceInBytes,omitempty"` + BiosId *string `json:"biosId,omitempty"` + DiskUsageStatus *RcmComponentStatus `json:"diskUsageStatus,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + FreeSpacePercentage *float64 `json:"freeSpacePercentage,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + HistoricHealth *ProtectionHealth `json:"historicHealth,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + MemoryUsagePercentage *float64 `json:"memoryUsagePercentage,omitempty"` + MemoryUsageStatus *RcmComponentStatus `json:"memoryUsageStatus,omitempty"` + Name *string `json:"name,omitempty"` + ProcessorUsagePercentage *float64 `json:"processorUsagePercentage,omitempty"` + ProcessorUsageStatus *RcmComponentStatus `json:"processorUsageStatus,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + SystemLoad *int64 `json:"systemLoad,omitempty"` + SystemLoadStatus *RcmComponentStatus `json:"systemLoadStatus,omitempty"` + ThroughputInBytes *int64 `json:"throughputInBytes,omitempty"` + ThroughputStatus *RcmComponentStatus `json:"throughputStatus,omitempty"` + ThroughputUploadPendingDataInBytes *int64 `json:"throughputUploadPendingDataInBytes,omitempty"` + TotalMemoryInBytes *int64 `json:"totalMemoryInBytes,omitempty"` + TotalSpaceInBytes *int64 `json:"totalSpaceInBytes,omitempty"` + UsedMemoryInBytes *int64 `json:"usedMemoryInBytes,omitempty"` + UsedSpaceInBytes *int64 `json:"usedSpaceInBytes,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *ProcessServerDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessServerDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_pushinstallerdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_pushinstallerdetails.go new file mode 100644 index 00000000000..485a5173ab5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_pushinstallerdetails.go @@ -0,0 +1,34 @@ +package replicationappliances + +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 PushInstallerDetails struct { + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *PushInstallerDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *PushInstallerDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_rcmproxydetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_rcmproxydetails.go new file mode 100644 index 00000000000..1d29ef4a653 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_rcmproxydetails.go @@ -0,0 +1,35 @@ +package replicationappliances + +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 RcmProxyDetails struct { + BiosId *string `json:"biosId,omitempty"` + ClientAuthenticationType *string `json:"clientAuthenticationType,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *RcmProxyDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *RcmProxyDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_replicationagentdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_replicationagentdetails.go new file mode 100644 index 00000000000..5147a2d9142 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_replicationagentdetails.go @@ -0,0 +1,34 @@ +package replicationappliances + +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 ReplicationAgentDetails struct { + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *ReplicationAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReplicationAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_replicationappliance.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_replicationappliance.go new file mode 100644 index 00000000000..65955cd695d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_replicationappliance.go @@ -0,0 +1,8 @@ +package replicationappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationAppliance struct { + Properties *ReplicationApplianceProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_replicationapplianceproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_replicationapplianceproperties.go new file mode 100644 index 00000000000..73f48639767 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_replicationapplianceproperties.go @@ -0,0 +1,33 @@ +package replicationappliances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationApplianceProperties struct { + ProviderSpecificDetails ApplianceSpecificDetails `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &ReplicationApplianceProperties{} + +func (s *ReplicationApplianceProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ReplicationApplianceProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalApplianceSpecificDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ReplicationApplianceProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_reprotectagentdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_reprotectagentdetails.go new file mode 100644 index 00000000000..da40fca482c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/model_reprotectagentdetails.go @@ -0,0 +1,50 @@ +package replicationappliances + +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 ReprotectAgentDetails struct { + AccessibleDatastores *[]string `json:"accessibleDatastores,omitempty"` + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastDiscoveryInUtc *string `json:"lastDiscoveryInUtc,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + VcenterId *string `json:"vcenterId,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *ReprotectAgentDetails) GetLastDiscoveryInUtcAsTime() (*time.Time, error) { + if o.LastDiscoveryInUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastDiscoveryInUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReprotectAgentDetails) SetLastDiscoveryInUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastDiscoveryInUtc = &formatted +} + +func (o *ReprotectAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReprotectAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/predicates.go new file mode 100644 index 00000000000..58258537c8d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/predicates.go @@ -0,0 +1,12 @@ +package replicationappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationApplianceOperationPredicate struct { +} + +func (p ReplicationApplianceOperationPredicate) Matches(input ReplicationAppliance) bool { + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/version.go new file mode 100644 index 00000000000..be2b36b5745 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationappliances/version.go @@ -0,0 +1,10 @@ +package replicationappliances + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationappliances/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/README.md new file mode 100644 index 00000000000..28975c242a3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/README.md @@ -0,0 +1,52 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults` Documentation + +The `replicationeligibilityresults` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults" +``` + + +### Client Initialization + +```go +client := replicationeligibilityresults.NewReplicationEligibilityResultsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationEligibilityResultsClient.Get` + +```go +ctx := context.TODO() +id := replicationeligibilityresults.NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineName") + +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: `ReplicationEligibilityResultsClient.List` + +```go +ctx := context.TODO() +id := replicationeligibilityresults.NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineName") + +read, err := client.List(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/client.go new file mode 100644 index 00000000000..329a008dd1f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/client.go @@ -0,0 +1,26 @@ +package replicationeligibilityresults + +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 ReplicationEligibilityResultsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationEligibilityResultsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationEligibilityResultsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationeligibilityresults", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationEligibilityResultsClient: %+v", err) + } + + return &ReplicationEligibilityResultsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/id_virtualmachine.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/id_virtualmachine.go new file mode 100644 index 00000000000..bd0dca13f94 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/id_virtualmachine.go @@ -0,0 +1,130 @@ +package replicationeligibilityresults + +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(&VirtualMachineId{}) +} + +var _ resourceids.ResourceId = &VirtualMachineId{} + +// VirtualMachineId is a struct representing the Resource ID for a Virtual Machine +type VirtualMachineId struct { + SubscriptionId string + ResourceGroupName string + VirtualMachineName string +} + +// NewVirtualMachineID returns a new VirtualMachineId struct +func NewVirtualMachineID(subscriptionId string, resourceGroupName string, virtualMachineName string) VirtualMachineId { + return VirtualMachineId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VirtualMachineName: virtualMachineName, + } +} + +// ParseVirtualMachineID parses 'input' into a VirtualMachineId +func ParseVirtualMachineID(input string) (*VirtualMachineId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualMachineId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualMachineId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualMachineIDInsensitively parses 'input' case-insensitively into a VirtualMachineId +// note: this method should only be used for API response data and not user input +func ParseVirtualMachineIDInsensitively(input string) (*VirtualMachineId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualMachineId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualMachineId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualMachineId) 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.VirtualMachineName, ok = input.Parsed["virtualMachineName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualMachineName", input) + } + + return nil +} + +// ValidateVirtualMachineID checks that 'input' can be parsed as a Virtual Machine ID +func ValidateVirtualMachineID(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 := ParseVirtualMachineID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Machine ID +func (id VirtualMachineId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/virtualMachines/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VirtualMachineName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Machine ID +func (id VirtualMachineId) 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("staticMicrosoftCompute", "Microsoft.Compute", "Microsoft.Compute"), + resourceids.StaticSegment("staticVirtualMachines", "virtualMachines", "virtualMachines"), + resourceids.UserSpecifiedSegment("virtualMachineName", "virtualMachineName"), + } +} + +// String returns a human-readable description of this Virtual Machine ID +func (id VirtualMachineId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Virtual Machine Name: %q", id.VirtualMachineName), + } + return fmt.Sprintf("Virtual Machine (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/id_virtualmachine_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/id_virtualmachine_test.go new file mode 100644 index 00000000000..2c4a1ce212a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/id_virtualmachine_test.go @@ -0,0 +1,282 @@ +package replicationeligibilityresults + +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 = &VirtualMachineId{} + +func TestNewVirtualMachineID(t *testing.T) { + id := NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineName") + + 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.VirtualMachineName != "virtualMachineName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualMachineName'", id.VirtualMachineName, "virtualMachineName") + } +} + +func TestFormatVirtualMachineID(t *testing.T) { + actual := NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachines/virtualMachineName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualMachineID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualMachineId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachines", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachines/virtualMachineName", + Expected: &VirtualMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualMachineName: "virtualMachineName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachines/virtualMachineName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualMachineID(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.VirtualMachineName != v.Expected.VirtualMachineName { + t.Fatalf("Expected %q but got %q for VirtualMachineName", v.Expected.VirtualMachineName, actual.VirtualMachineName) + } + + } +} + +func TestParseVirtualMachineIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualMachineId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachines", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/vIrTuAlMaChInEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachines/virtualMachineName", + Expected: &VirtualMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualMachineName: "virtualMachineName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachines/virtualMachineName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/vIrTuAlMaChInEs/vIrTuAlMaChInEnAmE", + Expected: &VirtualMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VirtualMachineName: "vIrTuAlMaChInEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/vIrTuAlMaChInEs/vIrTuAlMaChInEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualMachineIDInsensitively(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.VirtualMachineName != v.Expected.VirtualMachineName { + t.Fatalf("Expected %q but got %q for VirtualMachineName", v.Expected.VirtualMachineName, actual.VirtualMachineName) + } + + } +} + +func TestSegmentsForVirtualMachineId(t *testing.T) { + segments := VirtualMachineId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualMachineId 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/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/method_get.go new file mode 100644 index 00000000000..b2c86ad7756 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/method_get.go @@ -0,0 +1,54 @@ +package replicationeligibilityresults + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationEligibilityResults +} + +// Get ... +func (c ReplicationEligibilityResultsClient) Get(ctx context.Context, id VirtualMachineId) (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/Microsoft.RecoveryServices/replicationEligibilityResults/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 ReplicationEligibilityResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/method_list.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/method_list.go new file mode 100644 index 00000000000..5547cd4b49f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/method_list.go @@ -0,0 +1,54 @@ +package replicationeligibilityresults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationEligibilityResultsCollection +} + +// List ... +func (c ReplicationEligibilityResultsClient) List(ctx context.Context, id VirtualMachineId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.RecoveryServices/replicationEligibilityResults", 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 ReplicationEligibilityResultsCollection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/model_replicationeligibilityresults.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/model_replicationeligibilityresults.go new file mode 100644 index 00000000000..c14c19713c9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/model_replicationeligibilityresults.go @@ -0,0 +1,11 @@ +package replicationeligibilityresults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationEligibilityResults struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ReplicationEligibilityResultsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/model_replicationeligibilityresultscollection.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/model_replicationeligibilityresultscollection.go new file mode 100644 index 00000000000..2dc729eb1ca --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/model_replicationeligibilityresultscollection.go @@ -0,0 +1,8 @@ +package replicationeligibilityresults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationEligibilityResultsCollection struct { + Value *[]ReplicationEligibilityResults `json:"value,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/model_replicationeligibilityresultserrorinfo.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/model_replicationeligibilityresultserrorinfo.go new file mode 100644 index 00000000000..a81d7856188 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/model_replicationeligibilityresultserrorinfo.go @@ -0,0 +1,12 @@ +package replicationeligibilityresults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationEligibilityResultsErrorInfo struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/model_replicationeligibilityresultsproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/model_replicationeligibilityresultsproperties.go new file mode 100644 index 00000000000..ebc67f22629 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/model_replicationeligibilityresultsproperties.go @@ -0,0 +1,9 @@ +package replicationeligibilityresults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationEligibilityResultsProperties struct { + ClientRequestId *string `json:"clientRequestId,omitempty"` + Errors *[]ReplicationEligibilityResultsErrorInfo `json:"errors,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/version.go new file mode 100644 index 00000000000..b54bf8d5d90 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationeligibilityresults/version.go @@ -0,0 +1,10 @@ +package replicationeligibilityresults + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationeligibilityresults/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/README.md new file mode 100644 index 00000000000..b5ec3aa12aa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents` Documentation + +The `replicationevents` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationevents" +``` + + +### Client Initialization + +```go +client := replicationevents.NewReplicationEventsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationEventsClient.Get` + +```go +ctx := context.TODO() +id := replicationevents.NewReplicationEventID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationEventName") + +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: `ReplicationEventsClient.List` + +```go +ctx := context.TODO() +id := replicationevents.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id, replicationevents.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, replicationevents.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/client.go new file mode 100644 index 00000000000..65b05326a32 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/client.go @@ -0,0 +1,26 @@ +package replicationevents + +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 ReplicationEventsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationEventsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationEventsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationevents", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationEventsClient: %+v", err) + } + + return &ReplicationEventsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/constants.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/constants.go new file mode 100644 index 00000000000..209501caff5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/constants.go @@ -0,0 +1,51 @@ +package replicationevents + +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 HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/id_replicationevent.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/id_replicationevent.go new file mode 100644 index 00000000000..9a94a8d463c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/id_replicationevent.go @@ -0,0 +1,139 @@ +package replicationevents + +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(&ReplicationEventId{}) +} + +var _ resourceids.ResourceId = &ReplicationEventId{} + +// ReplicationEventId is a struct representing the Resource ID for a Replication Event +type ReplicationEventId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationEventName string +} + +// NewReplicationEventID returns a new ReplicationEventId struct +func NewReplicationEventID(subscriptionId string, resourceGroupName string, vaultName string, replicationEventName string) ReplicationEventId { + return ReplicationEventId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationEventName: replicationEventName, + } +} + +// ParseReplicationEventID parses 'input' into a ReplicationEventId +func ParseReplicationEventID(input string) (*ReplicationEventId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationEventId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationEventId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationEventIDInsensitively parses 'input' case-insensitively into a ReplicationEventId +// note: this method should only be used for API response data and not user input +func ParseReplicationEventIDInsensitively(input string) (*ReplicationEventId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationEventId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationEventId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationEventId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationEventName, ok = input.Parsed["replicationEventName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationEventName", input) + } + + return nil +} + +// ValidateReplicationEventID checks that 'input' can be parsed as a Replication Event ID +func ValidateReplicationEventID(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 := ParseReplicationEventID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Event ID +func (id ReplicationEventId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationEvents/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationEventName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Event ID +func (id ReplicationEventId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationEvents", "replicationEvents", "replicationEvents"), + resourceids.UserSpecifiedSegment("replicationEventName", "replicationEventName"), + } +} + +// String returns a human-readable description of this Replication Event ID +func (id ReplicationEventId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Event Name: %q", id.ReplicationEventName), + } + return fmt.Sprintf("Replication Event (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/id_replicationevent_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/id_replicationevent_test.go new file mode 100644 index 00000000000..f4be6ef83fd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/id_replicationevent_test.go @@ -0,0 +1,327 @@ +package replicationevents + +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 = &ReplicationEventId{} + +func TestNewReplicationEventID(t *testing.T) { + id := NewReplicationEventID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationEventName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationEventName != "replicationEventName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationEventName'", id.ReplicationEventName, "replicationEventName") + } +} + +func TestFormatReplicationEventID(t *testing.T) { + actual := NewReplicationEventID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationEventName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationEvents/replicationEventName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationEventID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationEventId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationEvents", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationEvents/replicationEventName", + Expected: &ReplicationEventId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationEventName: "replicationEventName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationEvents/replicationEventName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationEventID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationEventName != v.Expected.ReplicationEventName { + t.Fatalf("Expected %q but got %q for ReplicationEventName", v.Expected.ReplicationEventName, actual.ReplicationEventName) + } + + } +} + +func TestParseReplicationEventIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationEventId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationEvents", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnEvEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationEvents/replicationEventName", + Expected: &ReplicationEventId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationEventName: "replicationEventName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationEvents/replicationEventName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnEvEnTs/rEpLiCaTiOnEvEnTnAmE", + Expected: &ReplicationEventId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationEventName: "rEpLiCaTiOnEvEnTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnEvEnTs/rEpLiCaTiOnEvEnTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationEventIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationEventName != v.Expected.ReplicationEventName { + t.Fatalf("Expected %q but got %q for ReplicationEventName", v.Expected.ReplicationEventName, actual.ReplicationEventName) + } + + } +} + +func TestSegmentsForReplicationEventId(t *testing.T) { + segments := ReplicationEventId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationEventId 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/recoveryservicessiterecovery/2024-10-01/replicationevents/id_vault.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/id_vault.go new file mode 100644 index 00000000000..f540d5ea573 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/id_vault.go @@ -0,0 +1,130 @@ +package replicationevents + +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(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(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 := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/id_vault_test.go new file mode 100644 index 00000000000..fc824ae5e8b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationevents + +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 = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId 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/recoveryservicessiterecovery/2024-10-01/replicationevents/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/method_get.go new file mode 100644 index 00000000000..c04ce4fb4ea --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/method_get.go @@ -0,0 +1,53 @@ +package replicationevents + +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 *Event +} + +// Get ... +func (c ReplicationEventsClient) Get(ctx context.Context, id ReplicationEventId) (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 Event + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/method_list.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/method_list.go new file mode 100644 index 00000000000..d53ecc1e068 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/method_list.go @@ -0,0 +1,134 @@ +package replicationevents + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Event +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Event +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ReplicationEventsClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/replicationEvents", 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 *[]Event `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationEventsClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, EventOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationEventsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate EventOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Event, 0) + + resp, err := c.List(ctx, id, options) + 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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_a2aeventdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_a2aeventdetails.go new file mode 100644 index 00000000000..1fdd6f86eef --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_a2aeventdetails.go @@ -0,0 +1,55 @@ +package replicationevents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EventProviderSpecificDetails = A2AEventDetails{} + +type A2AEventDetails struct { + FabricLocation *string `json:"fabricLocation,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + ProtectedItemName *string `json:"protectedItemName,omitempty"` + RemoteFabricLocation *string `json:"remoteFabricLocation,omitempty"` + RemoteFabricName *string `json:"remoteFabricName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s A2AEventDetails) EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl { + return BaseEventProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AEventDetails{} + +func (s A2AEventDetails) MarshalJSON() ([]byte, error) { + type wrapper A2AEventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AEventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AEventDetails: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AEventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_event.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_event.go new file mode 100644 index 00000000000..e80daa64ebb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_event.go @@ -0,0 +1,12 @@ +package replicationevents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Event struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *EventProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_eventproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_eventproperties.go new file mode 100644 index 00000000000..810b6bbd324 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_eventproperties.go @@ -0,0 +1,90 @@ +package replicationevents + +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. + +type EventProperties struct { + AffectedObjectCorrelationId *string `json:"affectedObjectCorrelationId,omitempty"` + AffectedObjectFriendlyName *string `json:"affectedObjectFriendlyName,omitempty"` + Description *string `json:"description,omitempty"` + EventCode *string `json:"eventCode,omitempty"` + EventSpecificDetails EventSpecificDetails `json:"eventSpecificDetails"` + EventType *string `json:"eventType,omitempty"` + FabricId *string `json:"fabricId,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + ProviderSpecificDetails EventProviderSpecificDetails `json:"providerSpecificDetails"` + Severity *string `json:"severity,omitempty"` + TimeOfOccurrence *string `json:"timeOfOccurrence,omitempty"` +} + +func (o *EventProperties) GetTimeOfOccurrenceAsTime() (*time.Time, error) { + if o.TimeOfOccurrence == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeOfOccurrence, "2006-01-02T15:04:05Z07:00") +} + +func (o *EventProperties) SetTimeOfOccurrenceAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeOfOccurrence = &formatted +} + +var _ json.Unmarshaler = &EventProperties{} + +func (s *EventProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AffectedObjectCorrelationId *string `json:"affectedObjectCorrelationId,omitempty"` + AffectedObjectFriendlyName *string `json:"affectedObjectFriendlyName,omitempty"` + Description *string `json:"description,omitempty"` + EventCode *string `json:"eventCode,omitempty"` + EventType *string `json:"eventType,omitempty"` + FabricId *string `json:"fabricId,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Severity *string `json:"severity,omitempty"` + TimeOfOccurrence *string `json:"timeOfOccurrence,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AffectedObjectCorrelationId = decoded.AffectedObjectCorrelationId + s.AffectedObjectFriendlyName = decoded.AffectedObjectFriendlyName + s.Description = decoded.Description + s.EventCode = decoded.EventCode + s.EventType = decoded.EventType + s.FabricId = decoded.FabricId + s.HealthErrors = decoded.HealthErrors + s.Severity = decoded.Severity + s.TimeOfOccurrence = decoded.TimeOfOccurrence + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling EventProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["eventSpecificDetails"]; ok { + impl, err := UnmarshalEventSpecificDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'EventSpecificDetails' for 'EventProperties': %+v", err) + } + s.EventSpecificDetails = impl + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalEventProviderSpecificDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'EventProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_eventproviderspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_eventproviderspecificdetails.go new file mode 100644 index 00000000000..3b7783158d5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_eventproviderspecificdetails.go @@ -0,0 +1,139 @@ +package replicationevents + +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 EventProviderSpecificDetails interface { + EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl +} + +var _ EventProviderSpecificDetails = BaseEventProviderSpecificDetailsImpl{} + +type BaseEventProviderSpecificDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseEventProviderSpecificDetailsImpl) EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl { + return s +} + +var _ EventProviderSpecificDetails = RawEventProviderSpecificDetailsImpl{} + +// RawEventProviderSpecificDetailsImpl 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 RawEventProviderSpecificDetailsImpl struct { + eventProviderSpecificDetails BaseEventProviderSpecificDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawEventProviderSpecificDetailsImpl) EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl { + return s.eventProviderSpecificDetails +} + +func UnmarshalEventProviderSpecificDetailsImplementation(input []byte) (EventProviderSpecificDetails, 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 EventProviderSpecificDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AEventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AEventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplica2012") { + var out HyperVReplica2012EventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplica2012EventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplica2012R2") { + var out HyperVReplica2012R2EventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplica2012R2EventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureEventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureEventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaBaseEventDetails") { + var out HyperVReplicaBaseEventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaBaseEventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2EventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2EventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmEventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmEventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcmFailback") { + var out InMageRcmFailbackEventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFailbackEventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtEventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtEventDetails: %+v", err) + } + return out, nil + } + + var parent BaseEventProviderSpecificDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseEventProviderSpecificDetailsImpl: %+v", err) + } + + return RawEventProviderSpecificDetailsImpl{ + eventProviderSpecificDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_eventspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_eventspecificdetails.go new file mode 100644 index 00000000000..12bb0a88f4e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_eventspecificdetails.go @@ -0,0 +1,75 @@ +package replicationevents + +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 EventSpecificDetails interface { + EventSpecificDetails() BaseEventSpecificDetailsImpl +} + +var _ EventSpecificDetails = BaseEventSpecificDetailsImpl{} + +type BaseEventSpecificDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseEventSpecificDetailsImpl) EventSpecificDetails() BaseEventSpecificDetailsImpl { + return s +} + +var _ EventSpecificDetails = RawEventSpecificDetailsImpl{} + +// RawEventSpecificDetailsImpl 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 RawEventSpecificDetailsImpl struct { + eventSpecificDetails BaseEventSpecificDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawEventSpecificDetailsImpl) EventSpecificDetails() BaseEventSpecificDetailsImpl { + return s.eventSpecificDetails +} + +func UnmarshalEventSpecificDetailsImplementation(input []byte) (EventSpecificDetails, 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 EventSpecificDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "JobStatus") { + var out JobStatusEventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into JobStatusEventDetails: %+v", err) + } + return out, nil + } + + var parent BaseEventSpecificDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseEventSpecificDetailsImpl: %+v", err) + } + + return RawEventSpecificDetailsImpl{ + eventSpecificDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_healtherror.go new file mode 100644 index 00000000000..7739a4360d6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationevents + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_hypervreplica2012eventdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_hypervreplica2012eventdetails.go new file mode 100644 index 00000000000..515da58c7c4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_hypervreplica2012eventdetails.go @@ -0,0 +1,53 @@ +package replicationevents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EventProviderSpecificDetails = HyperVReplica2012EventDetails{} + +type HyperVReplica2012EventDetails struct { + ContainerName *string `json:"containerName,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + RemoteContainerName *string `json:"remoteContainerName,omitempty"` + RemoteFabricName *string `json:"remoteFabricName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplica2012EventDetails) EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl { + return BaseEventProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplica2012EventDetails{} + +func (s HyperVReplica2012EventDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplica2012EventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplica2012EventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplica2012EventDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplica2012" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplica2012EventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_hypervreplica2012r2eventdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_hypervreplica2012r2eventdetails.go new file mode 100644 index 00000000000..9b702881f52 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_hypervreplica2012r2eventdetails.go @@ -0,0 +1,53 @@ +package replicationevents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EventProviderSpecificDetails = HyperVReplica2012R2EventDetails{} + +type HyperVReplica2012R2EventDetails struct { + ContainerName *string `json:"containerName,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + RemoteContainerName *string `json:"remoteContainerName,omitempty"` + RemoteFabricName *string `json:"remoteFabricName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplica2012R2EventDetails) EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl { + return BaseEventProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplica2012R2EventDetails{} + +func (s HyperVReplica2012R2EventDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplica2012R2EventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplica2012R2EventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplica2012R2EventDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplica2012R2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplica2012R2EventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_hypervreplicaazureeventdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_hypervreplicaazureeventdetails.go new file mode 100644 index 00000000000..116628f1e3c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_hypervreplicaazureeventdetails.go @@ -0,0 +1,52 @@ +package replicationevents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EventProviderSpecificDetails = HyperVReplicaAzureEventDetails{} + +type HyperVReplicaAzureEventDetails struct { + ContainerName *string `json:"containerName,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + RemoteContainerName *string `json:"remoteContainerName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzureEventDetails) EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl { + return BaseEventProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzureEventDetails{} + +func (s HyperVReplicaAzureEventDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureEventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureEventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureEventDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureEventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_hypervreplicabaseeventdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_hypervreplicabaseeventdetails.go new file mode 100644 index 00000000000..213dc282ec0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_hypervreplicabaseeventdetails.go @@ -0,0 +1,53 @@ +package replicationevents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EventProviderSpecificDetails = HyperVReplicaBaseEventDetails{} + +type HyperVReplicaBaseEventDetails struct { + ContainerName *string `json:"containerName,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + RemoteContainerName *string `json:"remoteContainerName,omitempty"` + RemoteFabricName *string `json:"remoteFabricName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaBaseEventDetails) EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl { + return BaseEventProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaBaseEventDetails{} + +func (s HyperVReplicaBaseEventDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaBaseEventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaBaseEventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaBaseEventDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaBaseEventDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaBaseEventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_inmageazurev2eventdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_inmageazurev2eventdetails.go new file mode 100644 index 00000000000..983bdac1c99 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_inmageazurev2eventdetails.go @@ -0,0 +1,56 @@ +package replicationevents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EventProviderSpecificDetails = InMageAzureV2EventDetails{} + +type InMageAzureV2EventDetails struct { + Category *string `json:"category,omitempty"` + Component *string `json:"component,omitempty"` + CorrectiveAction *string `json:"correctiveAction,omitempty"` + Details *string `json:"details,omitempty"` + EventType *string `json:"eventType,omitempty"` + SiteName *string `json:"siteName,omitempty"` + Summary *string `json:"summary,omitempty"` + + // Fields inherited from EventProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2EventDetails) EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl { + return BaseEventProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2EventDetails{} + +func (s InMageAzureV2EventDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2EventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2EventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2EventDetails: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2EventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_inmagercmeventdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_inmagercmeventdetails.go new file mode 100644 index 00000000000..6a9d920bb45 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_inmagercmeventdetails.go @@ -0,0 +1,57 @@ +package replicationevents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EventProviderSpecificDetails = InMageRcmEventDetails{} + +type InMageRcmEventDetails struct { + ApplianceName *string `json:"applianceName,omitempty"` + ComponentDisplayName *string `json:"componentDisplayName,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + JobId *string `json:"jobId,omitempty"` + LatestAgentVersion *string `json:"latestAgentVersion,omitempty"` + ProtectedItemName *string `json:"protectedItemName,omitempty"` + ServerType *string `json:"serverType,omitempty"` + VirtualMachineName *string `json:"vmName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmEventDetails) EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl { + return BaseEventProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmEventDetails{} + +func (s InMageRcmEventDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmEventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmEventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmEventDetails: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmEventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_inmagercmfailbackeventdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_inmagercmfailbackeventdetails.go new file mode 100644 index 00000000000..e8a1f913af4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_inmagercmfailbackeventdetails.go @@ -0,0 +1,54 @@ +package replicationevents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EventProviderSpecificDetails = InMageRcmFailbackEventDetails{} + +type InMageRcmFailbackEventDetails struct { + ApplianceName *string `json:"applianceName,omitempty"` + ComponentDisplayName *string `json:"componentDisplayName,omitempty"` + ProtectedItemName *string `json:"protectedItemName,omitempty"` + ServerType *string `json:"serverType,omitempty"` + VirtualMachineName *string `json:"vmName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmFailbackEventDetails) EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl { + return BaseEventProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmFailbackEventDetails{} + +func (s InMageRcmFailbackEventDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFailbackEventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFailbackEventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFailbackEventDetails: %+v", err) + } + + decoded["instanceType"] = "InMageRcmFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFailbackEventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_innerhealtherror.go new file mode 100644 index 00000000000..357c416c2ff --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationevents + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_jobstatuseventdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_jobstatuseventdetails.go new file mode 100644 index 00000000000..4920df2048e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_jobstatuseventdetails.go @@ -0,0 +1,53 @@ +package replicationevents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EventSpecificDetails = JobStatusEventDetails{} + +type JobStatusEventDetails struct { + AffectedObjectType *string `json:"affectedObjectType,omitempty"` + JobFriendlyName *string `json:"jobFriendlyName,omitempty"` + JobId *string `json:"jobId,omitempty"` + JobStatus *string `json:"jobStatus,omitempty"` + + // Fields inherited from EventSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s JobStatusEventDetails) EventSpecificDetails() BaseEventSpecificDetailsImpl { + return BaseEventSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = JobStatusEventDetails{} + +func (s JobStatusEventDetails) MarshalJSON() ([]byte, error) { + type wrapper JobStatusEventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling JobStatusEventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling JobStatusEventDetails: %+v", err) + } + + decoded["instanceType"] = "JobStatus" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling JobStatusEventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_vmwarecbteventdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_vmwarecbteventdetails.go new file mode 100644 index 00000000000..410c87a3b1e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/model_vmwarecbteventdetails.go @@ -0,0 +1,50 @@ +package replicationevents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EventProviderSpecificDetails = VMwareCbtEventDetails{} + +type VMwareCbtEventDetails struct { + MigrationItemName *string `json:"migrationItemName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtEventDetails) EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl { + return BaseEventProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtEventDetails{} + +func (s VMwareCbtEventDetails) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtEventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtEventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtEventDetails: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtEventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/predicates.go new file mode 100644 index 00000000000..323e9dc1ff0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/predicates.go @@ -0,0 +1,32 @@ +package replicationevents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EventOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p EventOperationPredicate) Matches(input Event) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/version.go new file mode 100644 index 00000000000..eb31aa4d299 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationevents/version.go @@ -0,0 +1,10 @@ +package replicationevents + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationevents/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/README.md new file mode 100644 index 00000000000..11145dfd7ef --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/README.md @@ -0,0 +1,164 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics` Documentation + +The `replicationfabrics` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationfabrics" +``` + + +### Client Initialization + +```go +client := replicationfabrics.NewReplicationFabricsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationFabricsClient.CheckConsistency` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +if err := client.CheckConsistencyThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationFabricsClient.Create` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +payload := replicationfabrics.FabricCreationInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationFabricsClient.Delete` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationFabricsClient.Get` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +read, err := client.Get(ctx, id, replicationfabrics.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ReplicationFabricsClient.List` + +```go +ctx := context.TODO() +id := replicationfabrics.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationFabricsClient.MigrateToAad` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +if err := client.MigrateToAadThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationFabricsClient.Purge` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +if err := client.PurgeThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationFabricsClient.ReassociateGateway` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +payload := replicationfabrics.FailoverProcessServerRequest{ + // ... +} + + +if err := client.ReassociateGatewayThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationFabricsClient.RemoveInfra` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +if err := client.RemoveInfraThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationFabricsClient.RenewCertificate` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +payload := replicationfabrics.RenewCertificateInput{ + // ... +} + + +if err := client.RenewCertificateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/client.go new file mode 100644 index 00000000000..70508d500a7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/client.go @@ -0,0 +1,26 @@ +package replicationfabrics + +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 ReplicationFabricsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationFabricsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationFabricsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationfabrics", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationFabricsClient: %+v", err) + } + + return &ReplicationFabricsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/constants.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/constants.go new file mode 100644 index 00000000000..26c8d7e1b38 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/constants.go @@ -0,0 +1,195 @@ +package replicationfabrics + +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 AgentVersionStatus string + +const ( + AgentVersionStatusDeprecated AgentVersionStatus = "Deprecated" + AgentVersionStatusNotSupported AgentVersionStatus = "NotSupported" + AgentVersionStatusSecurityUpdateRequired AgentVersionStatus = "SecurityUpdateRequired" + AgentVersionStatusSupported AgentVersionStatus = "Supported" + AgentVersionStatusUpdateRequired AgentVersionStatus = "UpdateRequired" +) + +func PossibleValuesForAgentVersionStatus() []string { + return []string{ + string(AgentVersionStatusDeprecated), + string(AgentVersionStatusNotSupported), + string(AgentVersionStatusSecurityUpdateRequired), + string(AgentVersionStatusSupported), + string(AgentVersionStatusUpdateRequired), + } +} + +func (s *AgentVersionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentVersionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentVersionStatus(input string) (*AgentVersionStatus, error) { + vals := map[string]AgentVersionStatus{ + "deprecated": AgentVersionStatusDeprecated, + "notsupported": AgentVersionStatusNotSupported, + "securityupdaterequired": AgentVersionStatusSecurityUpdateRequired, + "supported": AgentVersionStatusSupported, + "updaterequired": AgentVersionStatusUpdateRequired, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentVersionStatus(input) + return &out, nil +} + +type HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} + +type ProtectionHealth string + +const ( + ProtectionHealthCritical ProtectionHealth = "Critical" + ProtectionHealthNone ProtectionHealth = "None" + ProtectionHealthNormal ProtectionHealth = "Normal" + ProtectionHealthWarning ProtectionHealth = "Warning" +) + +func PossibleValuesForProtectionHealth() []string { + return []string{ + string(ProtectionHealthCritical), + string(ProtectionHealthNone), + string(ProtectionHealthNormal), + string(ProtectionHealthWarning), + } +} + +func (s *ProtectionHealth) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProtectionHealth(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProtectionHealth(input string) (*ProtectionHealth, error) { + vals := map[string]ProtectionHealth{ + "critical": ProtectionHealthCritical, + "none": ProtectionHealthNone, + "normal": ProtectionHealthNormal, + "warning": ProtectionHealthWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionHealth(input) + return &out, nil +} + +type RcmComponentStatus string + +const ( + RcmComponentStatusCritical RcmComponentStatus = "Critical" + RcmComponentStatusHealthy RcmComponentStatus = "Healthy" + RcmComponentStatusUnknown RcmComponentStatus = "Unknown" + RcmComponentStatusWarning RcmComponentStatus = "Warning" +) + +func PossibleValuesForRcmComponentStatus() []string { + return []string{ + string(RcmComponentStatusCritical), + string(RcmComponentStatusHealthy), + string(RcmComponentStatusUnknown), + string(RcmComponentStatusWarning), + } +} + +func (s *RcmComponentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRcmComponentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRcmComponentStatus(input string) (*RcmComponentStatus, error) { + vals := map[string]RcmComponentStatus{ + "critical": RcmComponentStatusCritical, + "healthy": RcmComponentStatusHealthy, + "unknown": RcmComponentStatusUnknown, + "warning": RcmComponentStatusWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RcmComponentStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/id_replicationfabric.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/id_replicationfabric.go new file mode 100644 index 00000000000..020505872b8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/id_replicationfabric.go @@ -0,0 +1,139 @@ +package replicationfabrics + +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(&ReplicationFabricId{}) +} + +var _ resourceids.ResourceId = &ReplicationFabricId{} + +// ReplicationFabricId is a struct representing the Resource ID for a Replication Fabric +type ReplicationFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string +} + +// NewReplicationFabricID returns a new ReplicationFabricId struct +func NewReplicationFabricID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string) ReplicationFabricId { + return ReplicationFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + } +} + +// ParseReplicationFabricID parses 'input' into a ReplicationFabricId +func ParseReplicationFabricID(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationFabricIDInsensitively parses 'input' case-insensitively into a ReplicationFabricId +// note: this method should only be used for API response data and not user input +func ParseReplicationFabricIDInsensitively(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationFabricId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + return nil +} + +// ValidateReplicationFabricID checks that 'input' can be parsed as a Replication Fabric ID +func ValidateReplicationFabricID(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 := ParseReplicationFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Fabric ID +func (id ReplicationFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Fabric ID +func (id ReplicationFabricId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + } +} + +// String returns a human-readable description of this Replication Fabric ID +func (id ReplicationFabricId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + } + return fmt.Sprintf("Replication Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/id_replicationfabric_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/id_replicationfabric_test.go new file mode 100644 index 00000000000..19edc4fbec2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/id_replicationfabric_test.go @@ -0,0 +1,327 @@ +package replicationfabrics + +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 = &ReplicationFabricId{} + +func TestNewReplicationFabricID(t *testing.T) { + id := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } +} + +func TestFormatReplicationFabricID(t *testing.T) { + actual := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestParseReplicationFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestSegmentsForReplicationFabricId(t *testing.T) { + segments := ReplicationFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationFabricId 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/recoveryservicessiterecovery/2024-10-01/replicationfabrics/id_vault.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/id_vault.go new file mode 100644 index 00000000000..d5e352feba9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/id_vault.go @@ -0,0 +1,130 @@ +package replicationfabrics + +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(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(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 := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/id_vault_test.go new file mode 100644 index 00000000000..a8000d12f4a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationfabrics + +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 = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId 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/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_checkconsistency.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_checkconsistency.go new file mode 100644 index 00000000000..36419d8f8cc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_checkconsistency.go @@ -0,0 +1,71 @@ +package replicationfabrics + +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 CheckConsistencyOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Fabric +} + +// CheckConsistency ... +func (c ReplicationFabricsClient) CheckConsistency(ctx context.Context, id ReplicationFabricId) (result CheckConsistencyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkConsistency", 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 +} + +// CheckConsistencyThenPoll performs CheckConsistency then polls until it's completed +func (c ReplicationFabricsClient) CheckConsistencyThenPoll(ctx context.Context, id ReplicationFabricId) error { + result, err := c.CheckConsistency(ctx, id) + if err != nil { + return fmt.Errorf("performing CheckConsistency: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CheckConsistency: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_create.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_create.go new file mode 100644 index 00000000000..651d923fdab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_create.go @@ -0,0 +1,75 @@ +package replicationfabrics + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Fabric +} + +// Create ... +func (c ReplicationFabricsClient) Create(ctx context.Context, id ReplicationFabricId, input FabricCreationInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationFabricsClient) CreateThenPoll(ctx context.Context, id ReplicationFabricId, input FabricCreationInput) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_delete.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_delete.go new file mode 100644 index 00000000000..2c456521a1e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_delete.go @@ -0,0 +1,70 @@ +package replicationfabrics + +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 ReplicationFabricsClient) Delete(ctx context.Context, id ReplicationFabricId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/remove", 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 ReplicationFabricsClient) DeleteThenPoll(ctx context.Context, id ReplicationFabricId) 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/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_get.go new file mode 100644 index 00000000000..4ddb027258c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_get.go @@ -0,0 +1,83 @@ +package replicationfabrics + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Fabric +} + +type GetOperationOptions struct { + Filter *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// Get ... +func (c ReplicationFabricsClient) Get(ctx context.Context, id ReplicationFabricId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + 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 Fabric + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_list.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_list.go new file mode 100644 index 00000000000..9087564b359 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_list.go @@ -0,0 +1,105 @@ +package replicationfabrics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Fabric +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Fabric +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ReplicationFabricsClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/replicationFabrics", 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 *[]Fabric `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationFabricsClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, FabricOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationFabricsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate FabricOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Fabric, 0) + + resp, err := c.List(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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_migratetoaad.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_migratetoaad.go new file mode 100644 index 00000000000..b7fcaf76c6e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_migratetoaad.go @@ -0,0 +1,70 @@ +package replicationfabrics + +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 MigrateToAadOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// MigrateToAad ... +func (c ReplicationFabricsClient) MigrateToAad(ctx context.Context, id ReplicationFabricId) (result MigrateToAadOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/migratetoaad", 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 +} + +// MigrateToAadThenPoll performs MigrateToAad then polls until it's completed +func (c ReplicationFabricsClient) MigrateToAadThenPoll(ctx context.Context, id ReplicationFabricId) error { + result, err := c.MigrateToAad(ctx, id) + if err != nil { + return fmt.Errorf("performing MigrateToAad: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MigrateToAad: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_purge.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_purge.go new file mode 100644 index 00000000000..23d0862e294 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_purge.go @@ -0,0 +1,70 @@ +package replicationfabrics + +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 PurgeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Purge ... +func (c ReplicationFabricsClient) Purge(ctx context.Context, id ReplicationFabricId) (result PurgeOperationResponse, 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 +} + +// PurgeThenPoll performs Purge then polls until it's completed +func (c ReplicationFabricsClient) PurgeThenPoll(ctx context.Context, id ReplicationFabricId) error { + result, err := c.Purge(ctx, id) + if err != nil { + return fmt.Errorf("performing Purge: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Purge: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_reassociategateway.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_reassociategateway.go new file mode 100644 index 00000000000..94cc0eb4bae --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_reassociategateway.go @@ -0,0 +1,75 @@ +package replicationfabrics + +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 ReassociateGatewayOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Fabric +} + +// ReassociateGateway ... +func (c ReplicationFabricsClient) ReassociateGateway(ctx context.Context, id ReplicationFabricId, input FailoverProcessServerRequest) (result ReassociateGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reassociateGateway", 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 +} + +// ReassociateGatewayThenPoll performs ReassociateGateway then polls until it's completed +func (c ReplicationFabricsClient) ReassociateGatewayThenPoll(ctx context.Context, id ReplicationFabricId, input FailoverProcessServerRequest) error { + result, err := c.ReassociateGateway(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ReassociateGateway: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ReassociateGateway: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_removeinfra.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_removeinfra.go new file mode 100644 index 00000000000..242bf25cd2b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_removeinfra.go @@ -0,0 +1,69 @@ +package replicationfabrics + +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 RemoveInfraOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RemoveInfra ... +func (c ReplicationFabricsClient) RemoveInfra(ctx context.Context, id ReplicationFabricId) (result RemoveInfraOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/removeInfra", 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 +} + +// RemoveInfraThenPoll performs RemoveInfra then polls until it's completed +func (c ReplicationFabricsClient) RemoveInfraThenPoll(ctx context.Context, id ReplicationFabricId) error { + result, err := c.RemoveInfra(ctx, id) + if err != nil { + return fmt.Errorf("performing RemoveInfra: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RemoveInfra: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_renewcertificate.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_renewcertificate.go new file mode 100644 index 00000000000..ed91ffffebd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/method_renewcertificate.go @@ -0,0 +1,75 @@ +package replicationfabrics + +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 RenewCertificateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Fabric +} + +// RenewCertificate ... +func (c ReplicationFabricsClient) RenewCertificate(ctx context.Context, id ReplicationFabricId, input RenewCertificateInput) (result RenewCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/renewCertificate", 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 +} + +// RenewCertificateThenPoll performs RenewCertificate then polls until it's completed +func (c ReplicationFabricsClient) RenewCertificateThenPoll(ctx context.Context, id ReplicationFabricId, input RenewCertificateInput) error { + result, err := c.RenewCertificate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RenewCertificate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RenewCertificate: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_a2aextendedlocationdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_a2aextendedlocationdetails.go new file mode 100644 index 00000000000..4c3f270376d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_a2aextendedlocationdetails.go @@ -0,0 +1,13 @@ +package replicationfabrics + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AExtendedLocationDetails struct { + PrimaryExtendedLocation *edgezones.Model `json:"primaryExtendedLocation,omitempty"` + RecoveryExtendedLocation *edgezones.Model `json:"recoveryExtendedLocation,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_a2afabricspecificlocationdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_a2afabricspecificlocationdetails.go new file mode 100644 index 00000000000..cf5d60d8f06 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_a2afabricspecificlocationdetails.go @@ -0,0 +1,23 @@ +package replicationfabrics + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AFabricSpecificLocationDetails struct { + InitialPrimaryExtendedLocation *edgezones.Model `json:"initialPrimaryExtendedLocation,omitempty"` + InitialPrimaryFabricLocation *string `json:"initialPrimaryFabricLocation,omitempty"` + InitialPrimaryZone *string `json:"initialPrimaryZone,omitempty"` + InitialRecoveryExtendedLocation *edgezones.Model `json:"initialRecoveryExtendedLocation,omitempty"` + InitialRecoveryFabricLocation *string `json:"initialRecoveryFabricLocation,omitempty"` + InitialRecoveryZone *string `json:"initialRecoveryZone,omitempty"` + PrimaryExtendedLocation *edgezones.Model `json:"primaryExtendedLocation,omitempty"` + PrimaryFabricLocation *string `json:"primaryFabricLocation,omitempty"` + PrimaryZone *string `json:"primaryZone,omitempty"` + RecoveryExtendedLocation *edgezones.Model `json:"recoveryExtendedLocation,omitempty"` + RecoveryFabricLocation *string `json:"recoveryFabricLocation,omitempty"` + RecoveryZone *string `json:"recoveryZone,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_a2azonedetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_a2azonedetails.go new file mode 100644 index 00000000000..f4ad23d1c8c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_a2azonedetails.go @@ -0,0 +1,9 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AZoneDetails struct { + Source *string `json:"source,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_agentdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_agentdetails.go new file mode 100644 index 00000000000..ec30bdfa82c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_agentdetails.go @@ -0,0 +1,12 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentDetails struct { + AgentId *string `json:"agentId,omitempty"` + BiosId *string `json:"biosId,omitempty"` + Disks *[]AgentDiskDetails `json:"disks,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + MachineId *string `json:"machineId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_agentdiskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_agentdiskdetails.go new file mode 100644 index 00000000000..be3e096778e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_agentdiskdetails.go @@ -0,0 +1,12 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentDiskDetails struct { + CapacityInBytes *int64 `json:"capacityInBytes,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + IsOSDisk *string `json:"isOSDisk,omitempty"` + LunId *int64 `json:"lunId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_azurefabriccreationinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_azurefabriccreationinput.go new file mode 100644 index 00000000000..738d129adb3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_azurefabriccreationinput.go @@ -0,0 +1,50 @@ +package replicationfabrics + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificCreationInput = AzureFabricCreationInput{} + +type AzureFabricCreationInput struct { + Location *string `json:"location,omitempty"` + + // Fields inherited from FabricSpecificCreationInput + + InstanceType string `json:"instanceType"` +} + +func (s AzureFabricCreationInput) FabricSpecificCreationInput() BaseFabricSpecificCreationInputImpl { + return BaseFabricSpecificCreationInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = AzureFabricCreationInput{} + +func (s AzureFabricCreationInput) MarshalJSON() ([]byte, error) { + type wrapper AzureFabricCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFabricCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFabricCreationInput: %+v", err) + } + + decoded["instanceType"] = "Azure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFabricCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_azurefabricspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_azurefabricspecificdetails.go new file mode 100644 index 00000000000..e654364c02c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_azurefabricspecificdetails.go @@ -0,0 +1,54 @@ +package replicationfabrics + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificDetails = AzureFabricSpecificDetails{} + +type AzureFabricSpecificDetails struct { + ContainerIds *[]string `json:"containerIds,omitempty"` + ExtendedLocations *[]A2AExtendedLocationDetails `json:"extendedLocations,omitempty"` + Location *string `json:"location,omitempty"` + LocationDetails *[]A2AFabricSpecificLocationDetails `json:"locationDetails,omitempty"` + Zones *[]A2AZoneDetails `json:"zones,omitempty"` + + // Fields inherited from FabricSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s AzureFabricSpecificDetails) FabricSpecificDetails() BaseFabricSpecificDetailsImpl { + return BaseFabricSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = AzureFabricSpecificDetails{} + +func (s AzureFabricSpecificDetails) MarshalJSON() ([]byte, error) { + type wrapper AzureFabricSpecificDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFabricSpecificDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFabricSpecificDetails: %+v", err) + } + + decoded["instanceType"] = "Azure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFabricSpecificDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_datastore.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_datastore.go new file mode 100644 index 00000000000..e20a79fe8fe --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_datastore.go @@ -0,0 +1,12 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataStore struct { + Capacity *string `json:"capacity,omitempty"` + FreeSpace *string `json:"freeSpace,omitempty"` + SymbolicName *string `json:"symbolicName,omitempty"` + Type *string `json:"type,omitempty"` + Uuid *string `json:"uuid,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_dradetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_dradetails.go new file mode 100644 index 00000000000..3e205a58dff --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_dradetails.go @@ -0,0 +1,34 @@ +package replicationfabrics + +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 DraDetails struct { + BiosId *string `json:"biosId,omitempty"` + ForwardProtectedItemCount *int64 `json:"forwardProtectedItemCount,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + ReverseProtectedItemCount *int64 `json:"reverseProtectedItemCount,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *DraDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *DraDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_encryptiondetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_encryptiondetails.go new file mode 100644 index 00000000000..75278c5e8f0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_encryptiondetails.go @@ -0,0 +1,28 @@ +package replicationfabrics + +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 EncryptionDetails struct { + KekCertExpiryDate *string `json:"kekCertExpiryDate,omitempty"` + KekCertThumbprint *string `json:"kekCertThumbprint,omitempty"` + KekState *string `json:"kekState,omitempty"` +} + +func (o *EncryptionDetails) GetKekCertExpiryDateAsTime() (*time.Time, error) { + if o.KekCertExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.KekCertExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *EncryptionDetails) SetKekCertExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.KekCertExpiryDate = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_fabric.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_fabric.go new file mode 100644 index 00000000000..025c3ea019c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_fabric.go @@ -0,0 +1,12 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Fabric struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FabricProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_fabriccreationinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_fabriccreationinput.go new file mode 100644 index 00000000000..33f8bdc704c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_fabriccreationinput.go @@ -0,0 +1,8 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FabricCreationInput struct { + Properties *FabricCreationInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_fabriccreationinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_fabriccreationinputproperties.go new file mode 100644 index 00000000000..b78f44518cc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_fabriccreationinputproperties.go @@ -0,0 +1,33 @@ +package replicationfabrics + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FabricCreationInputProperties struct { + CustomDetails FabricSpecificCreationInput `json:"customDetails"` +} + +var _ json.Unmarshaler = &FabricCreationInputProperties{} + +func (s *FabricCreationInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling FabricCreationInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["customDetails"]; ok { + impl, err := UnmarshalFabricSpecificCreationInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CustomDetails' for 'FabricCreationInputProperties': %+v", err) + } + s.CustomDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_fabricproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_fabricproperties.go new file mode 100644 index 00000000000..821456e11eb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_fabricproperties.go @@ -0,0 +1,60 @@ +package replicationfabrics + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FabricProperties struct { + BcdrState *string `json:"bcdrState,omitempty"` + CustomDetails FabricSpecificDetails `json:"customDetails"` + EncryptionDetails *EncryptionDetails `json:"encryptionDetails,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Health *string `json:"health,omitempty"` + HealthErrorDetails *[]HealthError `json:"healthErrorDetails,omitempty"` + InternalIdentifier *string `json:"internalIdentifier,omitempty"` + RolloverEncryptionDetails *EncryptionDetails `json:"rolloverEncryptionDetails,omitempty"` +} + +var _ json.Unmarshaler = &FabricProperties{} + +func (s *FabricProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + BcdrState *string `json:"bcdrState,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryptionDetails,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Health *string `json:"health,omitempty"` + HealthErrorDetails *[]HealthError `json:"healthErrorDetails,omitempty"` + InternalIdentifier *string `json:"internalIdentifier,omitempty"` + RolloverEncryptionDetails *EncryptionDetails `json:"rolloverEncryptionDetails,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.BcdrState = decoded.BcdrState + s.EncryptionDetails = decoded.EncryptionDetails + s.FriendlyName = decoded.FriendlyName + s.Health = decoded.Health + s.HealthErrorDetails = decoded.HealthErrorDetails + s.InternalIdentifier = decoded.InternalIdentifier + s.RolloverEncryptionDetails = decoded.RolloverEncryptionDetails + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling FabricProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["customDetails"]; ok { + impl, err := UnmarshalFabricSpecificDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CustomDetails' for 'FabricProperties': %+v", err) + } + s.CustomDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_fabricspecificcreationinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_fabricspecificcreationinput.go new file mode 100644 index 00000000000..128f14469f7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_fabricspecificcreationinput.go @@ -0,0 +1,91 @@ +package replicationfabrics + +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 FabricSpecificCreationInput interface { + FabricSpecificCreationInput() BaseFabricSpecificCreationInputImpl +} + +var _ FabricSpecificCreationInput = BaseFabricSpecificCreationInputImpl{} + +type BaseFabricSpecificCreationInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseFabricSpecificCreationInputImpl) FabricSpecificCreationInput() BaseFabricSpecificCreationInputImpl { + return s +} + +var _ FabricSpecificCreationInput = RawFabricSpecificCreationInputImpl{} + +// RawFabricSpecificCreationInputImpl 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 RawFabricSpecificCreationInputImpl struct { + fabricSpecificCreationInput BaseFabricSpecificCreationInputImpl + Type string + Values map[string]interface{} +} + +func (s RawFabricSpecificCreationInputImpl) FabricSpecificCreationInput() BaseFabricSpecificCreationInputImpl { + return s.fabricSpecificCreationInput +} + +func UnmarshalFabricSpecificCreationInputImplementation(input []byte) (FabricSpecificCreationInput, 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 FabricSpecificCreationInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Azure") { + var out AzureFabricCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFabricCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmFabricCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFabricCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareV2") { + var out VMwareV2FabricCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareV2FabricCreationInput: %+v", err) + } + return out, nil + } + + var parent BaseFabricSpecificCreationInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseFabricSpecificCreationInputImpl: %+v", err) + } + + return RawFabricSpecificCreationInputImpl{ + fabricSpecificCreationInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_fabricspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_fabricspecificdetails.go new file mode 100644 index 00000000000..be6b1c113b5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_fabricspecificdetails.go @@ -0,0 +1,115 @@ +package replicationfabrics + +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 FabricSpecificDetails interface { + FabricSpecificDetails() BaseFabricSpecificDetailsImpl +} + +var _ FabricSpecificDetails = BaseFabricSpecificDetailsImpl{} + +type BaseFabricSpecificDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseFabricSpecificDetailsImpl) FabricSpecificDetails() BaseFabricSpecificDetailsImpl { + return s +} + +var _ FabricSpecificDetails = RawFabricSpecificDetailsImpl{} + +// RawFabricSpecificDetailsImpl 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 RawFabricSpecificDetailsImpl struct { + fabricSpecificDetails BaseFabricSpecificDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawFabricSpecificDetailsImpl) FabricSpecificDetails() BaseFabricSpecificDetailsImpl { + return s.fabricSpecificDetails +} + +func UnmarshalFabricSpecificDetailsImplementation(input []byte) (FabricSpecificDetails, 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 FabricSpecificDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Azure") { + var out AzureFabricSpecificDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFabricSpecificDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVSite") { + var out HyperVSiteDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVSiteDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmFabricSpecificDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFabricSpecificDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMM") { + var out VMmDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMmDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMware") { + var out VMwareDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareV2") { + var out VMwareV2FabricSpecificDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareV2FabricSpecificDetails: %+v", err) + } + return out, nil + } + + var parent BaseFabricSpecificDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseFabricSpecificDetailsImpl: %+v", err) + } + + return RawFabricSpecificDetailsImpl{ + fabricSpecificDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_failoverprocessserverrequest.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_failoverprocessserverrequest.go new file mode 100644 index 00000000000..f782d62e870 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_failoverprocessserverrequest.go @@ -0,0 +1,8 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FailoverProcessServerRequest struct { + Properties *FailoverProcessServerRequestProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_failoverprocessserverrequestproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_failoverprocessserverrequestproperties.go new file mode 100644 index 00000000000..03ea6958e5d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_failoverprocessserverrequestproperties.go @@ -0,0 +1,12 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FailoverProcessServerRequestProperties struct { + ContainerName *string `json:"containerName,omitempty"` + SourceProcessServerId *string `json:"sourceProcessServerId,omitempty"` + TargetProcessServerId *string `json:"targetProcessServerId,omitempty"` + UpdateType *string `json:"updateType,omitempty"` + VMsToMigrate *[]string `json:"vmsToMigrate,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_healtherror.go new file mode 100644 index 00000000000..50dfa0a791d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationfabrics + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_hypervhostdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_hypervhostdetails.go new file mode 100644 index 00000000000..5a5914edea0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_hypervhostdetails.go @@ -0,0 +1,10 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HyperVHostDetails struct { + Id *string `json:"id,omitempty"` + MarsAgentVersion *string `json:"marsAgentVersion,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_hypervsitedetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_hypervsitedetails.go new file mode 100644 index 00000000000..35716f3e90a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_hypervsitedetails.go @@ -0,0 +1,50 @@ +package replicationfabrics + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificDetails = HyperVSiteDetails{} + +type HyperVSiteDetails struct { + HyperVHosts *[]HyperVHostDetails `json:"hyperVHosts,omitempty"` + + // Fields inherited from FabricSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s HyperVSiteDetails) FabricSpecificDetails() BaseFabricSpecificDetailsImpl { + return BaseFabricSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVSiteDetails{} + +func (s HyperVSiteDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVSiteDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVSiteDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVSiteDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVSite" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVSiteDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_identityproviderdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_identityproviderdetails.go new file mode 100644 index 00000000000..0a005565876 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_identityproviderdetails.go @@ -0,0 +1,12 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityProviderDetails struct { + AadAuthority *string `json:"aadAuthority,omitempty"` + ApplicationId *string `json:"applicationId,omitempty"` + Audience *string `json:"audience,omitempty"` + ObjectId *string `json:"objectId,omitempty"` + TenantId *string `json:"tenantId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_identityproviderinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_identityproviderinput.go new file mode 100644 index 00000000000..95277e41cc9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_identityproviderinput.go @@ -0,0 +1,12 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityProviderInput struct { + AadAuthority string `json:"aadAuthority"` + ApplicationId string `json:"applicationId"` + Audience string `json:"audience"` + ObjectId string `json:"objectId"` + TenantId string `json:"tenantId"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_inmagefabricswitchproviderblockingerrordetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_inmagefabricswitchproviderblockingerrordetails.go new file mode 100644 index 00000000000..665f9db6edb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_inmagefabricswitchproviderblockingerrordetails.go @@ -0,0 +1,13 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageFabricSwitchProviderBlockingErrorDetails struct { + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorMessageParameters *map[string]string `json:"errorMessageParameters,omitempty"` + ErrorTags *map[string]string `json:"errorTags,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_inmagercmfabriccreationinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_inmagercmfabriccreationinput.go new file mode 100644 index 00000000000..9e072625014 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_inmagercmfabriccreationinput.go @@ -0,0 +1,52 @@ +package replicationfabrics + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificCreationInput = InMageRcmFabricCreationInput{} + +type InMageRcmFabricCreationInput struct { + PhysicalSiteId string `json:"physicalSiteId"` + SourceAgentIdentity IdentityProviderInput `json:"sourceAgentIdentity"` + VMwareSiteId string `json:"vmwareSiteId"` + + // Fields inherited from FabricSpecificCreationInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmFabricCreationInput) FabricSpecificCreationInput() BaseFabricSpecificCreationInputImpl { + return BaseFabricSpecificCreationInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmFabricCreationInput{} + +func (s InMageRcmFabricCreationInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFabricCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFabricCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFabricCreationInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFabricCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_inmagercmfabricspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_inmagercmfabricspecificdetails.go new file mode 100644 index 00000000000..4e138321c6f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_inmagercmfabricspecificdetails.go @@ -0,0 +1,65 @@ +package replicationfabrics + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificDetails = InMageRcmFabricSpecificDetails{} + +type InMageRcmFabricSpecificDetails struct { + AgentDetails *[]AgentDetails `json:"agentDetails,omitempty"` + ControlPlaneUri *string `json:"controlPlaneUri,omitempty"` + DataPlaneUri *string `json:"dataPlaneUri,omitempty"` + Dras *[]DraDetails `json:"dras,omitempty"` + MarsAgents *[]MarsAgentDetails `json:"marsAgents,omitempty"` + PhysicalSiteId *string `json:"physicalSiteId,omitempty"` + ProcessServers *[]ProcessServerDetails `json:"processServers,omitempty"` + PushInstallers *[]PushInstallerDetails `json:"pushInstallers,omitempty"` + RcmProxies *[]RcmProxyDetails `json:"rcmProxies,omitempty"` + ReplicationAgents *[]ReplicationAgentDetails `json:"replicationAgents,omitempty"` + ReprotectAgents *[]ReprotectAgentDetails `json:"reprotectAgents,omitempty"` + ServiceContainerId *string `json:"serviceContainerId,omitempty"` + ServiceEndpoint *string `json:"serviceEndpoint,omitempty"` + ServiceResourceId *string `json:"serviceResourceId,omitempty"` + SourceAgentIdentityDetails *IdentityProviderDetails `json:"sourceAgentIdentityDetails,omitempty"` + VMwareSiteId *string `json:"vmwareSiteId,omitempty"` + + // Fields inherited from FabricSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmFabricSpecificDetails) FabricSpecificDetails() BaseFabricSpecificDetailsImpl { + return BaseFabricSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmFabricSpecificDetails{} + +func (s InMageRcmFabricSpecificDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFabricSpecificDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFabricSpecificDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFabricSpecificDetails: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFabricSpecificDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_innerhealtherror.go new file mode 100644 index 00000000000..c14191f79bd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationfabrics + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_marsagentdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_marsagentdetails.go new file mode 100644 index 00000000000..ed4c6a9d572 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_marsagentdetails.go @@ -0,0 +1,34 @@ +package replicationfabrics + +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 MarsAgentDetails struct { + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *MarsAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *MarsAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_mastertargetserver.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_mastertargetserver.go new file mode 100644 index 00000000000..a5e06f8b4a6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_mastertargetserver.go @@ -0,0 +1,67 @@ +package replicationfabrics + +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 MasterTargetServer struct { + AgentExpiryDate *string `json:"agentExpiryDate,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + AgentVersionDetails *VersionDetails `json:"agentVersionDetails,omitempty"` + DataStores *[]DataStore `json:"dataStores,omitempty"` + DiskCount *int64 `json:"diskCount,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeat *string `json:"lastHeartbeat,omitempty"` + MarsAgentExpiryDate *string `json:"marsAgentExpiryDate,omitempty"` + MarsAgentVersion *string `json:"marsAgentVersion,omitempty"` + MarsAgentVersionDetails *VersionDetails `json:"marsAgentVersionDetails,omitempty"` + Name *string `json:"name,omitempty"` + OsType *string `json:"osType,omitempty"` + OsVersion *string `json:"osVersion,omitempty"` + RetentionVolumes *[]RetentionVolume `json:"retentionVolumes,omitempty"` + ValidationErrors *[]HealthError `json:"validationErrors,omitempty"` + VersionStatus *string `json:"versionStatus,omitempty"` +} + +func (o *MasterTargetServer) GetAgentExpiryDateAsTime() (*time.Time, error) { + if o.AgentExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AgentExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *MasterTargetServer) SetAgentExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AgentExpiryDate = &formatted +} + +func (o *MasterTargetServer) GetLastHeartbeatAsTime() (*time.Time, error) { + if o.LastHeartbeat == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeat, "2006-01-02T15:04:05Z07:00") +} + +func (o *MasterTargetServer) SetLastHeartbeatAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeat = &formatted +} + +func (o *MasterTargetServer) GetMarsAgentExpiryDateAsTime() (*time.Time, error) { + if o.MarsAgentExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.MarsAgentExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *MasterTargetServer) SetMarsAgentExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.MarsAgentExpiryDate = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_mobilityserviceupdate.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_mobilityserviceupdate.go new file mode 100644 index 00000000000..aa2c9c06e41 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_mobilityserviceupdate.go @@ -0,0 +1,10 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MobilityServiceUpdate struct { + OsType *string `json:"osType,omitempty"` + RebootStatus *string `json:"rebootStatus,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_processserver.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_processserver.go new file mode 100644 index 00000000000..60022e3bd47 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_processserver.go @@ -0,0 +1,97 @@ +package replicationfabrics + +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 ProcessServer struct { + AgentExpiryDate *string `json:"agentExpiryDate,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + AgentVersionDetails *VersionDetails `json:"agentVersionDetails,omitempty"` + AvailableMemoryInBytes *int64 `json:"availableMemoryInBytes,omitempty"` + AvailableSpaceInBytes *int64 `json:"availableSpaceInBytes,omitempty"` + CpuLoad *string `json:"cpuLoad,omitempty"` + CpuLoadStatus *string `json:"cpuLoadStatus,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + HostId *string `json:"hostId,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeat *string `json:"lastHeartbeat,omitempty"` + MachineCount *string `json:"machineCount,omitempty"` + MarsCommunicationStatus *string `json:"marsCommunicationStatus,omitempty"` + MarsRegistrationStatus *string `json:"marsRegistrationStatus,omitempty"` + MemoryUsageStatus *string `json:"memoryUsageStatus,omitempty"` + MobilityServiceUpdates *[]MobilityServiceUpdate `json:"mobilityServiceUpdates,omitempty"` + OsType *string `json:"osType,omitempty"` + OsVersion *string `json:"osVersion,omitempty"` + PsServiceStatus *string `json:"psServiceStatus,omitempty"` + PsStatsRefreshTime *string `json:"psStatsRefreshTime,omitempty"` + ReplicationPairCount *string `json:"replicationPairCount,omitempty"` + SpaceUsageStatus *string `json:"spaceUsageStatus,omitempty"` + SslCertExpiryDate *string `json:"sslCertExpiryDate,omitempty"` + SslCertExpiryRemainingDays *int64 `json:"sslCertExpiryRemainingDays,omitempty"` + SystemLoad *string `json:"systemLoad,omitempty"` + SystemLoadStatus *string `json:"systemLoadStatus,omitempty"` + ThroughputInBytes *int64 `json:"throughputInBytes,omitempty"` + ThroughputInMBps *int64 `json:"throughputInMBps,omitempty"` + ThroughputStatus *string `json:"throughputStatus,omitempty"` + ThroughputUploadPendingDataInBytes *int64 `json:"throughputUploadPendingDataInBytes,omitempty"` + TotalMemoryInBytes *int64 `json:"totalMemoryInBytes,omitempty"` + TotalSpaceInBytes *int64 `json:"totalSpaceInBytes,omitempty"` + VersionStatus *string `json:"versionStatus,omitempty"` +} + +func (o *ProcessServer) GetAgentExpiryDateAsTime() (*time.Time, error) { + if o.AgentExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AgentExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessServer) SetAgentExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AgentExpiryDate = &formatted +} + +func (o *ProcessServer) GetLastHeartbeatAsTime() (*time.Time, error) { + if o.LastHeartbeat == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeat, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessServer) SetLastHeartbeatAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeat = &formatted +} + +func (o *ProcessServer) GetPsStatsRefreshTimeAsTime() (*time.Time, error) { + if o.PsStatsRefreshTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.PsStatsRefreshTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessServer) SetPsStatsRefreshTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.PsStatsRefreshTime = &formatted +} + +func (o *ProcessServer) GetSslCertExpiryDateAsTime() (*time.Time, error) { + if o.SslCertExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SslCertExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessServer) SetSslCertExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SslCertExpiryDate = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_processserverdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_processserverdetails.go new file mode 100644 index 00000000000..dd4118b12a9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_processserverdetails.go @@ -0,0 +1,54 @@ +package replicationfabrics + +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 ProcessServerDetails struct { + AvailableMemoryInBytes *int64 `json:"availableMemoryInBytes,omitempty"` + AvailableSpaceInBytes *int64 `json:"availableSpaceInBytes,omitempty"` + BiosId *string `json:"biosId,omitempty"` + DiskUsageStatus *RcmComponentStatus `json:"diskUsageStatus,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + FreeSpacePercentage *float64 `json:"freeSpacePercentage,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + HistoricHealth *ProtectionHealth `json:"historicHealth,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + MemoryUsagePercentage *float64 `json:"memoryUsagePercentage,omitempty"` + MemoryUsageStatus *RcmComponentStatus `json:"memoryUsageStatus,omitempty"` + Name *string `json:"name,omitempty"` + ProcessorUsagePercentage *float64 `json:"processorUsagePercentage,omitempty"` + ProcessorUsageStatus *RcmComponentStatus `json:"processorUsageStatus,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + SystemLoad *int64 `json:"systemLoad,omitempty"` + SystemLoadStatus *RcmComponentStatus `json:"systemLoadStatus,omitempty"` + ThroughputInBytes *int64 `json:"throughputInBytes,omitempty"` + ThroughputStatus *RcmComponentStatus `json:"throughputStatus,omitempty"` + ThroughputUploadPendingDataInBytes *int64 `json:"throughputUploadPendingDataInBytes,omitempty"` + TotalMemoryInBytes *int64 `json:"totalMemoryInBytes,omitempty"` + TotalSpaceInBytes *int64 `json:"totalSpaceInBytes,omitempty"` + UsedMemoryInBytes *int64 `json:"usedMemoryInBytes,omitempty"` + UsedSpaceInBytes *int64 `json:"usedSpaceInBytes,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *ProcessServerDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessServerDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_pushinstallerdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_pushinstallerdetails.go new file mode 100644 index 00000000000..e12d0506fab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_pushinstallerdetails.go @@ -0,0 +1,34 @@ +package replicationfabrics + +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 PushInstallerDetails struct { + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *PushInstallerDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *PushInstallerDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_rcmproxydetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_rcmproxydetails.go new file mode 100644 index 00000000000..939904987ef --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_rcmproxydetails.go @@ -0,0 +1,35 @@ +package replicationfabrics + +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 RcmProxyDetails struct { + BiosId *string `json:"biosId,omitempty"` + ClientAuthenticationType *string `json:"clientAuthenticationType,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *RcmProxyDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *RcmProxyDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_renewcertificateinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_renewcertificateinput.go new file mode 100644 index 00000000000..ab4a712f42d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_renewcertificateinput.go @@ -0,0 +1,8 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RenewCertificateInput struct { + Properties *RenewCertificateInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_renewcertificateinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_renewcertificateinputproperties.go new file mode 100644 index 00000000000..bf4f0b8030e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_renewcertificateinputproperties.go @@ -0,0 +1,8 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RenewCertificateInputProperties struct { + RenewCertificateType *string `json:"renewCertificateType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_replicationagentdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_replicationagentdetails.go new file mode 100644 index 00000000000..0e9ca7038c8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_replicationagentdetails.go @@ -0,0 +1,34 @@ +package replicationfabrics + +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 ReplicationAgentDetails struct { + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *ReplicationAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReplicationAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_reprotectagentdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_reprotectagentdetails.go new file mode 100644 index 00000000000..61e5cf92ba5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_reprotectagentdetails.go @@ -0,0 +1,50 @@ +package replicationfabrics + +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 ReprotectAgentDetails struct { + AccessibleDatastores *[]string `json:"accessibleDatastores,omitempty"` + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastDiscoveryInUtc *string `json:"lastDiscoveryInUtc,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + VcenterId *string `json:"vcenterId,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *ReprotectAgentDetails) GetLastDiscoveryInUtcAsTime() (*time.Time, error) { + if o.LastDiscoveryInUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastDiscoveryInUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReprotectAgentDetails) SetLastDiscoveryInUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastDiscoveryInUtc = &formatted +} + +func (o *ReprotectAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReprotectAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_retentionvolume.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_retentionvolume.go new file mode 100644 index 00000000000..7d9aa7c6801 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_retentionvolume.go @@ -0,0 +1,11 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionVolume struct { + CapacityInBytes *int64 `json:"capacityInBytes,omitempty"` + FreeSpaceInBytes *int64 `json:"freeSpaceInBytes,omitempty"` + ThresholdPercentage *int64 `json:"thresholdPercentage,omitempty"` + VolumeName *string `json:"volumeName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_runasaccount.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_runasaccount.go new file mode 100644 index 00000000000..2339edd7049 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_runasaccount.go @@ -0,0 +1,9 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RunAsAccount struct { + AccountId *string `json:"accountId,omitempty"` + AccountName *string `json:"accountName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_versiondetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_versiondetails.go new file mode 100644 index 00000000000..5d74eb7597e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_versiondetails.go @@ -0,0 +1,28 @@ +package replicationfabrics + +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 VersionDetails struct { + ExpiryDate *string `json:"expiryDate,omitempty"` + Status *AgentVersionStatus `json:"status,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *VersionDetails) GetExpiryDateAsTime() (*time.Time, error) { + if o.ExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *VersionDetails) SetExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiryDate = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_vmmdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_vmmdetails.go new file mode 100644 index 00000000000..cb33769db25 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_vmmdetails.go @@ -0,0 +1,49 @@ +package replicationfabrics + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificDetails = VMmDetails{} + +type VMmDetails struct { + + // Fields inherited from FabricSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s VMmDetails) FabricSpecificDetails() BaseFabricSpecificDetailsImpl { + return BaseFabricSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMmDetails{} + +func (s VMmDetails) MarshalJSON() ([]byte, error) { + type wrapper VMmDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmDetails: %+v", err) + } + + decoded["instanceType"] = "VMM" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_vmwaredetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_vmwaredetails.go new file mode 100644 index 00000000000..097a880d515 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_vmwaredetails.go @@ -0,0 +1,82 @@ +package replicationfabrics + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificDetails = VMwareDetails{} + +type VMwareDetails struct { + AgentCount *string `json:"agentCount,omitempty"` + AgentExpiryDate *string `json:"agentExpiryDate,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + AgentVersionDetails *VersionDetails `json:"agentVersionDetails,omitempty"` + AvailableMemoryInBytes *int64 `json:"availableMemoryInBytes,omitempty"` + AvailableSpaceInBytes *int64 `json:"availableSpaceInBytes,omitempty"` + CpuLoad *string `json:"cpuLoad,omitempty"` + CpuLoadStatus *string `json:"cpuLoadStatus,omitempty"` + CsServiceStatus *string `json:"csServiceStatus,omitempty"` + DatabaseServerLoad *string `json:"databaseServerLoad,omitempty"` + DatabaseServerLoadStatus *string `json:"databaseServerLoadStatus,omitempty"` + HostName *string `json:"hostName,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + LastHeartbeat *string `json:"lastHeartbeat,omitempty"` + MasterTargetServers *[]MasterTargetServer `json:"masterTargetServers,omitempty"` + MemoryUsageStatus *string `json:"memoryUsageStatus,omitempty"` + ProcessServerCount *string `json:"processServerCount,omitempty"` + ProcessServers *[]ProcessServer `json:"processServers,omitempty"` + ProtectedServers *string `json:"protectedServers,omitempty"` + PsTemplateVersion *string `json:"psTemplateVersion,omitempty"` + ReplicationPairCount *string `json:"replicationPairCount,omitempty"` + RunAsAccounts *[]RunAsAccount `json:"runAsAccounts,omitempty"` + SpaceUsageStatus *string `json:"spaceUsageStatus,omitempty"` + SslCertExpiryDate *string `json:"sslCertExpiryDate,omitempty"` + SslCertExpiryRemainingDays *int64 `json:"sslCertExpiryRemainingDays,omitempty"` + SwitchProviderBlockingErrorDetails *[]InMageFabricSwitchProviderBlockingErrorDetails `json:"switchProviderBlockingErrorDetails,omitempty"` + SystemLoad *string `json:"systemLoad,omitempty"` + SystemLoadStatus *string `json:"systemLoadStatus,omitempty"` + TotalMemoryInBytes *int64 `json:"totalMemoryInBytes,omitempty"` + TotalSpaceInBytes *int64 `json:"totalSpaceInBytes,omitempty"` + VersionStatus *string `json:"versionStatus,omitempty"` + WebLoad *string `json:"webLoad,omitempty"` + WebLoadStatus *string `json:"webLoadStatus,omitempty"` + + // Fields inherited from FabricSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s VMwareDetails) FabricSpecificDetails() BaseFabricSpecificDetailsImpl { + return BaseFabricSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareDetails{} + +func (s VMwareDetails) MarshalJSON() ([]byte, error) { + type wrapper VMwareDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareDetails: %+v", err) + } + + decoded["instanceType"] = "VMware" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_vmwarev2fabriccreationinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_vmwarev2fabriccreationinput.go new file mode 100644 index 00000000000..16600cfb322 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_vmwarev2fabriccreationinput.go @@ -0,0 +1,52 @@ +package replicationfabrics + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificCreationInput = VMwareV2FabricCreationInput{} + +type VMwareV2FabricCreationInput struct { + MigrationSolutionId string `json:"migrationSolutionId"` + PhysicalSiteId *string `json:"physicalSiteId,omitempty"` + VMwareSiteId *string `json:"vmwareSiteId,omitempty"` + + // Fields inherited from FabricSpecificCreationInput + + InstanceType string `json:"instanceType"` +} + +func (s VMwareV2FabricCreationInput) FabricSpecificCreationInput() BaseFabricSpecificCreationInputImpl { + return BaseFabricSpecificCreationInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareV2FabricCreationInput{} + +func (s VMwareV2FabricCreationInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareV2FabricCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareV2FabricCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareV2FabricCreationInput: %+v", err) + } + + decoded["instanceType"] = "VMwareV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareV2FabricCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_vmwarev2fabricspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_vmwarev2fabricspecificdetails.go new file mode 100644 index 00000000000..5ff33f8b551 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/model_vmwarev2fabricspecificdetails.go @@ -0,0 +1,56 @@ +package replicationfabrics + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificDetails = VMwareV2FabricSpecificDetails{} + +type VMwareV2FabricSpecificDetails struct { + MigrationSolutionId *string `json:"migrationSolutionId,omitempty"` + PhysicalSiteId *string `json:"physicalSiteId,omitempty"` + ProcessServers *[]ProcessServerDetails `json:"processServers,omitempty"` + ServiceContainerId *string `json:"serviceContainerId,omitempty"` + ServiceEndpoint *string `json:"serviceEndpoint,omitempty"` + ServiceResourceId *string `json:"serviceResourceId,omitempty"` + VMwareSiteId *string `json:"vmwareSiteId,omitempty"` + + // Fields inherited from FabricSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s VMwareV2FabricSpecificDetails) FabricSpecificDetails() BaseFabricSpecificDetailsImpl { + return BaseFabricSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareV2FabricSpecificDetails{} + +func (s VMwareV2FabricSpecificDetails) MarshalJSON() ([]byte, error) { + type wrapper VMwareV2FabricSpecificDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareV2FabricSpecificDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareV2FabricSpecificDetails: %+v", err) + } + + decoded["instanceType"] = "VMwareV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareV2FabricSpecificDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/predicates.go new file mode 100644 index 00000000000..faded6326cb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/predicates.go @@ -0,0 +1,32 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FabricOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p FabricOperationPredicate) Matches(input Fabric) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/version.go new file mode 100644 index 00000000000..cee53ffab28 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationfabrics/version.go @@ -0,0 +1,10 @@ +package replicationfabrics + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationfabrics/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/README.md new file mode 100644 index 00000000000..47dd338c323 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/README.md @@ -0,0 +1,111 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs` Documentation + +The `replicationjobs` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationjobs" +``` + + +### Client Initialization + +```go +client := replicationjobs.NewReplicationJobsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationJobsClient.Cancel` + +```go +ctx := context.TODO() +id := replicationjobs.NewReplicationJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationJobName") + +if err := client.CancelThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationJobsClient.Export` + +```go +ctx := context.TODO() +id := replicationjobs.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +payload := replicationjobs.JobQueryParameter{ + // ... +} + + +if err := client.ExportThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationJobsClient.Get` + +```go +ctx := context.TODO() +id := replicationjobs.NewReplicationJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationJobName") + +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: `ReplicationJobsClient.List` + +```go +ctx := context.TODO() +id := replicationjobs.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id, replicationjobs.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, replicationjobs.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationJobsClient.Restart` + +```go +ctx := context.TODO() +id := replicationjobs.NewReplicationJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationJobName") + +if err := client.RestartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationJobsClient.Resume` + +```go +ctx := context.TODO() +id := replicationjobs.NewReplicationJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationJobName") + +payload := replicationjobs.ResumeJobParams{ + // ... +} + + +if err := client.ResumeThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/client.go new file mode 100644 index 00000000000..0fb616b34c6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/client.go @@ -0,0 +1,26 @@ +package replicationjobs + +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 ReplicationJobsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationJobsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationJobsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationjobs", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationJobsClient: %+v", err) + } + + return &ReplicationJobsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/constants.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/constants.go new file mode 100644 index 00000000000..2ad7334b254 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/constants.go @@ -0,0 +1,54 @@ +package replicationjobs + +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 ExportJobOutputSerializationType string + +const ( + ExportJobOutputSerializationTypeExcel ExportJobOutputSerializationType = "Excel" + ExportJobOutputSerializationTypeJson ExportJobOutputSerializationType = "Json" + ExportJobOutputSerializationTypeXml ExportJobOutputSerializationType = "Xml" +) + +func PossibleValuesForExportJobOutputSerializationType() []string { + return []string{ + string(ExportJobOutputSerializationTypeExcel), + string(ExportJobOutputSerializationTypeJson), + string(ExportJobOutputSerializationTypeXml), + } +} + +func (s *ExportJobOutputSerializationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExportJobOutputSerializationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExportJobOutputSerializationType(input string) (*ExportJobOutputSerializationType, error) { + vals := map[string]ExportJobOutputSerializationType{ + "excel": ExportJobOutputSerializationTypeExcel, + "json": ExportJobOutputSerializationTypeJson, + "xml": ExportJobOutputSerializationTypeXml, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExportJobOutputSerializationType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/id_replicationjob.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/id_replicationjob.go new file mode 100644 index 00000000000..4abf5a4a7be --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/id_replicationjob.go @@ -0,0 +1,139 @@ +package replicationjobs + +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(&ReplicationJobId{}) +} + +var _ resourceids.ResourceId = &ReplicationJobId{} + +// ReplicationJobId is a struct representing the Resource ID for a Replication Job +type ReplicationJobId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationJobName string +} + +// NewReplicationJobID returns a new ReplicationJobId struct +func NewReplicationJobID(subscriptionId string, resourceGroupName string, vaultName string, replicationJobName string) ReplicationJobId { + return ReplicationJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationJobName: replicationJobName, + } +} + +// ParseReplicationJobID parses 'input' into a ReplicationJobId +func ParseReplicationJobID(input string) (*ReplicationJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationJobIDInsensitively parses 'input' case-insensitively into a ReplicationJobId +// note: this method should only be used for API response data and not user input +func ParseReplicationJobIDInsensitively(input string) (*ReplicationJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationJobId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationJobName, ok = input.Parsed["replicationJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationJobName", input) + } + + return nil +} + +// ValidateReplicationJobID checks that 'input' can be parsed as a Replication Job ID +func ValidateReplicationJobID(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 := ParseReplicationJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Job ID +func (id ReplicationJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Job ID +func (id ReplicationJobId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationJobs", "replicationJobs", "replicationJobs"), + resourceids.UserSpecifiedSegment("replicationJobName", "replicationJobName"), + } +} + +// String returns a human-readable description of this Replication Job ID +func (id ReplicationJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Job Name: %q", id.ReplicationJobName), + } + return fmt.Sprintf("Replication Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/id_replicationjob_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/id_replicationjob_test.go new file mode 100644 index 00000000000..1f54c3772b8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/id_replicationjob_test.go @@ -0,0 +1,327 @@ +package replicationjobs + +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 = &ReplicationJobId{} + +func TestNewReplicationJobID(t *testing.T) { + id := NewReplicationJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationJobName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationJobName != "replicationJobName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationJobName'", id.ReplicationJobName, "replicationJobName") + } +} + +func TestFormatReplicationJobID(t *testing.T) { + actual := NewReplicationJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationJobName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationJobs/replicationJobName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationJobs/replicationJobName", + Expected: &ReplicationJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationJobName: "replicationJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationJobs/replicationJobName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationJobID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationJobName != v.Expected.ReplicationJobName { + t.Fatalf("Expected %q but got %q for ReplicationJobName", v.Expected.ReplicationJobName, actual.ReplicationJobName) + } + + } +} + +func TestParseReplicationJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnJoBs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationJobs/replicationJobName", + Expected: &ReplicationJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationJobName: "replicationJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationJobs/replicationJobName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnJoBs/rEpLiCaTiOnJoBnAmE", + Expected: &ReplicationJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationJobName: "rEpLiCaTiOnJoBnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnJoBs/rEpLiCaTiOnJoBnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationJobIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationJobName != v.Expected.ReplicationJobName { + t.Fatalf("Expected %q but got %q for ReplicationJobName", v.Expected.ReplicationJobName, actual.ReplicationJobName) + } + + } +} + +func TestSegmentsForReplicationJobId(t *testing.T) { + segments := ReplicationJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationJobId 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/recoveryservicessiterecovery/2024-10-01/replicationjobs/id_vault.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/id_vault.go new file mode 100644 index 00000000000..da6fbb451d2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/id_vault.go @@ -0,0 +1,130 @@ +package replicationjobs + +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(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(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 := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/id_vault_test.go new file mode 100644 index 00000000000..33e578b5b44 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationjobs + +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 = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId 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/recoveryservicessiterecovery/2024-10-01/replicationjobs/method_cancel.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/method_cancel.go new file mode 100644 index 00000000000..6bb93c09237 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/method_cancel.go @@ -0,0 +1,71 @@ +package replicationjobs + +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 CancelOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Job +} + +// Cancel ... +func (c ReplicationJobsClient) Cancel(ctx context.Context, id ReplicationJobId) (result CancelOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/cancel", 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 +} + +// CancelThenPoll performs Cancel then polls until it's completed +func (c ReplicationJobsClient) CancelThenPoll(ctx context.Context, id ReplicationJobId) error { + result, err := c.Cancel(ctx, id) + if err != nil { + return fmt.Errorf("performing Cancel: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Cancel: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/method_export.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/method_export.go new file mode 100644 index 00000000000..3744e562e2d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/method_export.go @@ -0,0 +1,75 @@ +package replicationjobs + +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 ExportOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Job +} + +// Export ... +func (c ReplicationJobsClient) Export(ctx context.Context, id VaultId, input JobQueryParameter) (result ExportOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/replicationJobs/export", 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 +} + +// ExportThenPoll performs Export then polls until it's completed +func (c ReplicationJobsClient) ExportThenPoll(ctx context.Context, id VaultId, input JobQueryParameter) error { + result, err := c.Export(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Export: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Export: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/method_get.go new file mode 100644 index 00000000000..87300753784 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/method_get.go @@ -0,0 +1,53 @@ +package replicationjobs + +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 *Job +} + +// Get ... +func (c ReplicationJobsClient) Get(ctx context.Context, id ReplicationJobId) (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 Job + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/method_list.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/method_list.go new file mode 100644 index 00000000000..2ff295118f8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/method_list.go @@ -0,0 +1,134 @@ +package replicationjobs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Job +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Job +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ReplicationJobsClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/replicationJobs", 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 *[]Job `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationJobsClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, JobOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationJobsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate JobOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Job, 0) + + resp, err := c.List(ctx, id, options) + 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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/method_restart.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/method_restart.go new file mode 100644 index 00000000000..2750aec1de9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/method_restart.go @@ -0,0 +1,71 @@ +package replicationjobs + +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 RestartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Job +} + +// Restart ... +func (c ReplicationJobsClient) Restart(ctx context.Context, id ReplicationJobId) (result RestartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restart", 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 +} + +// RestartThenPoll performs Restart then polls until it's completed +func (c ReplicationJobsClient) RestartThenPoll(ctx context.Context, id ReplicationJobId) error { + result, err := c.Restart(ctx, id) + if err != nil { + return fmt.Errorf("performing Restart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Restart: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/method_resume.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/method_resume.go new file mode 100644 index 00000000000..1470fd97f41 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/method_resume.go @@ -0,0 +1,75 @@ +package replicationjobs + +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 ResumeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Job +} + +// Resume ... +func (c ReplicationJobsClient) Resume(ctx context.Context, id ReplicationJobId, input ResumeJobParams) (result ResumeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resume", 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 +} + +// ResumeThenPoll performs Resume then polls until it's completed +func (c ReplicationJobsClient) ResumeThenPoll(ctx context.Context, id ReplicationJobId, input ResumeJobParams) error { + result, err := c.Resume(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Resume: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Resume: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_asrjobdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_asrjobdetails.go new file mode 100644 index 00000000000..7f4aa5f741b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_asrjobdetails.go @@ -0,0 +1,51 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobDetails = AsrJobDetails{} + +type AsrJobDetails struct { + + // Fields inherited from JobDetails + + AffectedObjectDetails *map[string]string `json:"affectedObjectDetails,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s AsrJobDetails) JobDetails() BaseJobDetailsImpl { + return BaseJobDetailsImpl{ + AffectedObjectDetails: s.AffectedObjectDetails, + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = AsrJobDetails{} + +func (s AsrJobDetails) MarshalJSON() ([]byte, error) { + type wrapper AsrJobDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AsrJobDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AsrJobDetails: %+v", err) + } + + decoded["instanceType"] = "AsrJobDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AsrJobDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_asrtask.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_asrtask.go new file mode 100644 index 00000000000..5088e2dc807 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_asrtask.go @@ -0,0 +1,105 @@ +package replicationjobs + +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. + +type ASRTask struct { + AllowedActions *[]string `json:"allowedActions,omitempty"` + CustomDetails TaskTypeDetails `json:"customDetails"` + EndTime *string `json:"endTime,omitempty"` + Errors *[]JobErrorDetails `json:"errors,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + GroupTaskCustomDetails GroupTaskDetails `json:"groupTaskCustomDetails"` + Name *string `json:"name,omitempty"` + StartTime *string `json:"startTime,omitempty"` + State *string `json:"state,omitempty"` + StateDescription *string `json:"stateDescription,omitempty"` + TaskId *string `json:"taskId,omitempty"` + TaskType *string `json:"taskType,omitempty"` +} + +func (o *ASRTask) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ASRTask) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *ASRTask) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ASRTask) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Unmarshaler = &ASRTask{} + +func (s *ASRTask) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AllowedActions *[]string `json:"allowedActions,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Errors *[]JobErrorDetails `json:"errors,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Name *string `json:"name,omitempty"` + StartTime *string `json:"startTime,omitempty"` + State *string `json:"state,omitempty"` + StateDescription *string `json:"stateDescription,omitempty"` + TaskId *string `json:"taskId,omitempty"` + TaskType *string `json:"taskType,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AllowedActions = decoded.AllowedActions + s.EndTime = decoded.EndTime + s.Errors = decoded.Errors + s.FriendlyName = decoded.FriendlyName + s.Name = decoded.Name + s.StartTime = decoded.StartTime + s.State = decoded.State + s.StateDescription = decoded.StateDescription + s.TaskId = decoded.TaskId + s.TaskType = decoded.TaskType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ASRTask into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["customDetails"]; ok { + impl, err := UnmarshalTaskTypeDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CustomDetails' for 'ASRTask': %+v", err) + } + s.CustomDetails = impl + } + + if v, ok := temp["groupTaskCustomDetails"]; ok { + impl, err := UnmarshalGroupTaskDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'GroupTaskCustomDetails' for 'ASRTask': %+v", err) + } + s.GroupTaskCustomDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_automationrunbooktaskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_automationrunbooktaskdetails.go new file mode 100644 index 00000000000..8e3ea451afe --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_automationrunbooktaskdetails.go @@ -0,0 +1,58 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TaskTypeDetails = AutomationRunbookTaskDetails{} + +type AutomationRunbookTaskDetails struct { + AccountName *string `json:"accountName,omitempty"` + CloudServiceName *string `json:"cloudServiceName,omitempty"` + IsPrimarySideScript *bool `json:"isPrimarySideScript,omitempty"` + JobId *string `json:"jobId,omitempty"` + JobOutput *string `json:"jobOutput,omitempty"` + Name *string `json:"name,omitempty"` + RunbookId *string `json:"runbookId,omitempty"` + RunbookName *string `json:"runbookName,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + + // Fields inherited from TaskTypeDetails + + InstanceType string `json:"instanceType"` +} + +func (s AutomationRunbookTaskDetails) TaskTypeDetails() BaseTaskTypeDetailsImpl { + return BaseTaskTypeDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = AutomationRunbookTaskDetails{} + +func (s AutomationRunbookTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper AutomationRunbookTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AutomationRunbookTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AutomationRunbookTaskDetails: %+v", err) + } + + decoded["instanceType"] = "AutomationRunbookTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AutomationRunbookTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_clusterfailoverjobdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_clusterfailoverjobdetails.go new file mode 100644 index 00000000000..e7e4b56cb58 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_clusterfailoverjobdetails.go @@ -0,0 +1,52 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobDetails = ClusterFailoverJobDetails{} + +type ClusterFailoverJobDetails struct { + ProtectedItemDetails *[]FailoverReplicationProtectedItemDetails `json:"protectedItemDetails,omitempty"` + + // Fields inherited from JobDetails + + AffectedObjectDetails *map[string]string `json:"affectedObjectDetails,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s ClusterFailoverJobDetails) JobDetails() BaseJobDetailsImpl { + return BaseJobDetailsImpl{ + AffectedObjectDetails: s.AffectedObjectDetails, + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = ClusterFailoverJobDetails{} + +func (s ClusterFailoverJobDetails) MarshalJSON() ([]byte, error) { + type wrapper ClusterFailoverJobDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ClusterFailoverJobDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ClusterFailoverJobDetails: %+v", err) + } + + decoded["instanceType"] = "ClusterFailoverJobDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ClusterFailoverJobDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_clusterswitchprotectionjobdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_clusterswitchprotectionjobdetails.go new file mode 100644 index 00000000000..48238d85340 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_clusterswitchprotectionjobdetails.go @@ -0,0 +1,52 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobDetails = ClusterSwitchProtectionJobDetails{} + +type ClusterSwitchProtectionJobDetails struct { + NewReplicationProtectionClusterId *string `json:"newReplicationProtectionClusterId,omitempty"` + + // Fields inherited from JobDetails + + AffectedObjectDetails *map[string]string `json:"affectedObjectDetails,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s ClusterSwitchProtectionJobDetails) JobDetails() BaseJobDetailsImpl { + return BaseJobDetailsImpl{ + AffectedObjectDetails: s.AffectedObjectDetails, + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = ClusterSwitchProtectionJobDetails{} + +func (s ClusterSwitchProtectionJobDetails) MarshalJSON() ([]byte, error) { + type wrapper ClusterSwitchProtectionJobDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ClusterSwitchProtectionJobDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ClusterSwitchProtectionJobDetails: %+v", err) + } + + decoded["instanceType"] = "ClusterSwitchProtectionJobDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ClusterSwitchProtectionJobDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_clustertestfailoverjobdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_clustertestfailoverjobdetails.go new file mode 100644 index 00000000000..fd3d258a382 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_clustertestfailoverjobdetails.go @@ -0,0 +1,57 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobDetails = ClusterTestFailoverJobDetails{} + +type ClusterTestFailoverJobDetails struct { + Comments *string `json:"comments,omitempty"` + NetworkFriendlyName *string `json:"networkFriendlyName,omitempty"` + NetworkName *string `json:"networkName,omitempty"` + NetworkType *string `json:"networkType,omitempty"` + ProtectedItemDetails *[]FailoverReplicationProtectedItemDetails `json:"protectedItemDetails,omitempty"` + TestFailoverStatus *string `json:"testFailoverStatus,omitempty"` + + // Fields inherited from JobDetails + + AffectedObjectDetails *map[string]string `json:"affectedObjectDetails,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s ClusterTestFailoverJobDetails) JobDetails() BaseJobDetailsImpl { + return BaseJobDetailsImpl{ + AffectedObjectDetails: s.AffectedObjectDetails, + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = ClusterTestFailoverJobDetails{} + +func (s ClusterTestFailoverJobDetails) MarshalJSON() ([]byte, error) { + type wrapper ClusterTestFailoverJobDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ClusterTestFailoverJobDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ClusterTestFailoverJobDetails: %+v", err) + } + + decoded["instanceType"] = "ClusterTestFailoverJobDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ClusterTestFailoverJobDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_consistencychecktaskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_consistencychecktaskdetails.go new file mode 100644 index 00000000000..4e945c5c362 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_consistencychecktaskdetails.go @@ -0,0 +1,50 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TaskTypeDetails = ConsistencyCheckTaskDetails{} + +type ConsistencyCheckTaskDetails struct { + VMDetails *[]InconsistentVMDetails `json:"vmDetails,omitempty"` + + // Fields inherited from TaskTypeDetails + + InstanceType string `json:"instanceType"` +} + +func (s ConsistencyCheckTaskDetails) TaskTypeDetails() BaseTaskTypeDetailsImpl { + return BaseTaskTypeDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = ConsistencyCheckTaskDetails{} + +func (s ConsistencyCheckTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper ConsistencyCheckTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ConsistencyCheckTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ConsistencyCheckTaskDetails: %+v", err) + } + + decoded["instanceType"] = "ConsistencyCheckTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ConsistencyCheckTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_exportjobdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_exportjobdetails.go new file mode 100644 index 00000000000..4f6a728cb67 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_exportjobdetails.go @@ -0,0 +1,53 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobDetails = ExportJobDetails{} + +type ExportJobDetails struct { + BlobUri *string `json:"blobUri,omitempty"` + SasToken *string `json:"sasToken,omitempty"` + + // Fields inherited from JobDetails + + AffectedObjectDetails *map[string]string `json:"affectedObjectDetails,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s ExportJobDetails) JobDetails() BaseJobDetailsImpl { + return BaseJobDetailsImpl{ + AffectedObjectDetails: s.AffectedObjectDetails, + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = ExportJobDetails{} + +func (s ExportJobDetails) MarshalJSON() ([]byte, error) { + type wrapper ExportJobDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ExportJobDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ExportJobDetails: %+v", err) + } + + decoded["instanceType"] = "ExportJobDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ExportJobDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_fabricreplicationgrouptaskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_fabricreplicationgrouptaskdetails.go new file mode 100644 index 00000000000..9c64ad0db35 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_fabricreplicationgrouptaskdetails.go @@ -0,0 +1,51 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TaskTypeDetails = FabricReplicationGroupTaskDetails{} + +type FabricReplicationGroupTaskDetails struct { + SkippedReason *string `json:"skippedReason,omitempty"` + SkippedReasonString *string `json:"skippedReasonString,omitempty"` + + // Fields inherited from TaskTypeDetails + + InstanceType string `json:"instanceType"` +} + +func (s FabricReplicationGroupTaskDetails) TaskTypeDetails() BaseTaskTypeDetailsImpl { + return BaseTaskTypeDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = FabricReplicationGroupTaskDetails{} + +func (s FabricReplicationGroupTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper FabricReplicationGroupTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FabricReplicationGroupTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FabricReplicationGroupTaskDetails: %+v", err) + } + + decoded["instanceType"] = "FabricReplicationGroupTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FabricReplicationGroupTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_failoverjobdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_failoverjobdetails.go new file mode 100644 index 00000000000..512eb079845 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_failoverjobdetails.go @@ -0,0 +1,52 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobDetails = FailoverJobDetails{} + +type FailoverJobDetails struct { + ProtectedItemDetails *[]FailoverReplicationProtectedItemDetails `json:"protectedItemDetails,omitempty"` + + // Fields inherited from JobDetails + + AffectedObjectDetails *map[string]string `json:"affectedObjectDetails,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s FailoverJobDetails) JobDetails() BaseJobDetailsImpl { + return BaseJobDetailsImpl{ + AffectedObjectDetails: s.AffectedObjectDetails, + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = FailoverJobDetails{} + +func (s FailoverJobDetails) MarshalJSON() ([]byte, error) { + type wrapper FailoverJobDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FailoverJobDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FailoverJobDetails: %+v", err) + } + + decoded["instanceType"] = "FailoverJobDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FailoverJobDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_failoverreplicationprotecteditemdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_failoverreplicationprotecteditemdetails.go new file mode 100644 index 00000000000..8f28aeba2ed --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_failoverreplicationprotecteditemdetails.go @@ -0,0 +1,34 @@ +package replicationjobs + +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 FailoverReplicationProtectedItemDetails struct { + FriendlyName *string `json:"friendlyName,omitempty"` + Name *string `json:"name,omitempty"` + NetworkConnectionStatus *string `json:"networkConnectionStatus,omitempty"` + NetworkFriendlyName *string `json:"networkFriendlyName,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + Subnet *string `json:"subnet,omitempty"` + TestVMFriendlyName *string `json:"testVmFriendlyName,omitempty"` + TestVMName *string `json:"testVmName,omitempty"` +} + +func (o *FailoverReplicationProtectedItemDetails) GetRecoveryPointTimeAsTime() (*time.Time, error) { + if o.RecoveryPointTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RecoveryPointTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *FailoverReplicationProtectedItemDetails) SetRecoveryPointTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RecoveryPointTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_grouptaskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_grouptaskdetails.go new file mode 100644 index 00000000000..60467655c21 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_grouptaskdetails.go @@ -0,0 +1,84 @@ +package replicationjobs + +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 GroupTaskDetails interface { + GroupTaskDetails() BaseGroupTaskDetailsImpl +} + +var _ GroupTaskDetails = BaseGroupTaskDetailsImpl{} + +type BaseGroupTaskDetailsImpl struct { + ChildTasks *[]ASRTask `json:"childTasks,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s BaseGroupTaskDetailsImpl) GroupTaskDetails() BaseGroupTaskDetailsImpl { + return s +} + +var _ GroupTaskDetails = RawGroupTaskDetailsImpl{} + +// RawGroupTaskDetailsImpl 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 RawGroupTaskDetailsImpl struct { + groupTaskDetails BaseGroupTaskDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawGroupTaskDetailsImpl) GroupTaskDetails() BaseGroupTaskDetailsImpl { + return s.groupTaskDetails +} + +func UnmarshalGroupTaskDetailsImplementation(input []byte) (GroupTaskDetails, 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 GroupTaskDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "InlineWorkflowTaskDetails") { + var out InlineWorkflowTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InlineWorkflowTaskDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RecoveryPlanGroupTaskDetails") { + var out RecoveryPlanGroupTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanGroupTaskDetails: %+v", err) + } + return out, nil + } + + var parent BaseGroupTaskDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseGroupTaskDetailsImpl: %+v", err) + } + + return RawGroupTaskDetailsImpl{ + groupTaskDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_inconsistentvmdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_inconsistentvmdetails.go new file mode 100644 index 00000000000..04192118e25 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_inconsistentvmdetails.go @@ -0,0 +1,11 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InconsistentVMDetails struct { + CloudName *string `json:"cloudName,omitempty"` + Details *[]string `json:"details,omitempty"` + ErrorIds *[]string `json:"errorIds,omitempty"` + VirtualMachineName *string `json:"vmName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_inlineworkflowtaskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_inlineworkflowtaskdetails.go new file mode 100644 index 00000000000..dc281023cd2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_inlineworkflowtaskdetails.go @@ -0,0 +1,52 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ GroupTaskDetails = InlineWorkflowTaskDetails{} + +type InlineWorkflowTaskDetails struct { + WorkflowIds *[]string `json:"workflowIds,omitempty"` + + // Fields inherited from GroupTaskDetails + + ChildTasks *[]ASRTask `json:"childTasks,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s InlineWorkflowTaskDetails) GroupTaskDetails() BaseGroupTaskDetailsImpl { + return BaseGroupTaskDetailsImpl{ + ChildTasks: s.ChildTasks, + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InlineWorkflowTaskDetails{} + +func (s InlineWorkflowTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper InlineWorkflowTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InlineWorkflowTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InlineWorkflowTaskDetails: %+v", err) + } + + decoded["instanceType"] = "InlineWorkflowTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InlineWorkflowTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_job.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_job.go new file mode 100644 index 00000000000..74a9debce1f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_job.go @@ -0,0 +1,12 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Job struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *JobProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_jobdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_jobdetails.go new file mode 100644 index 00000000000..ea3d4d26d8f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_jobdetails.go @@ -0,0 +1,132 @@ +package replicationjobs + +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 JobDetails interface { + JobDetails() BaseJobDetailsImpl +} + +var _ JobDetails = BaseJobDetailsImpl{} + +type BaseJobDetailsImpl struct { + AffectedObjectDetails *map[string]string `json:"affectedObjectDetails,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s BaseJobDetailsImpl) JobDetails() BaseJobDetailsImpl { + return s +} + +var _ JobDetails = RawJobDetailsImpl{} + +// RawJobDetailsImpl 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 RawJobDetailsImpl struct { + jobDetails BaseJobDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawJobDetailsImpl) JobDetails() BaseJobDetailsImpl { + return s.jobDetails +} + +func UnmarshalJobDetailsImplementation(input []byte) (JobDetails, 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 JobDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AsrJobDetails") { + var out AsrJobDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AsrJobDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ClusterFailoverJobDetails") { + var out ClusterFailoverJobDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ClusterFailoverJobDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ClusterSwitchProtectionJobDetails") { + var out ClusterSwitchProtectionJobDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ClusterSwitchProtectionJobDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ClusterTestFailoverJobDetails") { + var out ClusterTestFailoverJobDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ClusterTestFailoverJobDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ExportJobDetails") { + var out ExportJobDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ExportJobDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "FailoverJobDetails") { + var out FailoverJobDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into FailoverJobDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SwitchProtectionJobDetails") { + var out SwitchProtectionJobDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SwitchProtectionJobDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "TestFailoverJobDetails") { + var out TestFailoverJobDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into TestFailoverJobDetails: %+v", err) + } + return out, nil + } + + var parent BaseJobDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseJobDetailsImpl: %+v", err) + } + + return RawJobDetailsImpl{ + jobDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_jobentity.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_jobentity.go new file mode 100644 index 00000000000..e3cbaea444e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_jobentity.go @@ -0,0 +1,13 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobEntity struct { + JobFriendlyName *string `json:"jobFriendlyName,omitempty"` + JobId *string `json:"jobId,omitempty"` + JobScenarioName *string `json:"jobScenarioName,omitempty"` + TargetInstanceType *string `json:"targetInstanceType,omitempty"` + TargetObjectId *string `json:"targetObjectId,omitempty"` + TargetObjectName *string `json:"targetObjectName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_joberrordetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_joberrordetails.go new file mode 100644 index 00000000000..797e2dc1bd1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_joberrordetails.go @@ -0,0 +1,30 @@ +package replicationjobs + +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 JobErrorDetails struct { + CreationTime *string `json:"creationTime,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ProviderErrorDetails *ProviderError `json:"providerErrorDetails,omitempty"` + ServiceErrorDetails *ServiceError `json:"serviceErrorDetails,omitempty"` + TaskId *string `json:"taskId,omitempty"` +} + +func (o *JobErrorDetails) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *JobErrorDetails) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_jobproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_jobproperties.go new file mode 100644 index 00000000000..a63dbf5d5f9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_jobproperties.go @@ -0,0 +1,105 @@ +package replicationjobs + +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. + +type JobProperties struct { + ActivityId *string `json:"activityId,omitempty"` + AllowedActions *[]string `json:"allowedActions,omitempty"` + CustomDetails JobDetails `json:"customDetails"` + EndTime *string `json:"endTime,omitempty"` + Errors *[]JobErrorDetails `json:"errors,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ScenarioName *string `json:"scenarioName,omitempty"` + StartTime *string `json:"startTime,omitempty"` + State *string `json:"state,omitempty"` + StateDescription *string `json:"stateDescription,omitempty"` + TargetInstanceType *string `json:"targetInstanceType,omitempty"` + TargetObjectId *string `json:"targetObjectId,omitempty"` + TargetObjectName *string `json:"targetObjectName,omitempty"` + Tasks *[]ASRTask `json:"tasks,omitempty"` +} + +func (o *JobProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *JobProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *JobProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *JobProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Unmarshaler = &JobProperties{} + +func (s *JobProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ActivityId *string `json:"activityId,omitempty"` + AllowedActions *[]string `json:"allowedActions,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Errors *[]JobErrorDetails `json:"errors,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ScenarioName *string `json:"scenarioName,omitempty"` + StartTime *string `json:"startTime,omitempty"` + State *string `json:"state,omitempty"` + StateDescription *string `json:"stateDescription,omitempty"` + TargetInstanceType *string `json:"targetInstanceType,omitempty"` + TargetObjectId *string `json:"targetObjectId,omitempty"` + TargetObjectName *string `json:"targetObjectName,omitempty"` + Tasks *[]ASRTask `json:"tasks,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ActivityId = decoded.ActivityId + s.AllowedActions = decoded.AllowedActions + s.EndTime = decoded.EndTime + s.Errors = decoded.Errors + s.FriendlyName = decoded.FriendlyName + s.ScenarioName = decoded.ScenarioName + s.StartTime = decoded.StartTime + s.State = decoded.State + s.StateDescription = decoded.StateDescription + s.TargetInstanceType = decoded.TargetInstanceType + s.TargetObjectId = decoded.TargetObjectId + s.TargetObjectName = decoded.TargetObjectName + s.Tasks = decoded.Tasks + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling JobProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["customDetails"]; ok { + impl, err := UnmarshalJobDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CustomDetails' for 'JobProperties': %+v", err) + } + s.CustomDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_jobqueryparameter.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_jobqueryparameter.go new file mode 100644 index 00000000000..bc10a6b6e1d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_jobqueryparameter.go @@ -0,0 +1,15 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobQueryParameter struct { + AffectedObjectTypes *string `json:"affectedObjectTypes,omitempty"` + EndTime *string `json:"endTime,omitempty"` + FabricId *string `json:"fabricId,omitempty"` + JobName *string `json:"jobName,omitempty"` + JobOutputType *ExportJobOutputSerializationType `json:"jobOutputType,omitempty"` + JobStatus *string `json:"jobStatus,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimezoneOffset *float64 `json:"timezoneOffset,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_jobtaskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_jobtaskdetails.go new file mode 100644 index 00000000000..3ef70d2bc39 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_jobtaskdetails.go @@ -0,0 +1,50 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TaskTypeDetails = JobTaskDetails{} + +type JobTaskDetails struct { + JobTask *JobEntity `json:"jobTask,omitempty"` + + // Fields inherited from TaskTypeDetails + + InstanceType string `json:"instanceType"` +} + +func (s JobTaskDetails) TaskTypeDetails() BaseTaskTypeDetailsImpl { + return BaseTaskTypeDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = JobTaskDetails{} + +func (s JobTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper JobTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling JobTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling JobTaskDetails: %+v", err) + } + + decoded["instanceType"] = "JobTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling JobTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_manualactiontaskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_manualactiontaskdetails.go new file mode 100644 index 00000000000..6b274494184 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_manualactiontaskdetails.go @@ -0,0 +1,52 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TaskTypeDetails = ManualActionTaskDetails{} + +type ManualActionTaskDetails struct { + Instructions *string `json:"instructions,omitempty"` + Name *string `json:"name,omitempty"` + Observation *string `json:"observation,omitempty"` + + // Fields inherited from TaskTypeDetails + + InstanceType string `json:"instanceType"` +} + +func (s ManualActionTaskDetails) TaskTypeDetails() BaseTaskTypeDetailsImpl { + return BaseTaskTypeDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = ManualActionTaskDetails{} + +func (s ManualActionTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper ManualActionTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ManualActionTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ManualActionTaskDetails: %+v", err) + } + + decoded["instanceType"] = "ManualActionTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ManualActionTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_providererror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_providererror.go new file mode 100644 index 00000000000..e7f3a6131ee --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_providererror.go @@ -0,0 +1,12 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProviderError struct { + ErrorCode *int64 `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_recoveryplangrouptaskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_recoveryplangrouptaskdetails.go new file mode 100644 index 00000000000..6eab9e8093b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_recoveryplangrouptaskdetails.go @@ -0,0 +1,54 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ GroupTaskDetails = RecoveryPlanGroupTaskDetails{} + +type RecoveryPlanGroupTaskDetails struct { + GroupId *string `json:"groupId,omitempty"` + Name *string `json:"name,omitempty"` + RpGroupType *string `json:"rpGroupType,omitempty"` + + // Fields inherited from GroupTaskDetails + + ChildTasks *[]ASRTask `json:"childTasks,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanGroupTaskDetails) GroupTaskDetails() BaseGroupTaskDetailsImpl { + return BaseGroupTaskDetailsImpl{ + ChildTasks: s.ChildTasks, + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanGroupTaskDetails{} + +func (s RecoveryPlanGroupTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanGroupTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanGroupTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanGroupTaskDetails: %+v", err) + } + + decoded["instanceType"] = "RecoveryPlanGroupTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanGroupTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_recoveryplanshutdowngrouptaskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_recoveryplanshutdowngrouptaskdetails.go new file mode 100644 index 00000000000..cd81c6460c1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_recoveryplanshutdowngrouptaskdetails.go @@ -0,0 +1,51 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ GroupTaskDetails = RecoveryPlanShutdownGroupTaskDetails{} + +type RecoveryPlanShutdownGroupTaskDetails struct { + + // Fields inherited from GroupTaskDetails + + ChildTasks *[]ASRTask `json:"childTasks,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanShutdownGroupTaskDetails) GroupTaskDetails() BaseGroupTaskDetailsImpl { + return BaseGroupTaskDetailsImpl{ + ChildTasks: s.ChildTasks, + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanShutdownGroupTaskDetails{} + +func (s RecoveryPlanShutdownGroupTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanShutdownGroupTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanShutdownGroupTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanShutdownGroupTaskDetails: %+v", err) + } + + decoded["instanceType"] = "RecoveryPlanShutdownGroupTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanShutdownGroupTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_resumejobparams.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_resumejobparams.go new file mode 100644 index 00000000000..c247d0c303b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_resumejobparams.go @@ -0,0 +1,8 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResumeJobParams struct { + Properties *ResumeJobParamsProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_resumejobparamsproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_resumejobparamsproperties.go new file mode 100644 index 00000000000..a4dc002b22b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_resumejobparamsproperties.go @@ -0,0 +1,8 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResumeJobParamsProperties struct { + Comments *string `json:"comments,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_scriptactiontaskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_scriptactiontaskdetails.go new file mode 100644 index 00000000000..0c01efcc79a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_scriptactiontaskdetails.go @@ -0,0 +1,53 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TaskTypeDetails = ScriptActionTaskDetails{} + +type ScriptActionTaskDetails struct { + IsPrimarySideScript *bool `json:"isPrimarySideScript,omitempty"` + Name *string `json:"name,omitempty"` + Output *string `json:"output,omitempty"` + Path *string `json:"path,omitempty"` + + // Fields inherited from TaskTypeDetails + + InstanceType string `json:"instanceType"` +} + +func (s ScriptActionTaskDetails) TaskTypeDetails() BaseTaskTypeDetailsImpl { + return BaseTaskTypeDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = ScriptActionTaskDetails{} + +func (s ScriptActionTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper ScriptActionTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ScriptActionTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ScriptActionTaskDetails: %+v", err) + } + + decoded["instanceType"] = "ScriptActionTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ScriptActionTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_serviceerror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_serviceerror.go new file mode 100644 index 00000000000..1ce1b446dc8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_serviceerror.go @@ -0,0 +1,12 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceError struct { + ActivityId *string `json:"activityId,omitempty"` + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_switchprotectionjobdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_switchprotectionjobdetails.go new file mode 100644 index 00000000000..396de18f8eb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_switchprotectionjobdetails.go @@ -0,0 +1,52 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobDetails = SwitchProtectionJobDetails{} + +type SwitchProtectionJobDetails struct { + NewReplicationProtectedItemId *string `json:"newReplicationProtectedItemId,omitempty"` + + // Fields inherited from JobDetails + + AffectedObjectDetails *map[string]string `json:"affectedObjectDetails,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s SwitchProtectionJobDetails) JobDetails() BaseJobDetailsImpl { + return BaseJobDetailsImpl{ + AffectedObjectDetails: s.AffectedObjectDetails, + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = SwitchProtectionJobDetails{} + +func (s SwitchProtectionJobDetails) MarshalJSON() ([]byte, error) { + type wrapper SwitchProtectionJobDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SwitchProtectionJobDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SwitchProtectionJobDetails: %+v", err) + } + + decoded["instanceType"] = "SwitchProtectionJobDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SwitchProtectionJobDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_tasktypedetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_tasktypedetails.go new file mode 100644 index 00000000000..cf5e57d1cd3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_tasktypedetails.go @@ -0,0 +1,115 @@ +package replicationjobs + +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 TaskTypeDetails interface { + TaskTypeDetails() BaseTaskTypeDetailsImpl +} + +var _ TaskTypeDetails = BaseTaskTypeDetailsImpl{} + +type BaseTaskTypeDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseTaskTypeDetailsImpl) TaskTypeDetails() BaseTaskTypeDetailsImpl { + return s +} + +var _ TaskTypeDetails = RawTaskTypeDetailsImpl{} + +// RawTaskTypeDetailsImpl 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 RawTaskTypeDetailsImpl struct { + taskTypeDetails BaseTaskTypeDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawTaskTypeDetailsImpl) TaskTypeDetails() BaseTaskTypeDetailsImpl { + return s.taskTypeDetails +} + +func UnmarshalTaskTypeDetailsImplementation(input []byte) (TaskTypeDetails, 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 TaskTypeDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AutomationRunbookTaskDetails") { + var out AutomationRunbookTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AutomationRunbookTaskDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ConsistencyCheckTaskDetails") { + var out ConsistencyCheckTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ConsistencyCheckTaskDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "JobTaskDetails") { + var out JobTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into JobTaskDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ManualActionTaskDetails") { + var out ManualActionTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ManualActionTaskDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ScriptActionTaskDetails") { + var out ScriptActionTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ScriptActionTaskDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VmNicUpdatesTaskDetails") { + var out VMNicUpdatesTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMNicUpdatesTaskDetails: %+v", err) + } + return out, nil + } + + var parent BaseTaskTypeDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseTaskTypeDetailsImpl: %+v", err) + } + + return RawTaskTypeDetailsImpl{ + taskTypeDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_testfailoverjobdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_testfailoverjobdetails.go new file mode 100644 index 00000000000..60e90887c9e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_testfailoverjobdetails.go @@ -0,0 +1,57 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobDetails = TestFailoverJobDetails{} + +type TestFailoverJobDetails struct { + Comments *string `json:"comments,omitempty"` + NetworkFriendlyName *string `json:"networkFriendlyName,omitempty"` + NetworkName *string `json:"networkName,omitempty"` + NetworkType *string `json:"networkType,omitempty"` + ProtectedItemDetails *[]FailoverReplicationProtectedItemDetails `json:"protectedItemDetails,omitempty"` + TestFailoverStatus *string `json:"testFailoverStatus,omitempty"` + + // Fields inherited from JobDetails + + AffectedObjectDetails *map[string]string `json:"affectedObjectDetails,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s TestFailoverJobDetails) JobDetails() BaseJobDetailsImpl { + return BaseJobDetailsImpl{ + AffectedObjectDetails: s.AffectedObjectDetails, + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = TestFailoverJobDetails{} + +func (s TestFailoverJobDetails) MarshalJSON() ([]byte, error) { + type wrapper TestFailoverJobDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling TestFailoverJobDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling TestFailoverJobDetails: %+v", err) + } + + decoded["instanceType"] = "TestFailoverJobDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling TestFailoverJobDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_virtualmachinetaskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_virtualmachinetaskdetails.go new file mode 100644 index 00000000000..0bed7483e0a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_virtualmachinetaskdetails.go @@ -0,0 +1,51 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TaskTypeDetails = VirtualMachineTaskDetails{} + +type VirtualMachineTaskDetails struct { + SkippedReason *string `json:"skippedReason,omitempty"` + SkippedReasonString *string `json:"skippedReasonString,omitempty"` + + // Fields inherited from TaskTypeDetails + + InstanceType string `json:"instanceType"` +} + +func (s VirtualMachineTaskDetails) TaskTypeDetails() BaseTaskTypeDetailsImpl { + return BaseTaskTypeDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VirtualMachineTaskDetails{} + +func (s VirtualMachineTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper VirtualMachineTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VirtualMachineTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VirtualMachineTaskDetails: %+v", err) + } + + decoded["instanceType"] = "VirtualMachineTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VirtualMachineTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_vmnicupdatestaskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_vmnicupdatestaskdetails.go new file mode 100644 index 00000000000..e20168ec669 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/model_vmnicupdatestaskdetails.go @@ -0,0 +1,52 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TaskTypeDetails = VMNicUpdatesTaskDetails{} + +type VMNicUpdatesTaskDetails struct { + Name *string `json:"name,omitempty"` + NicId *string `json:"nicId,omitempty"` + VMId *string `json:"vmId,omitempty"` + + // Fields inherited from TaskTypeDetails + + InstanceType string `json:"instanceType"` +} + +func (s VMNicUpdatesTaskDetails) TaskTypeDetails() BaseTaskTypeDetailsImpl { + return BaseTaskTypeDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMNicUpdatesTaskDetails{} + +func (s VMNicUpdatesTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper VMNicUpdatesTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMNicUpdatesTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMNicUpdatesTaskDetails: %+v", err) + } + + decoded["instanceType"] = "VmNicUpdatesTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMNicUpdatesTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/predicates.go new file mode 100644 index 00000000000..840f78ec8e3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/predicates.go @@ -0,0 +1,32 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p JobOperationPredicate) Matches(input Job) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/version.go new file mode 100644 index 00000000000..501006cf6cc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationjobs/version.go @@ -0,0 +1,10 @@ +package replicationjobs + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationjobs/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/README.md new file mode 100644 index 00000000000..81d9e71785b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks` Documentation + +The `replicationlogicalnetworks` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks" +``` + + +### Client Initialization + +```go +client := replicationlogicalnetworks.NewReplicationLogicalNetworksClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationLogicalNetworksClient.Get` + +```go +ctx := context.TODO() +id := replicationlogicalnetworks.NewReplicationLogicalNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationLogicalNetworkName") + +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: `ReplicationLogicalNetworksClient.ListByReplicationFabrics` + +```go +ctx := context.TODO() +id := replicationlogicalnetworks.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +// alternatively `client.ListByReplicationFabrics(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationFabricsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/client.go new file mode 100644 index 00000000000..c3f18b03d72 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/client.go @@ -0,0 +1,26 @@ +package replicationlogicalnetworks + +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 ReplicationLogicalNetworksClient struct { + Client *resourcemanager.Client +} + +func NewReplicationLogicalNetworksClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationLogicalNetworksClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationlogicalnetworks", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationLogicalNetworksClient: %+v", err) + } + + return &ReplicationLogicalNetworksClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/id_replicationfabric.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/id_replicationfabric.go new file mode 100644 index 00000000000..cd151e6011f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/id_replicationfabric.go @@ -0,0 +1,139 @@ +package replicationlogicalnetworks + +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(&ReplicationFabricId{}) +} + +var _ resourceids.ResourceId = &ReplicationFabricId{} + +// ReplicationFabricId is a struct representing the Resource ID for a Replication Fabric +type ReplicationFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string +} + +// NewReplicationFabricID returns a new ReplicationFabricId struct +func NewReplicationFabricID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string) ReplicationFabricId { + return ReplicationFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + } +} + +// ParseReplicationFabricID parses 'input' into a ReplicationFabricId +func ParseReplicationFabricID(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationFabricIDInsensitively parses 'input' case-insensitively into a ReplicationFabricId +// note: this method should only be used for API response data and not user input +func ParseReplicationFabricIDInsensitively(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationFabricId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + return nil +} + +// ValidateReplicationFabricID checks that 'input' can be parsed as a Replication Fabric ID +func ValidateReplicationFabricID(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 := ParseReplicationFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Fabric ID +func (id ReplicationFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Fabric ID +func (id ReplicationFabricId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + } +} + +// String returns a human-readable description of this Replication Fabric ID +func (id ReplicationFabricId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + } + return fmt.Sprintf("Replication Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/id_replicationfabric_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/id_replicationfabric_test.go new file mode 100644 index 00000000000..09d32c71688 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/id_replicationfabric_test.go @@ -0,0 +1,327 @@ +package replicationlogicalnetworks + +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 = &ReplicationFabricId{} + +func TestNewReplicationFabricID(t *testing.T) { + id := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } +} + +func TestFormatReplicationFabricID(t *testing.T) { + actual := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestParseReplicationFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestSegmentsForReplicationFabricId(t *testing.T) { + segments := ReplicationFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationFabricId 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/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/id_replicationlogicalnetwork.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/id_replicationlogicalnetwork.go new file mode 100644 index 00000000000..7f9fd6f74ba --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/id_replicationlogicalnetwork.go @@ -0,0 +1,148 @@ +package replicationlogicalnetworks + +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(&ReplicationLogicalNetworkId{}) +} + +var _ resourceids.ResourceId = &ReplicationLogicalNetworkId{} + +// ReplicationLogicalNetworkId is a struct representing the Resource ID for a Replication Logical Network +type ReplicationLogicalNetworkId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationLogicalNetworkName string +} + +// NewReplicationLogicalNetworkID returns a new ReplicationLogicalNetworkId struct +func NewReplicationLogicalNetworkID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationLogicalNetworkName string) ReplicationLogicalNetworkId { + return ReplicationLogicalNetworkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationLogicalNetworkName: replicationLogicalNetworkName, + } +} + +// ParseReplicationLogicalNetworkID parses 'input' into a ReplicationLogicalNetworkId +func ParseReplicationLogicalNetworkID(input string) (*ReplicationLogicalNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationLogicalNetworkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationLogicalNetworkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationLogicalNetworkIDInsensitively parses 'input' case-insensitively into a ReplicationLogicalNetworkId +// note: this method should only be used for API response data and not user input +func ParseReplicationLogicalNetworkIDInsensitively(input string) (*ReplicationLogicalNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationLogicalNetworkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationLogicalNetworkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationLogicalNetworkId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationLogicalNetworkName, ok = input.Parsed["replicationLogicalNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationLogicalNetworkName", input) + } + + return nil +} + +// ValidateReplicationLogicalNetworkID checks that 'input' can be parsed as a Replication Logical Network ID +func ValidateReplicationLogicalNetworkID(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 := ParseReplicationLogicalNetworkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Logical Network ID +func (id ReplicationLogicalNetworkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationLogicalNetworks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationLogicalNetworkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Logical Network ID +func (id ReplicationLogicalNetworkId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationLogicalNetworks", "replicationLogicalNetworks", "replicationLogicalNetworks"), + resourceids.UserSpecifiedSegment("replicationLogicalNetworkName", "replicationLogicalNetworkName"), + } +} + +// String returns a human-readable description of this Replication Logical Network ID +func (id ReplicationLogicalNetworkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Logical Network Name: %q", id.ReplicationLogicalNetworkName), + } + return fmt.Sprintf("Replication Logical Network (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/id_replicationlogicalnetwork_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/id_replicationlogicalnetwork_test.go new file mode 100644 index 00000000000..d0a55e18453 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/id_replicationlogicalnetwork_test.go @@ -0,0 +1,372 @@ +package replicationlogicalnetworks + +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 = &ReplicationLogicalNetworkId{} + +func TestNewReplicationLogicalNetworkID(t *testing.T) { + id := NewReplicationLogicalNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationLogicalNetworkName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationLogicalNetworkName != "replicationLogicalNetworkName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationLogicalNetworkName'", id.ReplicationLogicalNetworkName, "replicationLogicalNetworkName") + } +} + +func TestFormatReplicationLogicalNetworkID(t *testing.T) { + actual := NewReplicationLogicalNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationLogicalNetworkName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationLogicalNetworks/replicationLogicalNetworkName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationLogicalNetworkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationLogicalNetworkId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationLogicalNetworks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationLogicalNetworks/replicationLogicalNetworkName", + Expected: &ReplicationLogicalNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationLogicalNetworkName: "replicationLogicalNetworkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationLogicalNetworks/replicationLogicalNetworkName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationLogicalNetworkID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationLogicalNetworkName != v.Expected.ReplicationLogicalNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationLogicalNetworkName", v.Expected.ReplicationLogicalNetworkName, actual.ReplicationLogicalNetworkName) + } + + } +} + +func TestParseReplicationLogicalNetworkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationLogicalNetworkId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationLogicalNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnLoGiCaLnEtWoRkS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationLogicalNetworks/replicationLogicalNetworkName", + Expected: &ReplicationLogicalNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationLogicalNetworkName: "replicationLogicalNetworkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationLogicalNetworks/replicationLogicalNetworkName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnLoGiCaLnEtWoRkS/rEpLiCaTiOnLoGiCaLnEtWoRkNaMe", + Expected: &ReplicationLogicalNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationLogicalNetworkName: "rEpLiCaTiOnLoGiCaLnEtWoRkNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnLoGiCaLnEtWoRkS/rEpLiCaTiOnLoGiCaLnEtWoRkNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationLogicalNetworkIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationLogicalNetworkName != v.Expected.ReplicationLogicalNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationLogicalNetworkName", v.Expected.ReplicationLogicalNetworkName, actual.ReplicationLogicalNetworkName) + } + + } +} + +func TestSegmentsForReplicationLogicalNetworkId(t *testing.T) { + segments := ReplicationLogicalNetworkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationLogicalNetworkId 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/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/method_get.go new file mode 100644 index 00000000000..c6334546f1e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/method_get.go @@ -0,0 +1,53 @@ +package replicationlogicalnetworks + +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 *LogicalNetwork +} + +// Get ... +func (c ReplicationLogicalNetworksClient) Get(ctx context.Context, id ReplicationLogicalNetworkId) (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 LogicalNetwork + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/method_listbyreplicationfabrics.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/method_listbyreplicationfabrics.go new file mode 100644 index 00000000000..e9fef6356f3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/method_listbyreplicationfabrics.go @@ -0,0 +1,105 @@ +package replicationlogicalnetworks + +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 ListByReplicationFabricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LogicalNetwork +} + +type ListByReplicationFabricsCompleteResult struct { + LatestHttpResponse *http.Response + Items []LogicalNetwork +} + +type ListByReplicationFabricsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationFabricsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationFabrics ... +func (c ReplicationLogicalNetworksClient) ListByReplicationFabrics(ctx context.Context, id ReplicationFabricId) (result ListByReplicationFabricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationFabricsCustomPager{}, + Path: fmt.Sprintf("%s/replicationLogicalNetworks", 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 *[]LogicalNetwork `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationFabricsComplete retrieves all the results into a single object +func (c ReplicationLogicalNetworksClient) ListByReplicationFabricsComplete(ctx context.Context, id ReplicationFabricId) (ListByReplicationFabricsCompleteResult, error) { + return c.ListByReplicationFabricsCompleteMatchingPredicate(ctx, id, LogicalNetworkOperationPredicate{}) +} + +// ListByReplicationFabricsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationLogicalNetworksClient) ListByReplicationFabricsCompleteMatchingPredicate(ctx context.Context, id ReplicationFabricId, predicate LogicalNetworkOperationPredicate) (result ListByReplicationFabricsCompleteResult, err error) { + items := make([]LogicalNetwork, 0) + + resp, err := c.ListByReplicationFabrics(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 = ListByReplicationFabricsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/model_logicalnetwork.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/model_logicalnetwork.go new file mode 100644 index 00000000000..957182ab3db --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/model_logicalnetwork.go @@ -0,0 +1,12 @@ +package replicationlogicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogicalNetwork struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *LogicalNetworkProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/model_logicalnetworkproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/model_logicalnetworkproperties.go new file mode 100644 index 00000000000..2200c344760 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/model_logicalnetworkproperties.go @@ -0,0 +1,11 @@ +package replicationlogicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogicalNetworkProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + LogicalNetworkDefinitionsStatus *string `json:"logicalNetworkDefinitionsStatus,omitempty"` + LogicalNetworkUsage *string `json:"logicalNetworkUsage,omitempty"` + NetworkVirtualizationStatus *string `json:"networkVirtualizationStatus,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/predicates.go new file mode 100644 index 00000000000..30e71a8f92c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/predicates.go @@ -0,0 +1,32 @@ +package replicationlogicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogicalNetworkOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p LogicalNetworkOperationPredicate) Matches(input LogicalNetwork) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/version.go new file mode 100644 index 00000000000..f118b08c4e6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationlogicalnetworks/version.go @@ -0,0 +1,10 @@ +package replicationlogicalnetworks + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationlogicalnetworks/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/README.md new file mode 100644 index 00000000000..61385207b0e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/README.md @@ -0,0 +1,218 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems` Documentation + +The `replicationmigrationitems` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems" +``` + + +### Client Initialization + +```go +client := replicationmigrationitems.NewReplicationMigrationItemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationMigrationItemsClient.Create` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + +payload := replicationmigrationitems.EnableMigrationInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.Delete` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + +if err := client.DeleteThenPoll(ctx, id, replicationmigrationitems.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.Get` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + +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: `ReplicationMigrationItemsClient.List` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id, replicationmigrationitems.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, replicationmigrationitems.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.ListByReplicationProtectionContainers` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + +// alternatively `client.ListByReplicationProtectionContainers(ctx, id, replicationmigrationitems.DefaultListByReplicationProtectionContainersOperationOptions())` can be used to do batched pagination +items, err := client.ListByReplicationProtectionContainersComplete(ctx, id, replicationmigrationitems.DefaultListByReplicationProtectionContainersOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.Migrate` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + +payload := replicationmigrationitems.MigrateInput{ + // ... +} + + +if err := client.MigrateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.PauseReplication` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + +payload := replicationmigrationitems.PauseReplicationInput{ + // ... +} + + +if err := client.PauseReplicationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.ResumeReplication` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + +payload := replicationmigrationitems.ResumeReplicationInput{ + // ... +} + + +if err := client.ResumeReplicationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.Resync` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + +payload := replicationmigrationitems.ResyncInput{ + // ... +} + + +if err := client.ResyncThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.TestMigrate` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + +payload := replicationmigrationitems.TestMigrateInput{ + // ... +} + + +if err := client.TestMigrateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.TestMigrateCleanup` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + +payload := replicationmigrationitems.TestMigrateCleanupInput{ + // ... +} + + +if err := client.TestMigrateCleanupThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.Update` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + +payload := replicationmigrationitems.UpdateMigrationItemInput{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/client.go new file mode 100644 index 00000000000..65aedf397c6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/client.go @@ -0,0 +1,26 @@ +package replicationmigrationitems + +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 ReplicationMigrationItemsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationMigrationItemsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationMigrationItemsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationmigrationitems", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationMigrationItemsClient: %+v", err) + } + + return &ReplicationMigrationItemsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/constants.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/constants.go new file mode 100644 index 00000000000..b87ce8828c0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/constants.go @@ -0,0 +1,616 @@ +package replicationmigrationitems + +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 DiskAccountType string + +const ( + DiskAccountTypePremiumLRS DiskAccountType = "Premium_LRS" + DiskAccountTypePremiumVTwoLRS DiskAccountType = "PremiumV2_LRS" + DiskAccountTypePremiumZRS DiskAccountType = "Premium_ZRS" + DiskAccountTypeStandardLRS DiskAccountType = "Standard_LRS" + DiskAccountTypeStandardSSDLRS DiskAccountType = "StandardSSD_LRS" + DiskAccountTypeStandardSSDZRS DiskAccountType = "StandardSSD_ZRS" + DiskAccountTypeUltraSSDLRS DiskAccountType = "UltraSSD_LRS" +) + +func PossibleValuesForDiskAccountType() []string { + return []string{ + string(DiskAccountTypePremiumLRS), + string(DiskAccountTypePremiumVTwoLRS), + string(DiskAccountTypePremiumZRS), + string(DiskAccountTypeStandardLRS), + string(DiskAccountTypeStandardSSDLRS), + string(DiskAccountTypeStandardSSDZRS), + string(DiskAccountTypeUltraSSDLRS), + } +} + +func (s *DiskAccountType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskAccountType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiskAccountType(input string) (*DiskAccountType, error) { + vals := map[string]DiskAccountType{ + "premium_lrs": DiskAccountTypePremiumLRS, + "premiumv2_lrs": DiskAccountTypePremiumVTwoLRS, + "premium_zrs": DiskAccountTypePremiumZRS, + "standard_lrs": DiskAccountTypeStandardLRS, + "standardssd_lrs": DiskAccountTypeStandardSSDLRS, + "standardssd_zrs": DiskAccountTypeStandardSSDZRS, + "ultrassd_lrs": DiskAccountTypeUltraSSDLRS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiskAccountType(input) + return &out, nil +} + +type EthernetAddressType string + +const ( + EthernetAddressTypeDynamic EthernetAddressType = "Dynamic" + EthernetAddressTypeStatic EthernetAddressType = "Static" +) + +func PossibleValuesForEthernetAddressType() []string { + return []string{ + string(EthernetAddressTypeDynamic), + string(EthernetAddressTypeStatic), + } +} + +func (s *EthernetAddressType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEthernetAddressType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEthernetAddressType(input string) (*EthernetAddressType, error) { + vals := map[string]EthernetAddressType{ + "dynamic": EthernetAddressTypeDynamic, + "static": EthernetAddressTypeStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EthernetAddressType(input) + return &out, nil +} + +type HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} + +type LicenseType string + +const ( + LicenseTypeNoLicenseType LicenseType = "NoLicenseType" + LicenseTypeNotSpecified LicenseType = "NotSpecified" + LicenseTypeWindowsServer LicenseType = "WindowsServer" +) + +func PossibleValuesForLicenseType() []string { + return []string{ + string(LicenseTypeNoLicenseType), + string(LicenseTypeNotSpecified), + string(LicenseTypeWindowsServer), + } +} + +func (s *LicenseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLicenseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLicenseType(input string) (*LicenseType, error) { + vals := map[string]LicenseType{ + "nolicensetype": LicenseTypeNoLicenseType, + "notspecified": LicenseTypeNotSpecified, + "windowsserver": LicenseTypeWindowsServer, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LicenseType(input) + return &out, nil +} + +type LinuxLicenseType string + +const ( + LinuxLicenseTypeLinuxServer LinuxLicenseType = "LinuxServer" + LinuxLicenseTypeNoLicenseType LinuxLicenseType = "NoLicenseType" + LinuxLicenseTypeNotSpecified LinuxLicenseType = "NotSpecified" +) + +func PossibleValuesForLinuxLicenseType() []string { + return []string{ + string(LinuxLicenseTypeLinuxServer), + string(LinuxLicenseTypeNoLicenseType), + string(LinuxLicenseTypeNotSpecified), + } +} + +func (s *LinuxLicenseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLinuxLicenseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLinuxLicenseType(input string) (*LinuxLicenseType, error) { + vals := map[string]LinuxLicenseType{ + "linuxserver": LinuxLicenseTypeLinuxServer, + "nolicensetype": LinuxLicenseTypeNoLicenseType, + "notspecified": LinuxLicenseTypeNotSpecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LinuxLicenseType(input) + return &out, nil +} + +type MigrationItemOperation string + +const ( + MigrationItemOperationDisableMigration MigrationItemOperation = "DisableMigration" + MigrationItemOperationMigrate MigrationItemOperation = "Migrate" + MigrationItemOperationPauseReplication MigrationItemOperation = "PauseReplication" + MigrationItemOperationResumeReplication MigrationItemOperation = "ResumeReplication" + MigrationItemOperationStartResync MigrationItemOperation = "StartResync" + MigrationItemOperationTestMigrate MigrationItemOperation = "TestMigrate" + MigrationItemOperationTestMigrateCleanup MigrationItemOperation = "TestMigrateCleanup" +) + +func PossibleValuesForMigrationItemOperation() []string { + return []string{ + string(MigrationItemOperationDisableMigration), + string(MigrationItemOperationMigrate), + string(MigrationItemOperationPauseReplication), + string(MigrationItemOperationResumeReplication), + string(MigrationItemOperationStartResync), + string(MigrationItemOperationTestMigrate), + string(MigrationItemOperationTestMigrateCleanup), + } +} + +func (s *MigrationItemOperation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMigrationItemOperation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMigrationItemOperation(input string) (*MigrationItemOperation, error) { + vals := map[string]MigrationItemOperation{ + "disablemigration": MigrationItemOperationDisableMigration, + "migrate": MigrationItemOperationMigrate, + "pausereplication": MigrationItemOperationPauseReplication, + "resumereplication": MigrationItemOperationResumeReplication, + "startresync": MigrationItemOperationStartResync, + "testmigrate": MigrationItemOperationTestMigrate, + "testmigratecleanup": MigrationItemOperationTestMigrateCleanup, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MigrationItemOperation(input) + return &out, nil +} + +type MigrationState string + +const ( + MigrationStateDisableMigrationFailed MigrationState = "DisableMigrationFailed" + MigrationStateDisableMigrationInProgress MigrationState = "DisableMigrationInProgress" + MigrationStateEnableMigrationFailed MigrationState = "EnableMigrationFailed" + MigrationStateEnableMigrationInProgress MigrationState = "EnableMigrationInProgress" + MigrationStateInitialSeedingFailed MigrationState = "InitialSeedingFailed" + MigrationStateInitialSeedingInProgress MigrationState = "InitialSeedingInProgress" + MigrationStateMigrationCompletedWithInformation MigrationState = "MigrationCompletedWithInformation" + MigrationStateMigrationFailed MigrationState = "MigrationFailed" + MigrationStateMigrationInProgress MigrationState = "MigrationInProgress" + MigrationStateMigrationPartiallySucceeded MigrationState = "MigrationPartiallySucceeded" + MigrationStateMigrationSucceeded MigrationState = "MigrationSucceeded" + MigrationStateNone MigrationState = "None" + MigrationStateProtectionSuspended MigrationState = "ProtectionSuspended" + MigrationStateReplicating MigrationState = "Replicating" + MigrationStateResumeInProgress MigrationState = "ResumeInProgress" + MigrationStateResumeInitiated MigrationState = "ResumeInitiated" + MigrationStateSuspendingProtection MigrationState = "SuspendingProtection" +) + +func PossibleValuesForMigrationState() []string { + return []string{ + string(MigrationStateDisableMigrationFailed), + string(MigrationStateDisableMigrationInProgress), + string(MigrationStateEnableMigrationFailed), + string(MigrationStateEnableMigrationInProgress), + string(MigrationStateInitialSeedingFailed), + string(MigrationStateInitialSeedingInProgress), + string(MigrationStateMigrationCompletedWithInformation), + string(MigrationStateMigrationFailed), + string(MigrationStateMigrationInProgress), + string(MigrationStateMigrationPartiallySucceeded), + string(MigrationStateMigrationSucceeded), + string(MigrationStateNone), + string(MigrationStateProtectionSuspended), + string(MigrationStateReplicating), + string(MigrationStateResumeInProgress), + string(MigrationStateResumeInitiated), + string(MigrationStateSuspendingProtection), + } +} + +func (s *MigrationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMigrationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMigrationState(input string) (*MigrationState, error) { + vals := map[string]MigrationState{ + "disablemigrationfailed": MigrationStateDisableMigrationFailed, + "disablemigrationinprogress": MigrationStateDisableMigrationInProgress, + "enablemigrationfailed": MigrationStateEnableMigrationFailed, + "enablemigrationinprogress": MigrationStateEnableMigrationInProgress, + "initialseedingfailed": MigrationStateInitialSeedingFailed, + "initialseedinginprogress": MigrationStateInitialSeedingInProgress, + "migrationcompletedwithinformation": MigrationStateMigrationCompletedWithInformation, + "migrationfailed": MigrationStateMigrationFailed, + "migrationinprogress": MigrationStateMigrationInProgress, + "migrationpartiallysucceeded": MigrationStateMigrationPartiallySucceeded, + "migrationsucceeded": MigrationStateMigrationSucceeded, + "none": MigrationStateNone, + "protectionsuspended": MigrationStateProtectionSuspended, + "replicating": MigrationStateReplicating, + "resumeinprogress": MigrationStateResumeInProgress, + "resumeinitiated": MigrationStateResumeInitiated, + "suspendingprotection": MigrationStateSuspendingProtection, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MigrationState(input) + return &out, nil +} + +type ProtectionHealth string + +const ( + ProtectionHealthCritical ProtectionHealth = "Critical" + ProtectionHealthNone ProtectionHealth = "None" + ProtectionHealthNormal ProtectionHealth = "Normal" + ProtectionHealthWarning ProtectionHealth = "Warning" +) + +func PossibleValuesForProtectionHealth() []string { + return []string{ + string(ProtectionHealthCritical), + string(ProtectionHealthNone), + string(ProtectionHealthNormal), + string(ProtectionHealthWarning), + } +} + +func (s *ProtectionHealth) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProtectionHealth(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProtectionHealth(input string) (*ProtectionHealth, error) { + vals := map[string]ProtectionHealth{ + "critical": ProtectionHealthCritical, + "none": ProtectionHealthNone, + "normal": ProtectionHealthNormal, + "warning": ProtectionHealthWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionHealth(input) + return &out, nil +} + +type ResyncState string + +const ( + ResyncStateNone ResyncState = "None" + ResyncStatePreparedForResynchronization ResyncState = "PreparedForResynchronization" + ResyncStateStartedResynchronization ResyncState = "StartedResynchronization" +) + +func PossibleValuesForResyncState() []string { + return []string{ + string(ResyncStateNone), + string(ResyncStatePreparedForResynchronization), + string(ResyncStateStartedResynchronization), + } +} + +func (s *ResyncState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResyncState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResyncState(input string) (*ResyncState, error) { + vals := map[string]ResyncState{ + "none": ResyncStateNone, + "preparedforresynchronization": ResyncStatePreparedForResynchronization, + "startedresynchronization": ResyncStateStartedResynchronization, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResyncState(input) + return &out, nil +} + +type SecurityType string + +const ( + SecurityTypeConfidentialVM SecurityType = "ConfidentialVM" + SecurityTypeNone SecurityType = "None" + SecurityTypeTrustedLaunch SecurityType = "TrustedLaunch" +) + +func PossibleValuesForSecurityType() []string { + return []string{ + string(SecurityTypeConfidentialVM), + string(SecurityTypeNone), + string(SecurityTypeTrustedLaunch), + } +} + +func (s *SecurityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityType(input string) (*SecurityType, error) { + vals := map[string]SecurityType{ + "confidentialvm": SecurityTypeConfidentialVM, + "none": SecurityTypeNone, + "trustedlaunch": SecurityTypeTrustedLaunch, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityType(input) + return &out, nil +} + +type SqlServerLicenseType string + +const ( + SqlServerLicenseTypeAHUB SqlServerLicenseType = "AHUB" + SqlServerLicenseTypeNoLicenseType SqlServerLicenseType = "NoLicenseType" + SqlServerLicenseTypeNotSpecified SqlServerLicenseType = "NotSpecified" + SqlServerLicenseTypePAYG SqlServerLicenseType = "PAYG" +) + +func PossibleValuesForSqlServerLicenseType() []string { + return []string{ + string(SqlServerLicenseTypeAHUB), + string(SqlServerLicenseTypeNoLicenseType), + string(SqlServerLicenseTypeNotSpecified), + string(SqlServerLicenseTypePAYG), + } +} + +func (s *SqlServerLicenseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSqlServerLicenseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSqlServerLicenseType(input string) (*SqlServerLicenseType, error) { + vals := map[string]SqlServerLicenseType{ + "ahub": SqlServerLicenseTypeAHUB, + "nolicensetype": SqlServerLicenseTypeNoLicenseType, + "notspecified": SqlServerLicenseTypeNotSpecified, + "payg": SqlServerLicenseTypePAYG, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SqlServerLicenseType(input) + return &out, nil +} + +type TestMigrationState string + +const ( + TestMigrationStateNone TestMigrationState = "None" + TestMigrationStateTestMigrationCleanupInProgress TestMigrationState = "TestMigrationCleanupInProgress" + TestMigrationStateTestMigrationCompletedWithInformation TestMigrationState = "TestMigrationCompletedWithInformation" + TestMigrationStateTestMigrationFailed TestMigrationState = "TestMigrationFailed" + TestMigrationStateTestMigrationInProgress TestMigrationState = "TestMigrationInProgress" + TestMigrationStateTestMigrationPartiallySucceeded TestMigrationState = "TestMigrationPartiallySucceeded" + TestMigrationStateTestMigrationSucceeded TestMigrationState = "TestMigrationSucceeded" +) + +func PossibleValuesForTestMigrationState() []string { + return []string{ + string(TestMigrationStateNone), + string(TestMigrationStateTestMigrationCleanupInProgress), + string(TestMigrationStateTestMigrationCompletedWithInformation), + string(TestMigrationStateTestMigrationFailed), + string(TestMigrationStateTestMigrationInProgress), + string(TestMigrationStateTestMigrationPartiallySucceeded), + string(TestMigrationStateTestMigrationSucceeded), + } +} + +func (s *TestMigrationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTestMigrationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTestMigrationState(input string) (*TestMigrationState, error) { + vals := map[string]TestMigrationState{ + "none": TestMigrationStateNone, + "testmigrationcleanupinprogress": TestMigrationStateTestMigrationCleanupInProgress, + "testmigrationcompletedwithinformation": TestMigrationStateTestMigrationCompletedWithInformation, + "testmigrationfailed": TestMigrationStateTestMigrationFailed, + "testmigrationinprogress": TestMigrationStateTestMigrationInProgress, + "testmigrationpartiallysucceeded": TestMigrationStateTestMigrationPartiallySucceeded, + "testmigrationsucceeded": TestMigrationStateTestMigrationSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TestMigrationState(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/id_replicationmigrationitem.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/id_replicationmigrationitem.go new file mode 100644 index 00000000000..af2c070a6aa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/id_replicationmigrationitem.go @@ -0,0 +1,157 @@ +package replicationmigrationitems + +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(&ReplicationMigrationItemId{}) +} + +var _ resourceids.ResourceId = &ReplicationMigrationItemId{} + +// ReplicationMigrationItemId is a struct representing the Resource ID for a Replication Migration Item +type ReplicationMigrationItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationMigrationItemName string +} + +// NewReplicationMigrationItemID returns a new ReplicationMigrationItemId struct +func NewReplicationMigrationItemID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationMigrationItemName string) ReplicationMigrationItemId { + return ReplicationMigrationItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationMigrationItemName: replicationMigrationItemName, + } +} + +// ParseReplicationMigrationItemID parses 'input' into a ReplicationMigrationItemId +func ParseReplicationMigrationItemID(input string) (*ReplicationMigrationItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationMigrationItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationMigrationItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationMigrationItemIDInsensitively parses 'input' case-insensitively into a ReplicationMigrationItemId +// note: this method should only be used for API response data and not user input +func ParseReplicationMigrationItemIDInsensitively(input string) (*ReplicationMigrationItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationMigrationItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationMigrationItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationMigrationItemId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationMigrationItemName, ok = input.Parsed["replicationMigrationItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationMigrationItemName", input) + } + + return nil +} + +// ValidateReplicationMigrationItemID checks that 'input' can be parsed as a Replication Migration Item ID +func ValidateReplicationMigrationItemID(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 := ParseReplicationMigrationItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Migration Item ID +func (id ReplicationMigrationItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationMigrationItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationMigrationItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Migration Item ID +func (id ReplicationMigrationItemId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationMigrationItems", "replicationMigrationItems", "replicationMigrationItems"), + resourceids.UserSpecifiedSegment("replicationMigrationItemName", "replicationMigrationItemName"), + } +} + +// String returns a human-readable description of this Replication Migration Item ID +func (id ReplicationMigrationItemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Migration Item Name: %q", id.ReplicationMigrationItemName), + } + return fmt.Sprintf("Replication Migration Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/id_replicationmigrationitem_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/id_replicationmigrationitem_test.go new file mode 100644 index 00000000000..3df0ca67a2d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/id_replicationmigrationitem_test.go @@ -0,0 +1,417 @@ +package replicationmigrationitems + +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 = &ReplicationMigrationItemId{} + +func TestNewReplicationMigrationItemID(t *testing.T) { + id := NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationMigrationItemName != "replicationMigrationItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationMigrationItemName'", id.ReplicationMigrationItemName, "replicationMigrationItemName") + } +} + +func TestFormatReplicationMigrationItemID(t *testing.T) { + actual := NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationMigrationItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationMigrationItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName", + Expected: &ReplicationMigrationItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationMigrationItemName: "replicationMigrationItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationMigrationItemID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationMigrationItemName != v.Expected.ReplicationMigrationItemName { + t.Fatalf("Expected %q but got %q for ReplicationMigrationItemName", v.Expected.ReplicationMigrationItemName, actual.ReplicationMigrationItemName) + } + + } +} + +func TestParseReplicationMigrationItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationMigrationItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnMiGrAtIoNiTeMs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName", + Expected: &ReplicationMigrationItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationMigrationItemName: "replicationMigrationItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMnAmE", + Expected: &ReplicationMigrationItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationMigrationItemName: "rEpLiCaTiOnMiGrAtIoNiTeMnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationMigrationItemIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationMigrationItemName != v.Expected.ReplicationMigrationItemName { + t.Fatalf("Expected %q but got %q for ReplicationMigrationItemName", v.Expected.ReplicationMigrationItemName, actual.ReplicationMigrationItemName) + } + + } +} + +func TestSegmentsForReplicationMigrationItemId(t *testing.T) { + segments := ReplicationMigrationItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationMigrationItemId 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/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/id_replicationprotectioncontainer.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/id_replicationprotectioncontainer.go new file mode 100644 index 00000000000..f6b59f9a420 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/id_replicationprotectioncontainer.go @@ -0,0 +1,148 @@ +package replicationmigrationitems + +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(&ReplicationProtectionContainerId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectionContainerId{} + +// ReplicationProtectionContainerId is a struct representing the Resource ID for a Replication Protection Container +type ReplicationProtectionContainerId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string +} + +// NewReplicationProtectionContainerID returns a new ReplicationProtectionContainerId struct +func NewReplicationProtectionContainerID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string) ReplicationProtectionContainerId { + return ReplicationProtectionContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + } +} + +// ParseReplicationProtectionContainerID parses 'input' into a ReplicationProtectionContainerId +func ParseReplicationProtectionContainerID(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionContainerIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionContainerId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionContainerIDInsensitively(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionContainerId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + return nil +} + +// ValidateReplicationProtectionContainerID checks that 'input' can be parsed as a Replication Protection Container ID +func ValidateReplicationProtectionContainerID(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 := ParseReplicationProtectionContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Container ID +func (id ReplicationProtectionContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Container ID +func (id ReplicationProtectionContainerId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + } +} + +// String returns a human-readable description of this Replication Protection Container ID +func (id ReplicationProtectionContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + } + return fmt.Sprintf("Replication Protection Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/id_replicationprotectioncontainer_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/id_replicationprotectioncontainer_test.go new file mode 100644 index 00000000000..7d99ad5e9be --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/id_replicationprotectioncontainer_test.go @@ -0,0 +1,372 @@ +package replicationmigrationitems + +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 = &ReplicationProtectionContainerId{} + +func TestNewReplicationProtectionContainerID(t *testing.T) { + id := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } +} + +func TestFormatReplicationProtectionContainerID(t *testing.T) { + actual := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestParseReplicationProtectionContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestSegmentsForReplicationProtectionContainerId(t *testing.T) { + segments := ReplicationProtectionContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionContainerId 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/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/id_vault.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/id_vault.go new file mode 100644 index 00000000000..5d25616da85 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/id_vault.go @@ -0,0 +1,130 @@ +package replicationmigrationitems + +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(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(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 := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/id_vault_test.go new file mode 100644 index 00000000000..b0b22c1e6a7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationmigrationitems + +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 = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId 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/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_create.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_create.go new file mode 100644 index 00000000000..8bab8c5aa6d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_create.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MigrationItem +} + +// Create ... +func (c ReplicationMigrationItemsClient) Create(ctx context.Context, id ReplicationMigrationItemId, input EnableMigrationInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationMigrationItemsClient) CreateThenPoll(ctx context.Context, id ReplicationMigrationItemId, input EnableMigrationInput) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_delete.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_delete.go new file mode 100644 index 00000000000..f156c86538f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_delete.go @@ -0,0 +1,99 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + DeleteOption *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DeleteOption != nil { + out.Append("deleteOption", fmt.Sprintf("%v", *o.DeleteOption)) + } + return &out +} + +// Delete ... +func (c ReplicationMigrationItemsClient) Delete(ctx context.Context, id ReplicationMigrationItemId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + 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 ReplicationMigrationItemsClient) DeleteThenPoll(ctx context.Context, id ReplicationMigrationItemId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_get.go new file mode 100644 index 00000000000..3baac2bfc90 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_get.go @@ -0,0 +1,53 @@ +package replicationmigrationitems + +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 *MigrationItem +} + +// Get ... +func (c ReplicationMigrationItemsClient) Get(ctx context.Context, id ReplicationMigrationItemId) (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 MigrationItem + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_list.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_list.go new file mode 100644 index 00000000000..ce56fbeda81 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_list.go @@ -0,0 +1,142 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MigrationItem +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []MigrationItem +} + +type ListOperationOptions struct { + Filter *string + SkipToken *string + TakeToken *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.SkipToken != nil { + out.Append("skipToken", fmt.Sprintf("%v", *o.SkipToken)) + } + if o.TakeToken != nil { + out.Append("takeToken", fmt.Sprintf("%v", *o.TakeToken)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ReplicationMigrationItemsClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/replicationMigrationItems", 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 *[]MigrationItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationMigrationItemsClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, MigrationItemOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationMigrationItemsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate MigrationItemOperationPredicate) (result ListCompleteResult, err error) { + items := make([]MigrationItem, 0) + + resp, err := c.List(ctx, id, options) + 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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_listbyreplicationprotectioncontainers.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_listbyreplicationprotectioncontainers.go new file mode 100644 index 00000000000..c2c9399a4ab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_listbyreplicationprotectioncontainers.go @@ -0,0 +1,142 @@ +package replicationmigrationitems + +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 ListByReplicationProtectionContainersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MigrationItem +} + +type ListByReplicationProtectionContainersCompleteResult struct { + LatestHttpResponse *http.Response + Items []MigrationItem +} + +type ListByReplicationProtectionContainersOperationOptions struct { + Filter *string + SkipToken *string + TakeToken *string +} + +func DefaultListByReplicationProtectionContainersOperationOptions() ListByReplicationProtectionContainersOperationOptions { + return ListByReplicationProtectionContainersOperationOptions{} +} + +func (o ListByReplicationProtectionContainersOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByReplicationProtectionContainersOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByReplicationProtectionContainersOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.SkipToken != nil { + out.Append("skipToken", fmt.Sprintf("%v", *o.SkipToken)) + } + if o.TakeToken != nil { + out.Append("takeToken", fmt.Sprintf("%v", *o.TakeToken)) + } + return &out +} + +type ListByReplicationProtectionContainersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationProtectionContainersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationProtectionContainers ... +func (c ReplicationMigrationItemsClient) ListByReplicationProtectionContainers(ctx context.Context, id ReplicationProtectionContainerId, options ListByReplicationProtectionContainersOperationOptions) (result ListByReplicationProtectionContainersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByReplicationProtectionContainersCustomPager{}, + Path: fmt.Sprintf("%s/replicationMigrationItems", 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 *[]MigrationItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationProtectionContainersComplete retrieves all the results into a single object +func (c ReplicationMigrationItemsClient) ListByReplicationProtectionContainersComplete(ctx context.Context, id ReplicationProtectionContainerId, options ListByReplicationProtectionContainersOperationOptions) (ListByReplicationProtectionContainersCompleteResult, error) { + return c.ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx, id, options, MigrationItemOperationPredicate{}) +} + +// ListByReplicationProtectionContainersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationMigrationItemsClient) ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx context.Context, id ReplicationProtectionContainerId, options ListByReplicationProtectionContainersOperationOptions, predicate MigrationItemOperationPredicate) (result ListByReplicationProtectionContainersCompleteResult, err error) { + items := make([]MigrationItem, 0) + + resp, err := c.ListByReplicationProtectionContainers(ctx, id, options) + 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 = ListByReplicationProtectionContainersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_migrate.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_migrate.go new file mode 100644 index 00000000000..39eeccdea24 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_migrate.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +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 MigrateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MigrationItem +} + +// Migrate ... +func (c ReplicationMigrationItemsClient) Migrate(ctx context.Context, id ReplicationMigrationItemId, input MigrateInput) (result MigrateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/migrate", 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 +} + +// MigrateThenPoll performs Migrate then polls until it's completed +func (c ReplicationMigrationItemsClient) MigrateThenPoll(ctx context.Context, id ReplicationMigrationItemId, input MigrateInput) error { + result, err := c.Migrate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Migrate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Migrate: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_pausereplication.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_pausereplication.go new file mode 100644 index 00000000000..18b469af880 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_pausereplication.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +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 PauseReplicationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MigrationItem +} + +// PauseReplication ... +func (c ReplicationMigrationItemsClient) PauseReplication(ctx context.Context, id ReplicationMigrationItemId, input PauseReplicationInput) (result PauseReplicationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/pauseReplication", 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 +} + +// PauseReplicationThenPoll performs PauseReplication then polls until it's completed +func (c ReplicationMigrationItemsClient) PauseReplicationThenPoll(ctx context.Context, id ReplicationMigrationItemId, input PauseReplicationInput) error { + result, err := c.PauseReplication(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PauseReplication: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PauseReplication: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_resumereplication.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_resumereplication.go new file mode 100644 index 00000000000..38d610dcc9f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_resumereplication.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +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 ResumeReplicationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MigrationItem +} + +// ResumeReplication ... +func (c ReplicationMigrationItemsClient) ResumeReplication(ctx context.Context, id ReplicationMigrationItemId, input ResumeReplicationInput) (result ResumeReplicationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resumeReplication", 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 +} + +// ResumeReplicationThenPoll performs ResumeReplication then polls until it's completed +func (c ReplicationMigrationItemsClient) ResumeReplicationThenPoll(ctx context.Context, id ReplicationMigrationItemId, input ResumeReplicationInput) error { + result, err := c.ResumeReplication(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ResumeReplication: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ResumeReplication: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_resync.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_resync.go new file mode 100644 index 00000000000..dd463cfd5a0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_resync.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +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 ResyncOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MigrationItem +} + +// Resync ... +func (c ReplicationMigrationItemsClient) Resync(ctx context.Context, id ReplicationMigrationItemId, input ResyncInput) (result ResyncOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resync", 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 +} + +// ResyncThenPoll performs Resync then polls until it's completed +func (c ReplicationMigrationItemsClient) ResyncThenPoll(ctx context.Context, id ReplicationMigrationItemId, input ResyncInput) error { + result, err := c.Resync(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Resync: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Resync: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_testmigrate.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_testmigrate.go new file mode 100644 index 00000000000..998b9b6f304 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_testmigrate.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +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 TestMigrateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MigrationItem +} + +// TestMigrate ... +func (c ReplicationMigrationItemsClient) TestMigrate(ctx context.Context, id ReplicationMigrationItemId, input TestMigrateInput) (result TestMigrateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testMigrate", 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 +} + +// TestMigrateThenPoll performs TestMigrate then polls until it's completed +func (c ReplicationMigrationItemsClient) TestMigrateThenPoll(ctx context.Context, id ReplicationMigrationItemId, input TestMigrateInput) error { + result, err := c.TestMigrate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TestMigrate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TestMigrate: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_testmigratecleanup.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_testmigratecleanup.go new file mode 100644 index 00000000000..0d2c2032c31 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_testmigratecleanup.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +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 TestMigrateCleanupOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MigrationItem +} + +// TestMigrateCleanup ... +func (c ReplicationMigrationItemsClient) TestMigrateCleanup(ctx context.Context, id ReplicationMigrationItemId, input TestMigrateCleanupInput) (result TestMigrateCleanupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testMigrateCleanup", 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 +} + +// TestMigrateCleanupThenPoll performs TestMigrateCleanup then polls until it's completed +func (c ReplicationMigrationItemsClient) TestMigrateCleanupThenPoll(ctx context.Context, id ReplicationMigrationItemId, input TestMigrateCleanupInput) error { + result, err := c.TestMigrateCleanup(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TestMigrateCleanup: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TestMigrateCleanup: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_update.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_update.go new file mode 100644 index 00000000000..cb63d5a8133 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/method_update.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +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 *MigrationItem +} + +// Update ... +func (c ReplicationMigrationItemsClient) Update(ctx context.Context, id ReplicationMigrationItemId, input UpdateMigrationItemInput) (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 ReplicationMigrationItemsClient) UpdateThenPoll(ctx context.Context, id ReplicationMigrationItemId, input UpdateMigrationItemInput) 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/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_appliancemonitoringdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_appliancemonitoringdetails.go new file mode 100644 index 00000000000..4fe6ced44c2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_appliancemonitoringdetails.go @@ -0,0 +1,13 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplianceMonitoringDetails struct { + CpuDetails *ApplianceResourceDetails `json:"cpuDetails,omitempty"` + DatastoreSnapshot *[]DataStoreUtilizationDetails `json:"datastoreSnapshot,omitempty"` + DisksReplicationDetails *ApplianceResourceDetails `json:"disksReplicationDetails,omitempty"` + EsxiNfcBuffer *ApplianceResourceDetails `json:"esxiNfcBuffer,omitempty"` + NetworkBandwidth *ApplianceResourceDetails `json:"networkBandwidth,omitempty"` + RamDetails *ApplianceResourceDetails `json:"ramDetails,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_applianceresourcedetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_applianceresourcedetails.go new file mode 100644 index 00000000000..d2d7263c748 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_applianceresourcedetails.go @@ -0,0 +1,11 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplianceResourceDetails struct { + Capacity *int64 `json:"capacity,omitempty"` + ProcessUtilization *float64 `json:"processUtilization,omitempty"` + Status *string `json:"status,omitempty"` + TotalUtilization *float64 `json:"totalUtilization,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_criticaljobhistorydetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_criticaljobhistorydetails.go new file mode 100644 index 00000000000..cbaf060f779 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_criticaljobhistorydetails.go @@ -0,0 +1,29 @@ +package replicationmigrationitems + +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 CriticalJobHistoryDetails struct { + JobId *string `json:"jobId,omitempty"` + JobName *string `json:"jobName,omitempty"` + JobStatus *string `json:"jobStatus,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *CriticalJobHistoryDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CriticalJobHistoryDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_currentjobdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_currentjobdetails.go new file mode 100644 index 00000000000..6461ea7fe4f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_currentjobdetails.go @@ -0,0 +1,28 @@ +package replicationmigrationitems + +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 CurrentJobDetails struct { + JobId *string `json:"jobId,omitempty"` + JobName *string `json:"jobName,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *CurrentJobDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CurrentJobDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_datastoreutilizationdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_datastoreutilizationdetails.go new file mode 100644 index 00000000000..21df088d5b6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_datastoreutilizationdetails.go @@ -0,0 +1,10 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataStoreUtilizationDetails struct { + DataStoreName *string `json:"dataStoreName,omitempty"` + TotalSnapshotsCreated *int64 `json:"totalSnapshotsCreated,omitempty"` + TotalSnapshotsSupported *int64 `json:"totalSnapshotsSupported,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_enablemigrationinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_enablemigrationinput.go new file mode 100644 index 00000000000..eeb46d6566e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_enablemigrationinput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnableMigrationInput struct { + Properties EnableMigrationInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_enablemigrationinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_enablemigrationinputproperties.go new file mode 100644 index 00000000000..a52385b5bb0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_enablemigrationinputproperties.go @@ -0,0 +1,42 @@ +package replicationmigrationitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnableMigrationInputProperties struct { + PolicyId string `json:"policyId"` + ProviderSpecificDetails EnableMigrationProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &EnableMigrationInputProperties{} + +func (s *EnableMigrationInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + PolicyId string `json:"policyId"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.PolicyId = decoded.PolicyId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling EnableMigrationInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalEnableMigrationProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'EnableMigrationInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_enablemigrationproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_enablemigrationproviderspecificinput.go new file mode 100644 index 00000000000..9c4382643eb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_enablemigrationproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +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 EnableMigrationProviderSpecificInput interface { + EnableMigrationProviderSpecificInput() BaseEnableMigrationProviderSpecificInputImpl +} + +var _ EnableMigrationProviderSpecificInput = BaseEnableMigrationProviderSpecificInputImpl{} + +type BaseEnableMigrationProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseEnableMigrationProviderSpecificInputImpl) EnableMigrationProviderSpecificInput() BaseEnableMigrationProviderSpecificInputImpl { + return s +} + +var _ EnableMigrationProviderSpecificInput = RawEnableMigrationProviderSpecificInputImpl{} + +// RawEnableMigrationProviderSpecificInputImpl 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 RawEnableMigrationProviderSpecificInputImpl struct { + enableMigrationProviderSpecificInput BaseEnableMigrationProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawEnableMigrationProviderSpecificInputImpl) EnableMigrationProviderSpecificInput() BaseEnableMigrationProviderSpecificInputImpl { + return s.enableMigrationProviderSpecificInput +} + +func UnmarshalEnableMigrationProviderSpecificInputImplementation(input []byte) (EnableMigrationProviderSpecificInput, 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 EnableMigrationProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtEnableMigrationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtEnableMigrationInput: %+v", err) + } + return out, nil + } + + var parent BaseEnableMigrationProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseEnableMigrationProviderSpecificInputImpl: %+v", err) + } + + return RawEnableMigrationProviderSpecificInputImpl{ + enableMigrationProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_gatewayoperationdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_gatewayoperationdetails.go new file mode 100644 index 00000000000..b0cbbc52f12 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_gatewayoperationdetails.go @@ -0,0 +1,15 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayOperationDetails struct { + DataStores *[]string `json:"dataStores,omitempty"` + HostName *string `json:"hostName,omitempty"` + ProgressPercentage *int64 `json:"progressPercentage,omitempty"` + State *string `json:"state,omitempty"` + TimeElapsed *int64 `json:"timeElapsed,omitempty"` + TimeRemaining *int64 `json:"timeRemaining,omitempty"` + UploadSpeed *int64 `json:"uploadSpeed,omitempty"` + VMwareReadThroughput *int64 `json:"vmwareReadThroughput,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_healtherror.go new file mode 100644 index 00000000000..bd011f2be40 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationmigrationitems + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_innerhealtherror.go new file mode 100644 index 00000000000..57850e37e2e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationmigrationitems + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_managedruncommandscriptinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_managedruncommandscriptinput.go new file mode 100644 index 00000000000..5ee3b09a915 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_managedruncommandscriptinput.go @@ -0,0 +1,10 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedRunCommandScriptInput struct { + ScriptParameters string `json:"scriptParameters"` + ScriptURL string `json:"scriptUrl"` + StepName string `json:"stepName"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_migrateinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_migrateinput.go new file mode 100644 index 00000000000..64530958cea --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_migrateinput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateInput struct { + Properties MigrateInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_migrateinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_migrateinputproperties.go new file mode 100644 index 00000000000..ed4cee89e09 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_migrateinputproperties.go @@ -0,0 +1,33 @@ +package replicationmigrationitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateInputProperties struct { + ProviderSpecificDetails MigrateProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &MigrateInputProperties{} + +func (s *MigrateInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling MigrateInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalMigrateProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'MigrateInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_migrateproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_migrateproviderspecificinput.go new file mode 100644 index 00000000000..59eb089d150 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_migrateproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +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 MigrateProviderSpecificInput interface { + MigrateProviderSpecificInput() BaseMigrateProviderSpecificInputImpl +} + +var _ MigrateProviderSpecificInput = BaseMigrateProviderSpecificInputImpl{} + +type BaseMigrateProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseMigrateProviderSpecificInputImpl) MigrateProviderSpecificInput() BaseMigrateProviderSpecificInputImpl { + return s +} + +var _ MigrateProviderSpecificInput = RawMigrateProviderSpecificInputImpl{} + +// RawMigrateProviderSpecificInputImpl 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 RawMigrateProviderSpecificInputImpl struct { + migrateProviderSpecificInput BaseMigrateProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawMigrateProviderSpecificInputImpl) MigrateProviderSpecificInput() BaseMigrateProviderSpecificInputImpl { + return s.migrateProviderSpecificInput +} + +func UnmarshalMigrateProviderSpecificInputImplementation(input []byte) (MigrateProviderSpecificInput, 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 MigrateProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtMigrateInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtMigrateInput: %+v", err) + } + return out, nil + } + + var parent BaseMigrateProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseMigrateProviderSpecificInputImpl: %+v", err) + } + + return RawMigrateProviderSpecificInputImpl{ + migrateProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_migrationitem.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_migrationitem.go new file mode 100644 index 00000000000..42cd0fcb04e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_migrationitem.go @@ -0,0 +1,12 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationItem struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MigrationItemProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_migrationitemproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_migrationitemproperties.go new file mode 100644 index 00000000000..1061b0ce570 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_migrationitemproperties.go @@ -0,0 +1,123 @@ +package replicationmigrationitems + +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. + +type MigrationItemProperties struct { + AllowedOperations *[]MigrationItemOperation `json:"allowedOperations,omitempty"` + CriticalJobHistory *[]CriticalJobHistoryDetails `json:"criticalJobHistory,omitempty"` + CurrentJob *CurrentJobDetails `json:"currentJob,omitempty"` + EventCorrelationId *string `json:"eventCorrelationId,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + LastMigrationStatus *string `json:"lastMigrationStatus,omitempty"` + LastMigrationTime *string `json:"lastMigrationTime,omitempty"` + LastTestMigrationStatus *string `json:"lastTestMigrationStatus,omitempty"` + LastTestMigrationTime *string `json:"lastTestMigrationTime,omitempty"` + MachineName *string `json:"machineName,omitempty"` + MigrationState *MigrationState `json:"migrationState,omitempty"` + MigrationStateDescription *string `json:"migrationStateDescription,omitempty"` + PolicyFriendlyName *string `json:"policyFriendlyName,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProviderSpecificDetails MigrationProviderSpecificSettings `json:"providerSpecificDetails"` + RecoveryServicesProviderId *string `json:"recoveryServicesProviderId,omitempty"` + ReplicationStatus *string `json:"replicationStatus,omitempty"` + TestMigrateState *TestMigrationState `json:"testMigrateState,omitempty"` + TestMigrateStateDescription *string `json:"testMigrateStateDescription,omitempty"` +} + +func (o *MigrationItemProperties) GetLastMigrationTimeAsTime() (*time.Time, error) { + if o.LastMigrationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastMigrationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MigrationItemProperties) SetLastMigrationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastMigrationTime = &formatted +} + +func (o *MigrationItemProperties) GetLastTestMigrationTimeAsTime() (*time.Time, error) { + if o.LastTestMigrationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastTestMigrationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MigrationItemProperties) SetLastTestMigrationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastTestMigrationTime = &formatted +} + +var _ json.Unmarshaler = &MigrationItemProperties{} + +func (s *MigrationItemProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AllowedOperations *[]MigrationItemOperation `json:"allowedOperations,omitempty"` + CriticalJobHistory *[]CriticalJobHistoryDetails `json:"criticalJobHistory,omitempty"` + CurrentJob *CurrentJobDetails `json:"currentJob,omitempty"` + EventCorrelationId *string `json:"eventCorrelationId,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + LastMigrationStatus *string `json:"lastMigrationStatus,omitempty"` + LastMigrationTime *string `json:"lastMigrationTime,omitempty"` + LastTestMigrationStatus *string `json:"lastTestMigrationStatus,omitempty"` + LastTestMigrationTime *string `json:"lastTestMigrationTime,omitempty"` + MachineName *string `json:"machineName,omitempty"` + MigrationState *MigrationState `json:"migrationState,omitempty"` + MigrationStateDescription *string `json:"migrationStateDescription,omitempty"` + PolicyFriendlyName *string `json:"policyFriendlyName,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + RecoveryServicesProviderId *string `json:"recoveryServicesProviderId,omitempty"` + ReplicationStatus *string `json:"replicationStatus,omitempty"` + TestMigrateState *TestMigrationState `json:"testMigrateState,omitempty"` + TestMigrateStateDescription *string `json:"testMigrateStateDescription,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AllowedOperations = decoded.AllowedOperations + s.CriticalJobHistory = decoded.CriticalJobHistory + s.CurrentJob = decoded.CurrentJob + s.EventCorrelationId = decoded.EventCorrelationId + s.Health = decoded.Health + s.HealthErrors = decoded.HealthErrors + s.LastMigrationStatus = decoded.LastMigrationStatus + s.LastMigrationTime = decoded.LastMigrationTime + s.LastTestMigrationStatus = decoded.LastTestMigrationStatus + s.LastTestMigrationTime = decoded.LastTestMigrationTime + s.MachineName = decoded.MachineName + s.MigrationState = decoded.MigrationState + s.MigrationStateDescription = decoded.MigrationStateDescription + s.PolicyFriendlyName = decoded.PolicyFriendlyName + s.PolicyId = decoded.PolicyId + s.RecoveryServicesProviderId = decoded.RecoveryServicesProviderId + s.ReplicationStatus = decoded.ReplicationStatus + s.TestMigrateState = decoded.TestMigrateState + s.TestMigrateStateDescription = decoded.TestMigrateStateDescription + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling MigrationItemProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalMigrationProviderSpecificSettingsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'MigrationItemProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_migrationproviderspecificsettings.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_migrationproviderspecificsettings.go new file mode 100644 index 00000000000..c9522606209 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_migrationproviderspecificsettings.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +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 MigrationProviderSpecificSettings interface { + MigrationProviderSpecificSettings() BaseMigrationProviderSpecificSettingsImpl +} + +var _ MigrationProviderSpecificSettings = BaseMigrationProviderSpecificSettingsImpl{} + +type BaseMigrationProviderSpecificSettingsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseMigrationProviderSpecificSettingsImpl) MigrationProviderSpecificSettings() BaseMigrationProviderSpecificSettingsImpl { + return s +} + +var _ MigrationProviderSpecificSettings = RawMigrationProviderSpecificSettingsImpl{} + +// RawMigrationProviderSpecificSettingsImpl 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 RawMigrationProviderSpecificSettingsImpl struct { + migrationProviderSpecificSettings BaseMigrationProviderSpecificSettingsImpl + Type string + Values map[string]interface{} +} + +func (s RawMigrationProviderSpecificSettingsImpl) MigrationProviderSpecificSettings() BaseMigrationProviderSpecificSettingsImpl { + return s.migrationProviderSpecificSettings +} + +func UnmarshalMigrationProviderSpecificSettingsImplementation(input []byte) (MigrationProviderSpecificSettings, 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 MigrationProviderSpecificSettings into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtMigrationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtMigrationDetails: %+v", err) + } + return out, nil + } + + var parent BaseMigrationProviderSpecificSettingsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseMigrationProviderSpecificSettingsImpl: %+v", err) + } + + return RawMigrationProviderSpecificSettingsImpl{ + migrationProviderSpecificSettings: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_pausereplicationinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_pausereplicationinput.go new file mode 100644 index 00000000000..9e6108005ed --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_pausereplicationinput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PauseReplicationInput struct { + Properties PauseReplicationInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_pausereplicationinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_pausereplicationinputproperties.go new file mode 100644 index 00000000000..67b7a7a192c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_pausereplicationinputproperties.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PauseReplicationInputProperties struct { + InstanceType string `json:"instanceType"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_resumereplicationinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_resumereplicationinput.go new file mode 100644 index 00000000000..fb4429f5eac --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_resumereplicationinput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResumeReplicationInput struct { + Properties ResumeReplicationInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_resumereplicationinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_resumereplicationinputproperties.go new file mode 100644 index 00000000000..574d307db8b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_resumereplicationinputproperties.go @@ -0,0 +1,33 @@ +package replicationmigrationitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResumeReplicationInputProperties struct { + ProviderSpecificDetails ResumeReplicationProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &ResumeReplicationInputProperties{} + +func (s *ResumeReplicationInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ResumeReplicationInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalResumeReplicationProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ResumeReplicationInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_resumereplicationproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_resumereplicationproviderspecificinput.go new file mode 100644 index 00000000000..9a687d6318d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_resumereplicationproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +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 ResumeReplicationProviderSpecificInput interface { + ResumeReplicationProviderSpecificInput() BaseResumeReplicationProviderSpecificInputImpl +} + +var _ ResumeReplicationProviderSpecificInput = BaseResumeReplicationProviderSpecificInputImpl{} + +type BaseResumeReplicationProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseResumeReplicationProviderSpecificInputImpl) ResumeReplicationProviderSpecificInput() BaseResumeReplicationProviderSpecificInputImpl { + return s +} + +var _ ResumeReplicationProviderSpecificInput = RawResumeReplicationProviderSpecificInputImpl{} + +// RawResumeReplicationProviderSpecificInputImpl 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 RawResumeReplicationProviderSpecificInputImpl struct { + resumeReplicationProviderSpecificInput BaseResumeReplicationProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawResumeReplicationProviderSpecificInputImpl) ResumeReplicationProviderSpecificInput() BaseResumeReplicationProviderSpecificInputImpl { + return s.resumeReplicationProviderSpecificInput +} + +func UnmarshalResumeReplicationProviderSpecificInputImplementation(input []byte) (ResumeReplicationProviderSpecificInput, 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 ResumeReplicationProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtResumeReplicationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtResumeReplicationInput: %+v", err) + } + return out, nil + } + + var parent BaseResumeReplicationProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseResumeReplicationProviderSpecificInputImpl: %+v", err) + } + + return RawResumeReplicationProviderSpecificInputImpl{ + resumeReplicationProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_resyncinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_resyncinput.go new file mode 100644 index 00000000000..e680c11686e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_resyncinput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResyncInput struct { + Properties ResyncInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_resyncinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_resyncinputproperties.go new file mode 100644 index 00000000000..dc2d7fd7889 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_resyncinputproperties.go @@ -0,0 +1,33 @@ +package replicationmigrationitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResyncInputProperties struct { + ProviderSpecificDetails ResyncProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &ResyncInputProperties{} + +func (s *ResyncInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ResyncInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalResyncProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ResyncInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_resyncproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_resyncproviderspecificinput.go new file mode 100644 index 00000000000..55138df4165 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_resyncproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +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 ResyncProviderSpecificInput interface { + ResyncProviderSpecificInput() BaseResyncProviderSpecificInputImpl +} + +var _ ResyncProviderSpecificInput = BaseResyncProviderSpecificInputImpl{} + +type BaseResyncProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseResyncProviderSpecificInputImpl) ResyncProviderSpecificInput() BaseResyncProviderSpecificInputImpl { + return s +} + +var _ ResyncProviderSpecificInput = RawResyncProviderSpecificInputImpl{} + +// RawResyncProviderSpecificInputImpl 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 RawResyncProviderSpecificInputImpl struct { + resyncProviderSpecificInput BaseResyncProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawResyncProviderSpecificInputImpl) ResyncProviderSpecificInput() BaseResyncProviderSpecificInputImpl { + return s.resyncProviderSpecificInput +} + +func UnmarshalResyncProviderSpecificInputImplementation(input []byte) (ResyncProviderSpecificInput, 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 ResyncProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtResyncInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtResyncInput: %+v", err) + } + return out, nil + } + + var parent BaseResyncProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseResyncProviderSpecificInputImpl: %+v", err) + } + + return RawResyncProviderSpecificInputImpl{ + resyncProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_testmigratecleanupinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_testmigratecleanupinput.go new file mode 100644 index 00000000000..15890ac313a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_testmigratecleanupinput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestMigrateCleanupInput struct { + Properties TestMigrateCleanupInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_testmigratecleanupinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_testmigratecleanupinputproperties.go new file mode 100644 index 00000000000..a7ac0568f76 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_testmigratecleanupinputproperties.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestMigrateCleanupInputProperties struct { + Comments *string `json:"comments,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_testmigrateinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_testmigrateinput.go new file mode 100644 index 00000000000..cc8da4dbada --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_testmigrateinput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestMigrateInput struct { + Properties TestMigrateInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_testmigrateinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_testmigrateinputproperties.go new file mode 100644 index 00000000000..dea41ea3bdd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_testmigrateinputproperties.go @@ -0,0 +1,33 @@ +package replicationmigrationitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestMigrateInputProperties struct { + ProviderSpecificDetails TestMigrateProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &TestMigrateInputProperties{} + +func (s *TestMigrateInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling TestMigrateInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalTestMigrateProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'TestMigrateInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_testmigrateproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_testmigrateproviderspecificinput.go new file mode 100644 index 00000000000..d1ce68e9003 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_testmigrateproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +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 TestMigrateProviderSpecificInput interface { + TestMigrateProviderSpecificInput() BaseTestMigrateProviderSpecificInputImpl +} + +var _ TestMigrateProviderSpecificInput = BaseTestMigrateProviderSpecificInputImpl{} + +type BaseTestMigrateProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseTestMigrateProviderSpecificInputImpl) TestMigrateProviderSpecificInput() BaseTestMigrateProviderSpecificInputImpl { + return s +} + +var _ TestMigrateProviderSpecificInput = RawTestMigrateProviderSpecificInputImpl{} + +// RawTestMigrateProviderSpecificInputImpl 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 RawTestMigrateProviderSpecificInputImpl struct { + testMigrateProviderSpecificInput BaseTestMigrateProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawTestMigrateProviderSpecificInputImpl) TestMigrateProviderSpecificInput() BaseTestMigrateProviderSpecificInputImpl { + return s.testMigrateProviderSpecificInput +} + +func UnmarshalTestMigrateProviderSpecificInputImplementation(input []byte) (TestMigrateProviderSpecificInput, 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 TestMigrateProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtTestMigrateInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtTestMigrateInput: %+v", err) + } + return out, nil + } + + var parent BaseTestMigrateProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseTestMigrateProviderSpecificInputImpl: %+v", err) + } + + return RawTestMigrateProviderSpecificInputImpl{ + testMigrateProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_updatemigrationiteminput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_updatemigrationiteminput.go new file mode 100644 index 00000000000..3a41aab1339 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_updatemigrationiteminput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateMigrationItemInput struct { + Properties *UpdateMigrationItemInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_updatemigrationiteminputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_updatemigrationiteminputproperties.go new file mode 100644 index 00000000000..8d9d71c1ca7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_updatemigrationiteminputproperties.go @@ -0,0 +1,33 @@ +package replicationmigrationitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateMigrationItemInputProperties struct { + ProviderSpecificDetails UpdateMigrationItemProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &UpdateMigrationItemInputProperties{} + +func (s *UpdateMigrationItemInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling UpdateMigrationItemInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalUpdateMigrationItemProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'UpdateMigrationItemInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_updatemigrationitemproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_updatemigrationitemproviderspecificinput.go new file mode 100644 index 00000000000..a05c70810cc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_updatemigrationitemproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +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 UpdateMigrationItemProviderSpecificInput interface { + UpdateMigrationItemProviderSpecificInput() BaseUpdateMigrationItemProviderSpecificInputImpl +} + +var _ UpdateMigrationItemProviderSpecificInput = BaseUpdateMigrationItemProviderSpecificInputImpl{} + +type BaseUpdateMigrationItemProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseUpdateMigrationItemProviderSpecificInputImpl) UpdateMigrationItemProviderSpecificInput() BaseUpdateMigrationItemProviderSpecificInputImpl { + return s +} + +var _ UpdateMigrationItemProviderSpecificInput = RawUpdateMigrationItemProviderSpecificInputImpl{} + +// RawUpdateMigrationItemProviderSpecificInputImpl 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 RawUpdateMigrationItemProviderSpecificInputImpl struct { + updateMigrationItemProviderSpecificInput BaseUpdateMigrationItemProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawUpdateMigrationItemProviderSpecificInputImpl) UpdateMigrationItemProviderSpecificInput() BaseUpdateMigrationItemProviderSpecificInputImpl { + return s.updateMigrationItemProviderSpecificInput +} + +func UnmarshalUpdateMigrationItemProviderSpecificInputImplementation(input []byte) (UpdateMigrationItemProviderSpecificInput, 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 UpdateMigrationItemProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtUpdateMigrationItemInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtUpdateMigrationItemInput: %+v", err) + } + return out, nil + } + + var parent BaseUpdateMigrationItemProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseUpdateMigrationItemProviderSpecificInputImpl: %+v", err) + } + + return RawUpdateMigrationItemProviderSpecificInputImpl{ + updateMigrationItemProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtdiskinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtdiskinput.go new file mode 100644 index 00000000000..5ce6c03c0a0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtdiskinput.go @@ -0,0 +1,14 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMwareCbtDiskInput struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId string `json:"diskId"` + DiskType *DiskAccountType `json:"diskType,omitempty"` + IsOSDisk string `json:"isOSDisk"` + LogStorageAccountId string `json:"logStorageAccountId"` + LogStorageAccountSasSecretName string `json:"logStorageAccountSasSecretName"` + SectorSizeInBytes *int64 `json:"sectorSizeInBytes,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtenablemigrationinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtenablemigrationinput.go new file mode 100644 index 00000000000..312133d3257 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtenablemigrationinput.go @@ -0,0 +1,76 @@ +package replicationmigrationitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EnableMigrationProviderSpecificInput = VMwareCbtEnableMigrationInput{} + +type VMwareCbtEnableMigrationInput struct { + ConfidentialVMKeyVaultId *string `json:"confidentialVmKeyVaultId,omitempty"` + DataMoverRunAsAccountId string `json:"dataMoverRunAsAccountId"` + DisksToInclude []VMwareCbtDiskInput `json:"disksToInclude"` + LicenseType *LicenseType `json:"licenseType,omitempty"` + LinuxLicenseType *LinuxLicenseType `json:"linuxLicenseType,omitempty"` + PerformAutoResync *string `json:"performAutoResync,omitempty"` + PerformSqlBulkRegistration *string `json:"performSqlBulkRegistration,omitempty"` + SeedDiskTags *map[string]string `json:"seedDiskTags,omitempty"` + SnapshotRunAsAccountId string `json:"snapshotRunAsAccountId"` + SqlServerLicenseType *SqlServerLicenseType `json:"sqlServerLicenseType,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetBootDiagnosticsStorageAccountId *string `json:"targetBootDiagnosticsStorageAccountId,omitempty"` + TargetDiskTags *map[string]string `json:"targetDiskTags,omitempty"` + TargetNetworkId string `json:"targetNetworkId"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetResourceGroupId string `json:"targetResourceGroupId"` + TargetSubnetName *string `json:"targetSubnetName,omitempty"` + TargetVMName *string `json:"targetVmName,omitempty"` + TargetVMSecurityProfile *VMwareCbtSecurityProfileProperties `json:"targetVmSecurityProfile,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + TestNetworkId *string `json:"testNetworkId,omitempty"` + TestSubnetName *string `json:"testSubnetName,omitempty"` + UserSelectedOSName *string `json:"userSelectedOSName,omitempty"` + VMwareMachineId string `json:"vmwareMachineId"` + + // Fields inherited from EnableMigrationProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtEnableMigrationInput) EnableMigrationProviderSpecificInput() BaseEnableMigrationProviderSpecificInputImpl { + return BaseEnableMigrationProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtEnableMigrationInput{} + +func (s VMwareCbtEnableMigrationInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtEnableMigrationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtEnableMigrationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtEnableMigrationInput: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtEnableMigrationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtmigrateinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtmigrateinput.go new file mode 100644 index 00000000000..5c7c3385146 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtmigrateinput.go @@ -0,0 +1,52 @@ +package replicationmigrationitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ MigrateProviderSpecificInput = VMwareCbtMigrateInput{} + +type VMwareCbtMigrateInput struct { + OsUpgradeVersion *string `json:"osUpgradeVersion,omitempty"` + PerformShutdown string `json:"performShutdown"` + PostMigrationSteps *[]ManagedRunCommandScriptInput `json:"postMigrationSteps,omitempty"` + + // Fields inherited from MigrateProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtMigrateInput) MigrateProviderSpecificInput() BaseMigrateProviderSpecificInputImpl { + return BaseMigrateProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtMigrateInput{} + +func (s VMwareCbtMigrateInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtMigrateInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtMigrateInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtMigrateInput: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtMigrateInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtmigrationdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtmigrationdetails.go new file mode 100644 index 00000000000..5e53a8342bc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtmigrationdetails.go @@ -0,0 +1,98 @@ +package replicationmigrationitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ MigrationProviderSpecificSettings = VMwareCbtMigrationDetails{} + +type VMwareCbtMigrationDetails struct { + ApplianceMonitoringDetails *ApplianceMonitoringDetails `json:"applianceMonitoringDetails,omitempty"` + ConfidentialVMKeyVaultId *string `json:"confidentialVmKeyVaultId,omitempty"` + DataMoverRunAsAccountId *string `json:"dataMoverRunAsAccountId,omitempty"` + DeltaSyncProgressPercentage *int64 `json:"deltaSyncProgressPercentage,omitempty"` + DeltaSyncRetryCount *int64 `json:"deltaSyncRetryCount,omitempty"` + FirmwareType *string `json:"firmwareType,omitempty"` + GatewayOperationDetails *GatewayOperationDetails `json:"gatewayOperationDetails,omitempty"` + InitialSeedingProgressPercentage *int64 `json:"initialSeedingProgressPercentage,omitempty"` + InitialSeedingRetryCount *int64 `json:"initialSeedingRetryCount,omitempty"` + IsCheckSumResyncCycle *string `json:"isCheckSumResyncCycle,omitempty"` + LastRecoveryPointId *string `json:"lastRecoveryPointId,omitempty"` + LastRecoveryPointReceived *string `json:"lastRecoveryPointReceived,omitempty"` + LicenseType *string `json:"licenseType,omitempty"` + LinuxLicenseType *LinuxLicenseType `json:"linuxLicenseType,omitempty"` + MigrationProgressPercentage *int64 `json:"migrationProgressPercentage,omitempty"` + MigrationRecoveryPointId *string `json:"migrationRecoveryPointId,omitempty"` + OperationName *string `json:"operationName,omitempty"` + OsName *string `json:"osName,omitempty"` + OsType *string `json:"osType,omitempty"` + PerformAutoResync *string `json:"performAutoResync,omitempty"` + ProtectedDisks *[]VMwareCbtProtectedDiskDetails `json:"protectedDisks,omitempty"` + ResumeProgressPercentage *int64 `json:"resumeProgressPercentage,omitempty"` + ResumeRetryCount *int64 `json:"resumeRetryCount,omitempty"` + ResyncProgressPercentage *int64 `json:"resyncProgressPercentage,omitempty"` + ResyncRequired *string `json:"resyncRequired,omitempty"` + ResyncRetryCount *int64 `json:"resyncRetryCount,omitempty"` + ResyncState *ResyncState `json:"resyncState,omitempty"` + SeedDiskTags *map[string]string `json:"seedDiskTags,omitempty"` + SnapshotRunAsAccountId *string `json:"snapshotRunAsAccountId,omitempty"` + SqlServerLicenseType *string `json:"sqlServerLicenseType,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + SupportedOSVersions *[]string `json:"supportedOSVersions,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetBootDiagnosticsStorageAccountId *string `json:"targetBootDiagnosticsStorageAccountId,omitempty"` + TargetDiskTags *map[string]string `json:"targetDiskTags,omitempty"` + TargetGeneration *string `json:"targetGeneration,omitempty"` + TargetLocation *string `json:"targetLocation,omitempty"` + TargetNetworkId *string `json:"targetNetworkId,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVMName *string `json:"targetVmName,omitempty"` + TargetVMSecurityProfile *VMwareCbtSecurityProfileProperties `json:"targetVmSecurityProfile,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + TestNetworkId *string `json:"testNetworkId,omitempty"` + VMNics *[]VMwareCbtNicDetails `json:"vmNics,omitempty"` + VMwareMachineId *string `json:"vmwareMachineId,omitempty"` + + // Fields inherited from MigrationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtMigrationDetails) MigrationProviderSpecificSettings() BaseMigrationProviderSpecificSettingsImpl { + return BaseMigrationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtMigrationDetails{} + +func (s VMwareCbtMigrationDetails) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtMigrationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtMigrationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtMigrationDetails: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtMigrationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtnicdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtnicdetails.go new file mode 100644 index 00000000000..068195a186f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtnicdetails.go @@ -0,0 +1,21 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMwareCbtNicDetails struct { + IsPrimaryNic *string `json:"isPrimaryNic,omitempty"` + IsSelectedForMigration *string `json:"isSelectedForMigration,omitempty"` + NicId *string `json:"nicId,omitempty"` + SourceIPAddress *string `json:"sourceIPAddress,omitempty"` + SourceIPAddressType *EthernetAddressType `json:"sourceIPAddressType,omitempty"` + SourceNetworkId *string `json:"sourceNetworkId,omitempty"` + TargetIPAddress *string `json:"targetIPAddress,omitempty"` + TargetIPAddressType *EthernetAddressType `json:"targetIPAddressType,omitempty"` + TargetNicName *string `json:"targetNicName,omitempty"` + TargetSubnetName *string `json:"targetSubnetName,omitempty"` + TestIPAddress *string `json:"testIPAddress,omitempty"` + TestIPAddressType *EthernetAddressType `json:"testIPAddressType,omitempty"` + TestNetworkId *string `json:"testNetworkId,omitempty"` + TestSubnetName *string `json:"testSubnetName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtnicinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtnicinput.go new file mode 100644 index 00000000000..43ec27bd70b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtnicinput.go @@ -0,0 +1,15 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMwareCbtNicInput struct { + IsPrimaryNic string `json:"isPrimaryNic"` + IsSelectedForMigration *string `json:"isSelectedForMigration,omitempty"` + NicId string `json:"nicId"` + TargetNicName *string `json:"targetNicName,omitempty"` + TargetStaticIPAddress *string `json:"targetStaticIPAddress,omitempty"` + TargetSubnetName *string `json:"targetSubnetName,omitempty"` + TestStaticIPAddress *string `json:"testStaticIPAddress,omitempty"` + TestSubnetName *string `json:"testSubnetName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtprotecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtprotecteddiskdetails.go new file mode 100644 index 00000000000..0aeaee3a0ff --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtprotecteddiskdetails.go @@ -0,0 +1,23 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMwareCbtProtectedDiskDetails struct { + CapacityInBytes *int64 `json:"capacityInBytes,omitempty"` + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskPath *string `json:"diskPath,omitempty"` + DiskType *DiskAccountType `json:"diskType,omitempty"` + GatewayOperationDetails *GatewayOperationDetails `json:"gatewayOperationDetails,omitempty"` + IsOSDisk *string `json:"isOSDisk,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` + LogStorageAccountSasSecretName *string `json:"logStorageAccountSasSecretName,omitempty"` + SectorSizeInBytes *int64 `json:"sectorSizeInBytes,omitempty"` + SeedBlobUri *string `json:"seedBlobUri,omitempty"` + SeedManagedDiskId *string `json:"seedManagedDiskId,omitempty"` + TargetBlobUri *string `json:"targetBlobUri,omitempty"` + TargetDiskName *string `json:"targetDiskName,omitempty"` + TargetManagedDiskId *string `json:"targetManagedDiskId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtresumereplicationinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtresumereplicationinput.go new file mode 100644 index 00000000000..1c6cf9977e7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtresumereplicationinput.go @@ -0,0 +1,50 @@ +package replicationmigrationitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ResumeReplicationProviderSpecificInput = VMwareCbtResumeReplicationInput{} + +type VMwareCbtResumeReplicationInput struct { + DeleteMigrationResources *string `json:"deleteMigrationResources,omitempty"` + + // Fields inherited from ResumeReplicationProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtResumeReplicationInput) ResumeReplicationProviderSpecificInput() BaseResumeReplicationProviderSpecificInputImpl { + return BaseResumeReplicationProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtResumeReplicationInput{} + +func (s VMwareCbtResumeReplicationInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtResumeReplicationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtResumeReplicationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtResumeReplicationInput: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtResumeReplicationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtresyncinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtresyncinput.go new file mode 100644 index 00000000000..f5b5c166ad1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtresyncinput.go @@ -0,0 +1,50 @@ +package replicationmigrationitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ResyncProviderSpecificInput = VMwareCbtResyncInput{} + +type VMwareCbtResyncInput struct { + SkipCbtReset string `json:"skipCbtReset"` + + // Fields inherited from ResyncProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtResyncInput) ResyncProviderSpecificInput() BaseResyncProviderSpecificInputImpl { + return BaseResyncProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtResyncInput{} + +func (s VMwareCbtResyncInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtResyncInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtResyncInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtResyncInput: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtResyncInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtsecurityprofileproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtsecurityprofileproperties.go new file mode 100644 index 00000000000..8bca1ef02df --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtsecurityprofileproperties.go @@ -0,0 +1,12 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMwareCbtSecurityProfileProperties struct { + IsTargetVMConfidentialEncryptionEnabled *string `json:"isTargetVmConfidentialEncryptionEnabled,omitempty"` + IsTargetVMIntegrityMonitoringEnabled *string `json:"isTargetVmIntegrityMonitoringEnabled,omitempty"` + IsTargetVMSecureBootEnabled *string `json:"isTargetVmSecureBootEnabled,omitempty"` + IsTargetVMTpmEnabled *string `json:"isTargetVmTpmEnabled,omitempty"` + TargetVMSecurityType *SecurityType `json:"targetVmSecurityType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbttestmigrateinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbttestmigrateinput.go new file mode 100644 index 00000000000..0ec2adcc035 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbttestmigrateinput.go @@ -0,0 +1,54 @@ +package replicationmigrationitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TestMigrateProviderSpecificInput = VMwareCbtTestMigrateInput{} + +type VMwareCbtTestMigrateInput struct { + NetworkId string `json:"networkId"` + OsUpgradeVersion *string `json:"osUpgradeVersion,omitempty"` + PostMigrationSteps *[]ManagedRunCommandScriptInput `json:"postMigrationSteps,omitempty"` + RecoveryPointId string `json:"recoveryPointId"` + VMNics *[]VMwareCbtNicInput `json:"vmNics,omitempty"` + + // Fields inherited from TestMigrateProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtTestMigrateInput) TestMigrateProviderSpecificInput() BaseTestMigrateProviderSpecificInputImpl { + return BaseTestMigrateProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtTestMigrateInput{} + +func (s VMwareCbtTestMigrateInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtTestMigrateInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtTestMigrateInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtTestMigrateInput: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtTestMigrateInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtupdatediskinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtupdatediskinput.go new file mode 100644 index 00000000000..54acf609e2b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtupdatediskinput.go @@ -0,0 +1,10 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMwareCbtUpdateDiskInput struct { + DiskId string `json:"diskId"` + IsOSDisk *string `json:"isOSDisk,omitempty"` + TargetDiskName *string `json:"targetDiskName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtupdatemigrationiteminput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtupdatemigrationiteminput.go new file mode 100644 index 00000000000..f018f6cf6f2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/model_vmwarecbtupdatemigrationiteminput.go @@ -0,0 +1,68 @@ +package replicationmigrationitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ UpdateMigrationItemProviderSpecificInput = VMwareCbtUpdateMigrationItemInput{} + +type VMwareCbtUpdateMigrationItemInput struct { + LicenseType *LicenseType `json:"licenseType,omitempty"` + LinuxLicenseType *LinuxLicenseType `json:"linuxLicenseType,omitempty"` + PerformAutoResync *string `json:"performAutoResync,omitempty"` + SqlServerLicenseType *SqlServerLicenseType `json:"sqlServerLicenseType,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetBootDiagnosticsStorageAccountId *string `json:"targetBootDiagnosticsStorageAccountId,omitempty"` + TargetDiskTags *map[string]string `json:"targetDiskTags,omitempty"` + TargetNetworkId *string `json:"targetNetworkId,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVMName *string `json:"targetVmName,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + TestNetworkId *string `json:"testNetworkId,omitempty"` + UserSelectedOSName *string `json:"userSelectedOSName,omitempty"` + VMDisks *[]VMwareCbtUpdateDiskInput `json:"vmDisks,omitempty"` + VMNics *[]VMwareCbtNicInput `json:"vmNics,omitempty"` + + // Fields inherited from UpdateMigrationItemProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtUpdateMigrationItemInput) UpdateMigrationItemProviderSpecificInput() BaseUpdateMigrationItemProviderSpecificInputImpl { + return BaseUpdateMigrationItemProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtUpdateMigrationItemInput{} + +func (s VMwareCbtUpdateMigrationItemInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtUpdateMigrationItemInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtUpdateMigrationItemInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtUpdateMigrationItemInput: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtUpdateMigrationItemInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/predicates.go new file mode 100644 index 00000000000..38625eaca48 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/predicates.go @@ -0,0 +1,32 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationItemOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p MigrationItemOperationPredicate) Matches(input MigrationItem) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/version.go new file mode 100644 index 00000000000..6774e1e9225 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationmigrationitems/version.go @@ -0,0 +1,10 @@ +package replicationmigrationitems + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationmigrationitems/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/README.md new file mode 100644 index 00000000000..a6581c5c2c8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/README.md @@ -0,0 +1,116 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings` Documentation + +The `replicationnetworkmappings` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings" +``` + + +### Client Initialization + +```go +client := replicationnetworkmappings.NewReplicationNetworkMappingsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationNetworkMappingsClient.Create` + +```go +ctx := context.TODO() +id := replicationnetworkmappings.NewReplicationNetworkMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName", "replicationNetworkMappingName") + +payload := replicationnetworkmappings.CreateNetworkMappingInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationNetworkMappingsClient.Delete` + +```go +ctx := context.TODO() +id := replicationnetworkmappings.NewReplicationNetworkMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName", "replicationNetworkMappingName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationNetworkMappingsClient.Get` + +```go +ctx := context.TODO() +id := replicationnetworkmappings.NewReplicationNetworkMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName", "replicationNetworkMappingName") + +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: `ReplicationNetworkMappingsClient.List` + +```go +ctx := context.TODO() +id := replicationnetworkmappings.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationNetworkMappingsClient.ListByReplicationNetworks` + +```go +ctx := context.TODO() +id := replicationnetworkmappings.NewReplicationNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName") + +// alternatively `client.ListByReplicationNetworks(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationNetworksComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationNetworkMappingsClient.Update` + +```go +ctx := context.TODO() +id := replicationnetworkmappings.NewReplicationNetworkMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName", "replicationNetworkMappingName") + +payload := replicationnetworkmappings.UpdateNetworkMappingInput{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/client.go new file mode 100644 index 00000000000..abd39f3fa7e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/client.go @@ -0,0 +1,26 @@ +package replicationnetworkmappings + +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 ReplicationNetworkMappingsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationNetworkMappingsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationNetworkMappingsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationnetworkmappings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationNetworkMappingsClient: %+v", err) + } + + return &ReplicationNetworkMappingsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/id_replicationnetwork.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/id_replicationnetwork.go new file mode 100644 index 00000000000..bc0a19b4b6e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/id_replicationnetwork.go @@ -0,0 +1,148 @@ +package replicationnetworkmappings + +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(&ReplicationNetworkId{}) +} + +var _ resourceids.ResourceId = &ReplicationNetworkId{} + +// ReplicationNetworkId is a struct representing the Resource ID for a Replication Network +type ReplicationNetworkId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationNetworkName string +} + +// NewReplicationNetworkID returns a new ReplicationNetworkId struct +func NewReplicationNetworkID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationNetworkName string) ReplicationNetworkId { + return ReplicationNetworkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationNetworkName: replicationNetworkName, + } +} + +// ParseReplicationNetworkID parses 'input' into a ReplicationNetworkId +func ParseReplicationNetworkID(input string) (*ReplicationNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationNetworkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationNetworkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationNetworkIDInsensitively parses 'input' case-insensitively into a ReplicationNetworkId +// note: this method should only be used for API response data and not user input +func ParseReplicationNetworkIDInsensitively(input string) (*ReplicationNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationNetworkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationNetworkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationNetworkId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationNetworkName, ok = input.Parsed["replicationNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationNetworkName", input) + } + + return nil +} + +// ValidateReplicationNetworkID checks that 'input' can be parsed as a Replication Network ID +func ValidateReplicationNetworkID(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 := ParseReplicationNetworkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Network ID +func (id ReplicationNetworkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationNetworks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationNetworkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Network ID +func (id ReplicationNetworkId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationNetworks", "replicationNetworks", "replicationNetworks"), + resourceids.UserSpecifiedSegment("replicationNetworkName", "replicationNetworkName"), + } +} + +// String returns a human-readable description of this Replication Network ID +func (id ReplicationNetworkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Network Name: %q", id.ReplicationNetworkName), + } + return fmt.Sprintf("Replication Network (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/id_replicationnetwork_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/id_replicationnetwork_test.go new file mode 100644 index 00000000000..82963269f22 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/id_replicationnetwork_test.go @@ -0,0 +1,372 @@ +package replicationnetworkmappings + +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 = &ReplicationNetworkId{} + +func TestNewReplicationNetworkID(t *testing.T) { + id := NewReplicationNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationNetworkName != "replicationNetworkName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationNetworkName'", id.ReplicationNetworkName, "replicationNetworkName") + } +} + +func TestFormatReplicationNetworkID(t *testing.T) { + actual := NewReplicationNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationNetworkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationNetworkId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName", + Expected: &ReplicationNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationNetworkName: "replicationNetworkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationNetworkID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationNetworkName != v.Expected.ReplicationNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkName", v.Expected.ReplicationNetworkName, actual.ReplicationNetworkName) + } + + } +} + +func TestParseReplicationNetworkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationNetworkId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnNeTwOrKs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName", + Expected: &ReplicationNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationNetworkName: "replicationNetworkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKnAmE", + Expected: &ReplicationNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationNetworkName: "rEpLiCaTiOnNeTwOrKnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationNetworkIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationNetworkName != v.Expected.ReplicationNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkName", v.Expected.ReplicationNetworkName, actual.ReplicationNetworkName) + } + + } +} + +func TestSegmentsForReplicationNetworkId(t *testing.T) { + segments := ReplicationNetworkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationNetworkId 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/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/id_replicationnetworkmapping.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/id_replicationnetworkmapping.go new file mode 100644 index 00000000000..f35ea2e5232 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/id_replicationnetworkmapping.go @@ -0,0 +1,157 @@ +package replicationnetworkmappings + +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(&ReplicationNetworkMappingId{}) +} + +var _ resourceids.ResourceId = &ReplicationNetworkMappingId{} + +// ReplicationNetworkMappingId is a struct representing the Resource ID for a Replication Network Mapping +type ReplicationNetworkMappingId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationNetworkName string + ReplicationNetworkMappingName string +} + +// NewReplicationNetworkMappingID returns a new ReplicationNetworkMappingId struct +func NewReplicationNetworkMappingID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationNetworkName string, replicationNetworkMappingName string) ReplicationNetworkMappingId { + return ReplicationNetworkMappingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationNetworkName: replicationNetworkName, + ReplicationNetworkMappingName: replicationNetworkMappingName, + } +} + +// ParseReplicationNetworkMappingID parses 'input' into a ReplicationNetworkMappingId +func ParseReplicationNetworkMappingID(input string) (*ReplicationNetworkMappingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationNetworkMappingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationNetworkMappingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationNetworkMappingIDInsensitively parses 'input' case-insensitively into a ReplicationNetworkMappingId +// note: this method should only be used for API response data and not user input +func ParseReplicationNetworkMappingIDInsensitively(input string) (*ReplicationNetworkMappingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationNetworkMappingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationNetworkMappingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationNetworkMappingId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationNetworkName, ok = input.Parsed["replicationNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationNetworkName", input) + } + + if id.ReplicationNetworkMappingName, ok = input.Parsed["replicationNetworkMappingName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationNetworkMappingName", input) + } + + return nil +} + +// ValidateReplicationNetworkMappingID checks that 'input' can be parsed as a Replication Network Mapping ID +func ValidateReplicationNetworkMappingID(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 := ParseReplicationNetworkMappingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Network Mapping ID +func (id ReplicationNetworkMappingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationNetworks/%s/replicationNetworkMappings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationNetworkName, id.ReplicationNetworkMappingName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Network Mapping ID +func (id ReplicationNetworkMappingId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationNetworks", "replicationNetworks", "replicationNetworks"), + resourceids.UserSpecifiedSegment("replicationNetworkName", "replicationNetworkName"), + resourceids.StaticSegment("staticReplicationNetworkMappings", "replicationNetworkMappings", "replicationNetworkMappings"), + resourceids.UserSpecifiedSegment("replicationNetworkMappingName", "replicationNetworkMappingName"), + } +} + +// String returns a human-readable description of this Replication Network Mapping ID +func (id ReplicationNetworkMappingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Network Name: %q", id.ReplicationNetworkName), + fmt.Sprintf("Replication Network Mapping Name: %q", id.ReplicationNetworkMappingName), + } + return fmt.Sprintf("Replication Network Mapping (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/id_replicationnetworkmapping_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/id_replicationnetworkmapping_test.go new file mode 100644 index 00000000000..1d386c1e039 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/id_replicationnetworkmapping_test.go @@ -0,0 +1,417 @@ +package replicationnetworkmappings + +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 = &ReplicationNetworkMappingId{} + +func TestNewReplicationNetworkMappingID(t *testing.T) { + id := NewReplicationNetworkMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName", "replicationNetworkMappingName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationNetworkName != "replicationNetworkName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationNetworkName'", id.ReplicationNetworkName, "replicationNetworkName") + } + + if id.ReplicationNetworkMappingName != "replicationNetworkMappingName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationNetworkMappingName'", id.ReplicationNetworkMappingName, "replicationNetworkMappingName") + } +} + +func TestFormatReplicationNetworkMappingID(t *testing.T) { + actual := NewReplicationNetworkMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName", "replicationNetworkMappingName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName/replicationNetworkMappings/replicationNetworkMappingName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationNetworkMappingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationNetworkMappingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName/replicationNetworkMappings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName/replicationNetworkMappings/replicationNetworkMappingName", + Expected: &ReplicationNetworkMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationNetworkName: "replicationNetworkName", + ReplicationNetworkMappingName: "replicationNetworkMappingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName/replicationNetworkMappings/replicationNetworkMappingName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationNetworkMappingID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationNetworkName != v.Expected.ReplicationNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkName", v.Expected.ReplicationNetworkName, actual.ReplicationNetworkName) + } + + if actual.ReplicationNetworkMappingName != v.Expected.ReplicationNetworkMappingName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkMappingName", v.Expected.ReplicationNetworkMappingName, actual.ReplicationNetworkMappingName) + } + + } +} + +func TestParseReplicationNetworkMappingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationNetworkMappingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnNeTwOrKs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName/replicationNetworkMappings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKnAmE/rEpLiCaTiOnNeTwOrKmApPiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName/replicationNetworkMappings/replicationNetworkMappingName", + Expected: &ReplicationNetworkMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationNetworkName: "replicationNetworkName", + ReplicationNetworkMappingName: "replicationNetworkMappingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName/replicationNetworkMappings/replicationNetworkMappingName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKnAmE/rEpLiCaTiOnNeTwOrKmApPiNgS/rEpLiCaTiOnNeTwOrKmApPiNgNaMe", + Expected: &ReplicationNetworkMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationNetworkName: "rEpLiCaTiOnNeTwOrKnAmE", + ReplicationNetworkMappingName: "rEpLiCaTiOnNeTwOrKmApPiNgNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKnAmE/rEpLiCaTiOnNeTwOrKmApPiNgS/rEpLiCaTiOnNeTwOrKmApPiNgNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationNetworkMappingIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationNetworkName != v.Expected.ReplicationNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkName", v.Expected.ReplicationNetworkName, actual.ReplicationNetworkName) + } + + if actual.ReplicationNetworkMappingName != v.Expected.ReplicationNetworkMappingName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkMappingName", v.Expected.ReplicationNetworkMappingName, actual.ReplicationNetworkMappingName) + } + + } +} + +func TestSegmentsForReplicationNetworkMappingId(t *testing.T) { + segments := ReplicationNetworkMappingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationNetworkMappingId 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/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/id_vault.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/id_vault.go new file mode 100644 index 00000000000..5cecc8e3e7f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/id_vault.go @@ -0,0 +1,130 @@ +package replicationnetworkmappings + +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(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(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 := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/id_vault_test.go new file mode 100644 index 00000000000..0403f3ac48e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationnetworkmappings + +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 = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId 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/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/method_create.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/method_create.go new file mode 100644 index 00000000000..a4d2be62b74 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/method_create.go @@ -0,0 +1,75 @@ +package replicationnetworkmappings + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NetworkMapping +} + +// Create ... +func (c ReplicationNetworkMappingsClient) Create(ctx context.Context, id ReplicationNetworkMappingId, input CreateNetworkMappingInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationNetworkMappingsClient) CreateThenPoll(ctx context.Context, id ReplicationNetworkMappingId, input CreateNetworkMappingInput) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/method_delete.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/method_delete.go new file mode 100644 index 00000000000..3adf449be4b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/method_delete.go @@ -0,0 +1,70 @@ +package replicationnetworkmappings + +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 ReplicationNetworkMappingsClient) Delete(ctx context.Context, id ReplicationNetworkMappingId) (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 ReplicationNetworkMappingsClient) DeleteThenPoll(ctx context.Context, id ReplicationNetworkMappingId) 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/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/method_get.go new file mode 100644 index 00000000000..525a5254824 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/method_get.go @@ -0,0 +1,53 @@ +package replicationnetworkmappings + +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 *NetworkMapping +} + +// Get ... +func (c ReplicationNetworkMappingsClient) Get(ctx context.Context, id ReplicationNetworkMappingId) (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 NetworkMapping + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/method_list.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/method_list.go new file mode 100644 index 00000000000..c8dfd95c67d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/method_list.go @@ -0,0 +1,105 @@ +package replicationnetworkmappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkMapping +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkMapping +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ReplicationNetworkMappingsClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/replicationNetworkMappings", 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 *[]NetworkMapping `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationNetworkMappingsClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, NetworkMappingOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationNetworkMappingsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate NetworkMappingOperationPredicate) (result ListCompleteResult, err error) { + items := make([]NetworkMapping, 0) + + resp, err := c.List(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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/method_listbyreplicationnetworks.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/method_listbyreplicationnetworks.go new file mode 100644 index 00000000000..51e7d93a04b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/method_listbyreplicationnetworks.go @@ -0,0 +1,105 @@ +package replicationnetworkmappings + +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 ListByReplicationNetworksOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkMapping +} + +type ListByReplicationNetworksCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkMapping +} + +type ListByReplicationNetworksCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationNetworksCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationNetworks ... +func (c ReplicationNetworkMappingsClient) ListByReplicationNetworks(ctx context.Context, id ReplicationNetworkId) (result ListByReplicationNetworksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationNetworksCustomPager{}, + Path: fmt.Sprintf("%s/replicationNetworkMappings", 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 *[]NetworkMapping `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationNetworksComplete retrieves all the results into a single object +func (c ReplicationNetworkMappingsClient) ListByReplicationNetworksComplete(ctx context.Context, id ReplicationNetworkId) (ListByReplicationNetworksCompleteResult, error) { + return c.ListByReplicationNetworksCompleteMatchingPredicate(ctx, id, NetworkMappingOperationPredicate{}) +} + +// ListByReplicationNetworksCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationNetworkMappingsClient) ListByReplicationNetworksCompleteMatchingPredicate(ctx context.Context, id ReplicationNetworkId, predicate NetworkMappingOperationPredicate) (result ListByReplicationNetworksCompleteResult, err error) { + items := make([]NetworkMapping, 0) + + resp, err := c.ListByReplicationNetworks(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 = ListByReplicationNetworksCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/method_update.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/method_update.go new file mode 100644 index 00000000000..bbd5fc8d76f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/method_update.go @@ -0,0 +1,75 @@ +package replicationnetworkmappings + +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 *NetworkMapping +} + +// Update ... +func (c ReplicationNetworkMappingsClient) Update(ctx context.Context, id ReplicationNetworkMappingId, input UpdateNetworkMappingInput) (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 ReplicationNetworkMappingsClient) UpdateThenPoll(ctx context.Context, id ReplicationNetworkMappingId, input UpdateNetworkMappingInput) 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/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_azuretoazurecreatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_azuretoazurecreatenetworkmappinginput.go new file mode 100644 index 00000000000..bf9c068eb17 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_azuretoazurecreatenetworkmappinginput.go @@ -0,0 +1,50 @@ +package replicationnetworkmappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificCreateNetworkMappingInput = AzureToAzureCreateNetworkMappingInput{} + +type AzureToAzureCreateNetworkMappingInput struct { + PrimaryNetworkId string `json:"primaryNetworkId"` + + // Fields inherited from FabricSpecificCreateNetworkMappingInput + + InstanceType string `json:"instanceType"` +} + +func (s AzureToAzureCreateNetworkMappingInput) FabricSpecificCreateNetworkMappingInput() BaseFabricSpecificCreateNetworkMappingInputImpl { + return BaseFabricSpecificCreateNetworkMappingInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = AzureToAzureCreateNetworkMappingInput{} + +func (s AzureToAzureCreateNetworkMappingInput) MarshalJSON() ([]byte, error) { + type wrapper AzureToAzureCreateNetworkMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureToAzureCreateNetworkMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureToAzureCreateNetworkMappingInput: %+v", err) + } + + decoded["instanceType"] = "AzureToAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureToAzureCreateNetworkMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_azuretoazurenetworkmappingsettings.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_azuretoazurenetworkmappingsettings.go new file mode 100644 index 00000000000..3c54371de7d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_azuretoazurenetworkmappingsettings.go @@ -0,0 +1,51 @@ +package replicationnetworkmappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ NetworkMappingFabricSpecificSettings = AzureToAzureNetworkMappingSettings{} + +type AzureToAzureNetworkMappingSettings struct { + PrimaryFabricLocation *string `json:"primaryFabricLocation,omitempty"` + RecoveryFabricLocation *string `json:"recoveryFabricLocation,omitempty"` + + // Fields inherited from NetworkMappingFabricSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s AzureToAzureNetworkMappingSettings) NetworkMappingFabricSpecificSettings() BaseNetworkMappingFabricSpecificSettingsImpl { + return BaseNetworkMappingFabricSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = AzureToAzureNetworkMappingSettings{} + +func (s AzureToAzureNetworkMappingSettings) MarshalJSON() ([]byte, error) { + type wrapper AzureToAzureNetworkMappingSettings + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureToAzureNetworkMappingSettings: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureToAzureNetworkMappingSettings: %+v", err) + } + + decoded["instanceType"] = "AzureToAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureToAzureNetworkMappingSettings: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_azuretoazureupdatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_azuretoazureupdatenetworkmappinginput.go new file mode 100644 index 00000000000..712bd15b869 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_azuretoazureupdatenetworkmappinginput.go @@ -0,0 +1,50 @@ +package replicationnetworkmappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificUpdateNetworkMappingInput = AzureToAzureUpdateNetworkMappingInput{} + +type AzureToAzureUpdateNetworkMappingInput struct { + PrimaryNetworkId *string `json:"primaryNetworkId,omitempty"` + + // Fields inherited from FabricSpecificUpdateNetworkMappingInput + + InstanceType string `json:"instanceType"` +} + +func (s AzureToAzureUpdateNetworkMappingInput) FabricSpecificUpdateNetworkMappingInput() BaseFabricSpecificUpdateNetworkMappingInputImpl { + return BaseFabricSpecificUpdateNetworkMappingInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = AzureToAzureUpdateNetworkMappingInput{} + +func (s AzureToAzureUpdateNetworkMappingInput) MarshalJSON() ([]byte, error) { + type wrapper AzureToAzureUpdateNetworkMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureToAzureUpdateNetworkMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureToAzureUpdateNetworkMappingInput: %+v", err) + } + + decoded["instanceType"] = "AzureToAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureToAzureUpdateNetworkMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_createnetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_createnetworkmappinginput.go new file mode 100644 index 00000000000..1465b2453c9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_createnetworkmappinginput.go @@ -0,0 +1,8 @@ +package replicationnetworkmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateNetworkMappingInput struct { + Properties CreateNetworkMappingInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_createnetworkmappinginputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_createnetworkmappinginputproperties.go new file mode 100644 index 00000000000..792db7cc081 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_createnetworkmappinginputproperties.go @@ -0,0 +1,45 @@ +package replicationnetworkmappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateNetworkMappingInputProperties struct { + FabricSpecificDetails FabricSpecificCreateNetworkMappingInput `json:"fabricSpecificDetails"` + RecoveryFabricName *string `json:"recoveryFabricName,omitempty"` + RecoveryNetworkId string `json:"recoveryNetworkId"` +} + +var _ json.Unmarshaler = &CreateNetworkMappingInputProperties{} + +func (s *CreateNetworkMappingInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + RecoveryFabricName *string `json:"recoveryFabricName,omitempty"` + RecoveryNetworkId string `json:"recoveryNetworkId"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.RecoveryFabricName = decoded.RecoveryFabricName + s.RecoveryNetworkId = decoded.RecoveryNetworkId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CreateNetworkMappingInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["fabricSpecificDetails"]; ok { + impl, err := UnmarshalFabricSpecificCreateNetworkMappingInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'FabricSpecificDetails' for 'CreateNetworkMappingInputProperties': %+v", err) + } + s.FabricSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_fabricspecificcreatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_fabricspecificcreatenetworkmappinginput.go new file mode 100644 index 00000000000..ead65c29e3f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_fabricspecificcreatenetworkmappinginput.go @@ -0,0 +1,91 @@ +package replicationnetworkmappings + +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 FabricSpecificCreateNetworkMappingInput interface { + FabricSpecificCreateNetworkMappingInput() BaseFabricSpecificCreateNetworkMappingInputImpl +} + +var _ FabricSpecificCreateNetworkMappingInput = BaseFabricSpecificCreateNetworkMappingInputImpl{} + +type BaseFabricSpecificCreateNetworkMappingInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseFabricSpecificCreateNetworkMappingInputImpl) FabricSpecificCreateNetworkMappingInput() BaseFabricSpecificCreateNetworkMappingInputImpl { + return s +} + +var _ FabricSpecificCreateNetworkMappingInput = RawFabricSpecificCreateNetworkMappingInputImpl{} + +// RawFabricSpecificCreateNetworkMappingInputImpl 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 RawFabricSpecificCreateNetworkMappingInputImpl struct { + fabricSpecificCreateNetworkMappingInput BaseFabricSpecificCreateNetworkMappingInputImpl + Type string + Values map[string]interface{} +} + +func (s RawFabricSpecificCreateNetworkMappingInputImpl) FabricSpecificCreateNetworkMappingInput() BaseFabricSpecificCreateNetworkMappingInputImpl { + return s.fabricSpecificCreateNetworkMappingInput +} + +func UnmarshalFabricSpecificCreateNetworkMappingInputImplementation(input []byte) (FabricSpecificCreateNetworkMappingInput, 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 FabricSpecificCreateNetworkMappingInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureToAzure") { + var out AzureToAzureCreateNetworkMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureToAzureCreateNetworkMappingInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VmmToAzure") { + var out VMmToAzureCreateNetworkMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMmToAzureCreateNetworkMappingInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VmmToVmm") { + var out VMmToVMmCreateNetworkMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMmToVMmCreateNetworkMappingInput: %+v", err) + } + return out, nil + } + + var parent BaseFabricSpecificCreateNetworkMappingInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseFabricSpecificCreateNetworkMappingInputImpl: %+v", err) + } + + return RawFabricSpecificCreateNetworkMappingInputImpl{ + fabricSpecificCreateNetworkMappingInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_fabricspecificupdatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_fabricspecificupdatenetworkmappinginput.go new file mode 100644 index 00000000000..1619f21a4f5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_fabricspecificupdatenetworkmappinginput.go @@ -0,0 +1,91 @@ +package replicationnetworkmappings + +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 FabricSpecificUpdateNetworkMappingInput interface { + FabricSpecificUpdateNetworkMappingInput() BaseFabricSpecificUpdateNetworkMappingInputImpl +} + +var _ FabricSpecificUpdateNetworkMappingInput = BaseFabricSpecificUpdateNetworkMappingInputImpl{} + +type BaseFabricSpecificUpdateNetworkMappingInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseFabricSpecificUpdateNetworkMappingInputImpl) FabricSpecificUpdateNetworkMappingInput() BaseFabricSpecificUpdateNetworkMappingInputImpl { + return s +} + +var _ FabricSpecificUpdateNetworkMappingInput = RawFabricSpecificUpdateNetworkMappingInputImpl{} + +// RawFabricSpecificUpdateNetworkMappingInputImpl 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 RawFabricSpecificUpdateNetworkMappingInputImpl struct { + fabricSpecificUpdateNetworkMappingInput BaseFabricSpecificUpdateNetworkMappingInputImpl + Type string + Values map[string]interface{} +} + +func (s RawFabricSpecificUpdateNetworkMappingInputImpl) FabricSpecificUpdateNetworkMappingInput() BaseFabricSpecificUpdateNetworkMappingInputImpl { + return s.fabricSpecificUpdateNetworkMappingInput +} + +func UnmarshalFabricSpecificUpdateNetworkMappingInputImplementation(input []byte) (FabricSpecificUpdateNetworkMappingInput, 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 FabricSpecificUpdateNetworkMappingInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureToAzure") { + var out AzureToAzureUpdateNetworkMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureToAzureUpdateNetworkMappingInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VmmToAzure") { + var out VMmToAzureUpdateNetworkMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMmToAzureUpdateNetworkMappingInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VmmToVmm") { + var out VMmToVMmUpdateNetworkMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMmToVMmUpdateNetworkMappingInput: %+v", err) + } + return out, nil + } + + var parent BaseFabricSpecificUpdateNetworkMappingInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseFabricSpecificUpdateNetworkMappingInputImpl: %+v", err) + } + + return RawFabricSpecificUpdateNetworkMappingInputImpl{ + fabricSpecificUpdateNetworkMappingInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_networkmapping.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_networkmapping.go new file mode 100644 index 00000000000..920122dece0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_networkmapping.go @@ -0,0 +1,12 @@ +package replicationnetworkmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkMapping struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkMappingProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_networkmappingfabricspecificsettings.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_networkmappingfabricspecificsettings.go new file mode 100644 index 00000000000..cc0f8272959 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_networkmappingfabricspecificsettings.go @@ -0,0 +1,91 @@ +package replicationnetworkmappings + +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 NetworkMappingFabricSpecificSettings interface { + NetworkMappingFabricSpecificSettings() BaseNetworkMappingFabricSpecificSettingsImpl +} + +var _ NetworkMappingFabricSpecificSettings = BaseNetworkMappingFabricSpecificSettingsImpl{} + +type BaseNetworkMappingFabricSpecificSettingsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseNetworkMappingFabricSpecificSettingsImpl) NetworkMappingFabricSpecificSettings() BaseNetworkMappingFabricSpecificSettingsImpl { + return s +} + +var _ NetworkMappingFabricSpecificSettings = RawNetworkMappingFabricSpecificSettingsImpl{} + +// RawNetworkMappingFabricSpecificSettingsImpl 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 RawNetworkMappingFabricSpecificSettingsImpl struct { + networkMappingFabricSpecificSettings BaseNetworkMappingFabricSpecificSettingsImpl + Type string + Values map[string]interface{} +} + +func (s RawNetworkMappingFabricSpecificSettingsImpl) NetworkMappingFabricSpecificSettings() BaseNetworkMappingFabricSpecificSettingsImpl { + return s.networkMappingFabricSpecificSettings +} + +func UnmarshalNetworkMappingFabricSpecificSettingsImplementation(input []byte) (NetworkMappingFabricSpecificSettings, 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 NetworkMappingFabricSpecificSettings into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureToAzure") { + var out AzureToAzureNetworkMappingSettings + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureToAzureNetworkMappingSettings: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VmmToAzure") { + var out VMmToAzureNetworkMappingSettings + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMmToAzureNetworkMappingSettings: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VmmToVmm") { + var out VMmToVMmNetworkMappingSettings + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMmToVMmNetworkMappingSettings: %+v", err) + } + return out, nil + } + + var parent BaseNetworkMappingFabricSpecificSettingsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseNetworkMappingFabricSpecificSettingsImpl: %+v", err) + } + + return RawNetworkMappingFabricSpecificSettingsImpl{ + networkMappingFabricSpecificSettings: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_networkmappingproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_networkmappingproperties.go new file mode 100644 index 00000000000..2dbab290e69 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_networkmappingproperties.go @@ -0,0 +1,63 @@ +package replicationnetworkmappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkMappingProperties struct { + FabricSpecificSettings NetworkMappingFabricSpecificSettings `json:"fabricSpecificSettings"` + PrimaryFabricFriendlyName *string `json:"primaryFabricFriendlyName,omitempty"` + PrimaryNetworkFriendlyName *string `json:"primaryNetworkFriendlyName,omitempty"` + PrimaryNetworkId *string `json:"primaryNetworkId,omitempty"` + RecoveryFabricArmId *string `json:"recoveryFabricArmId,omitempty"` + RecoveryFabricFriendlyName *string `json:"recoveryFabricFriendlyName,omitempty"` + RecoveryNetworkFriendlyName *string `json:"recoveryNetworkFriendlyName,omitempty"` + RecoveryNetworkId *string `json:"recoveryNetworkId,omitempty"` + State *string `json:"state,omitempty"` +} + +var _ json.Unmarshaler = &NetworkMappingProperties{} + +func (s *NetworkMappingProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + PrimaryFabricFriendlyName *string `json:"primaryFabricFriendlyName,omitempty"` + PrimaryNetworkFriendlyName *string `json:"primaryNetworkFriendlyName,omitempty"` + PrimaryNetworkId *string `json:"primaryNetworkId,omitempty"` + RecoveryFabricArmId *string `json:"recoveryFabricArmId,omitempty"` + RecoveryFabricFriendlyName *string `json:"recoveryFabricFriendlyName,omitempty"` + RecoveryNetworkFriendlyName *string `json:"recoveryNetworkFriendlyName,omitempty"` + RecoveryNetworkId *string `json:"recoveryNetworkId,omitempty"` + State *string `json:"state,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.PrimaryFabricFriendlyName = decoded.PrimaryFabricFriendlyName + s.PrimaryNetworkFriendlyName = decoded.PrimaryNetworkFriendlyName + s.PrimaryNetworkId = decoded.PrimaryNetworkId + s.RecoveryFabricArmId = decoded.RecoveryFabricArmId + s.RecoveryFabricFriendlyName = decoded.RecoveryFabricFriendlyName + s.RecoveryNetworkFriendlyName = decoded.RecoveryNetworkFriendlyName + s.RecoveryNetworkId = decoded.RecoveryNetworkId + s.State = decoded.State + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling NetworkMappingProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["fabricSpecificSettings"]; ok { + impl, err := UnmarshalNetworkMappingFabricSpecificSettingsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'FabricSpecificSettings' for 'NetworkMappingProperties': %+v", err) + } + s.FabricSpecificSettings = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_updatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_updatenetworkmappinginput.go new file mode 100644 index 00000000000..12c39d59aee --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_updatenetworkmappinginput.go @@ -0,0 +1,8 @@ +package replicationnetworkmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateNetworkMappingInput struct { + Properties *UpdateNetworkMappingInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_updatenetworkmappinginputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_updatenetworkmappinginputproperties.go new file mode 100644 index 00000000000..341408fc5db --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_updatenetworkmappinginputproperties.go @@ -0,0 +1,45 @@ +package replicationnetworkmappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateNetworkMappingInputProperties struct { + FabricSpecificDetails FabricSpecificUpdateNetworkMappingInput `json:"fabricSpecificDetails"` + RecoveryFabricName *string `json:"recoveryFabricName,omitempty"` + RecoveryNetworkId *string `json:"recoveryNetworkId,omitempty"` +} + +var _ json.Unmarshaler = &UpdateNetworkMappingInputProperties{} + +func (s *UpdateNetworkMappingInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + RecoveryFabricName *string `json:"recoveryFabricName,omitempty"` + RecoveryNetworkId *string `json:"recoveryNetworkId,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.RecoveryFabricName = decoded.RecoveryFabricName + s.RecoveryNetworkId = decoded.RecoveryNetworkId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling UpdateNetworkMappingInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["fabricSpecificDetails"]; ok { + impl, err := UnmarshalFabricSpecificUpdateNetworkMappingInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'FabricSpecificDetails' for 'UpdateNetworkMappingInputProperties': %+v", err) + } + s.FabricSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_vmmtoazurecreatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_vmmtoazurecreatenetworkmappinginput.go new file mode 100644 index 00000000000..5de8410f7a0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_vmmtoazurecreatenetworkmappinginput.go @@ -0,0 +1,49 @@ +package replicationnetworkmappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificCreateNetworkMappingInput = VMmToAzureCreateNetworkMappingInput{} + +type VMmToAzureCreateNetworkMappingInput struct { + + // Fields inherited from FabricSpecificCreateNetworkMappingInput + + InstanceType string `json:"instanceType"` +} + +func (s VMmToAzureCreateNetworkMappingInput) FabricSpecificCreateNetworkMappingInput() BaseFabricSpecificCreateNetworkMappingInputImpl { + return BaseFabricSpecificCreateNetworkMappingInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMmToAzureCreateNetworkMappingInput{} + +func (s VMmToAzureCreateNetworkMappingInput) MarshalJSON() ([]byte, error) { + type wrapper VMmToAzureCreateNetworkMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmToAzureCreateNetworkMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmToAzureCreateNetworkMappingInput: %+v", err) + } + + decoded["instanceType"] = "VmmToAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmToAzureCreateNetworkMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_vmmtoazurenetworkmappingsettings.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_vmmtoazurenetworkmappingsettings.go new file mode 100644 index 00000000000..5be8c4d6c59 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_vmmtoazurenetworkmappingsettings.go @@ -0,0 +1,49 @@ +package replicationnetworkmappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ NetworkMappingFabricSpecificSettings = VMmToAzureNetworkMappingSettings{} + +type VMmToAzureNetworkMappingSettings struct { + + // Fields inherited from NetworkMappingFabricSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s VMmToAzureNetworkMappingSettings) NetworkMappingFabricSpecificSettings() BaseNetworkMappingFabricSpecificSettingsImpl { + return BaseNetworkMappingFabricSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMmToAzureNetworkMappingSettings{} + +func (s VMmToAzureNetworkMappingSettings) MarshalJSON() ([]byte, error) { + type wrapper VMmToAzureNetworkMappingSettings + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmToAzureNetworkMappingSettings: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmToAzureNetworkMappingSettings: %+v", err) + } + + decoded["instanceType"] = "VmmToAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmToAzureNetworkMappingSettings: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_vmmtoazureupdatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_vmmtoazureupdatenetworkmappinginput.go new file mode 100644 index 00000000000..6ed764e3a78 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_vmmtoazureupdatenetworkmappinginput.go @@ -0,0 +1,49 @@ +package replicationnetworkmappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificUpdateNetworkMappingInput = VMmToAzureUpdateNetworkMappingInput{} + +type VMmToAzureUpdateNetworkMappingInput struct { + + // Fields inherited from FabricSpecificUpdateNetworkMappingInput + + InstanceType string `json:"instanceType"` +} + +func (s VMmToAzureUpdateNetworkMappingInput) FabricSpecificUpdateNetworkMappingInput() BaseFabricSpecificUpdateNetworkMappingInputImpl { + return BaseFabricSpecificUpdateNetworkMappingInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMmToAzureUpdateNetworkMappingInput{} + +func (s VMmToAzureUpdateNetworkMappingInput) MarshalJSON() ([]byte, error) { + type wrapper VMmToAzureUpdateNetworkMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmToAzureUpdateNetworkMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmToAzureUpdateNetworkMappingInput: %+v", err) + } + + decoded["instanceType"] = "VmmToAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmToAzureUpdateNetworkMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_vmmtovmmcreatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_vmmtovmmcreatenetworkmappinginput.go new file mode 100644 index 00000000000..3b35c972313 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_vmmtovmmcreatenetworkmappinginput.go @@ -0,0 +1,49 @@ +package replicationnetworkmappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificCreateNetworkMappingInput = VMmToVMmCreateNetworkMappingInput{} + +type VMmToVMmCreateNetworkMappingInput struct { + + // Fields inherited from FabricSpecificCreateNetworkMappingInput + + InstanceType string `json:"instanceType"` +} + +func (s VMmToVMmCreateNetworkMappingInput) FabricSpecificCreateNetworkMappingInput() BaseFabricSpecificCreateNetworkMappingInputImpl { + return BaseFabricSpecificCreateNetworkMappingInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMmToVMmCreateNetworkMappingInput{} + +func (s VMmToVMmCreateNetworkMappingInput) MarshalJSON() ([]byte, error) { + type wrapper VMmToVMmCreateNetworkMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmToVMmCreateNetworkMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmToVMmCreateNetworkMappingInput: %+v", err) + } + + decoded["instanceType"] = "VmmToVmm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmToVMmCreateNetworkMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_vmmtovmmnetworkmappingsettings.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_vmmtovmmnetworkmappingsettings.go new file mode 100644 index 00000000000..51bb27e4687 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_vmmtovmmnetworkmappingsettings.go @@ -0,0 +1,49 @@ +package replicationnetworkmappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ NetworkMappingFabricSpecificSettings = VMmToVMmNetworkMappingSettings{} + +type VMmToVMmNetworkMappingSettings struct { + + // Fields inherited from NetworkMappingFabricSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s VMmToVMmNetworkMappingSettings) NetworkMappingFabricSpecificSettings() BaseNetworkMappingFabricSpecificSettingsImpl { + return BaseNetworkMappingFabricSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMmToVMmNetworkMappingSettings{} + +func (s VMmToVMmNetworkMappingSettings) MarshalJSON() ([]byte, error) { + type wrapper VMmToVMmNetworkMappingSettings + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmToVMmNetworkMappingSettings: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmToVMmNetworkMappingSettings: %+v", err) + } + + decoded["instanceType"] = "VmmToVmm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmToVMmNetworkMappingSettings: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_vmmtovmmupdatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_vmmtovmmupdatenetworkmappinginput.go new file mode 100644 index 00000000000..11d58df40d9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/model_vmmtovmmupdatenetworkmappinginput.go @@ -0,0 +1,49 @@ +package replicationnetworkmappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FabricSpecificUpdateNetworkMappingInput = VMmToVMmUpdateNetworkMappingInput{} + +type VMmToVMmUpdateNetworkMappingInput struct { + + // Fields inherited from FabricSpecificUpdateNetworkMappingInput + + InstanceType string `json:"instanceType"` +} + +func (s VMmToVMmUpdateNetworkMappingInput) FabricSpecificUpdateNetworkMappingInput() BaseFabricSpecificUpdateNetworkMappingInputImpl { + return BaseFabricSpecificUpdateNetworkMappingInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMmToVMmUpdateNetworkMappingInput{} + +func (s VMmToVMmUpdateNetworkMappingInput) MarshalJSON() ([]byte, error) { + type wrapper VMmToVMmUpdateNetworkMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmToVMmUpdateNetworkMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmToVMmUpdateNetworkMappingInput: %+v", err) + } + + decoded["instanceType"] = "VmmToVmm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmToVMmUpdateNetworkMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/predicates.go new file mode 100644 index 00000000000..716755e52f7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/predicates.go @@ -0,0 +1,32 @@ +package replicationnetworkmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkMappingOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p NetworkMappingOperationPredicate) Matches(input NetworkMapping) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/version.go new file mode 100644 index 00000000000..be5d3d82f74 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworkmappings/version.go @@ -0,0 +1,10 @@ +package replicationnetworkmappings + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationnetworkmappings/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/README.md new file mode 100644 index 00000000000..ba265550b55 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/README.md @@ -0,0 +1,70 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks` Documentation + +The `replicationnetworks` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationnetworks" +``` + + +### Client Initialization + +```go +client := replicationnetworks.NewReplicationNetworksClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationNetworksClient.Get` + +```go +ctx := context.TODO() +id := replicationnetworks.NewReplicationNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName") + +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: `ReplicationNetworksClient.List` + +```go +ctx := context.TODO() +id := replicationnetworks.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationNetworksClient.ListByReplicationFabrics` + +```go +ctx := context.TODO() +id := replicationnetworks.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +// alternatively `client.ListByReplicationFabrics(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationFabricsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/client.go new file mode 100644 index 00000000000..925990ef0d7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/client.go @@ -0,0 +1,26 @@ +package replicationnetworks + +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 ReplicationNetworksClient struct { + Client *resourcemanager.Client +} + +func NewReplicationNetworksClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationNetworksClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationnetworks", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationNetworksClient: %+v", err) + } + + return &ReplicationNetworksClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/id_replicationfabric.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/id_replicationfabric.go new file mode 100644 index 00000000000..a8c98a7e306 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/id_replicationfabric.go @@ -0,0 +1,139 @@ +package replicationnetworks + +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(&ReplicationFabricId{}) +} + +var _ resourceids.ResourceId = &ReplicationFabricId{} + +// ReplicationFabricId is a struct representing the Resource ID for a Replication Fabric +type ReplicationFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string +} + +// NewReplicationFabricID returns a new ReplicationFabricId struct +func NewReplicationFabricID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string) ReplicationFabricId { + return ReplicationFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + } +} + +// ParseReplicationFabricID parses 'input' into a ReplicationFabricId +func ParseReplicationFabricID(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationFabricIDInsensitively parses 'input' case-insensitively into a ReplicationFabricId +// note: this method should only be used for API response data and not user input +func ParseReplicationFabricIDInsensitively(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationFabricId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + return nil +} + +// ValidateReplicationFabricID checks that 'input' can be parsed as a Replication Fabric ID +func ValidateReplicationFabricID(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 := ParseReplicationFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Fabric ID +func (id ReplicationFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Fabric ID +func (id ReplicationFabricId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + } +} + +// String returns a human-readable description of this Replication Fabric ID +func (id ReplicationFabricId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + } + return fmt.Sprintf("Replication Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/id_replicationfabric_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/id_replicationfabric_test.go new file mode 100644 index 00000000000..e06cfc4dd1a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/id_replicationfabric_test.go @@ -0,0 +1,327 @@ +package replicationnetworks + +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 = &ReplicationFabricId{} + +func TestNewReplicationFabricID(t *testing.T) { + id := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } +} + +func TestFormatReplicationFabricID(t *testing.T) { + actual := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestParseReplicationFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestSegmentsForReplicationFabricId(t *testing.T) { + segments := ReplicationFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationFabricId 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/recoveryservicessiterecovery/2024-10-01/replicationnetworks/id_replicationnetwork.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/id_replicationnetwork.go new file mode 100644 index 00000000000..edf86f27ed8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/id_replicationnetwork.go @@ -0,0 +1,148 @@ +package replicationnetworks + +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(&ReplicationNetworkId{}) +} + +var _ resourceids.ResourceId = &ReplicationNetworkId{} + +// ReplicationNetworkId is a struct representing the Resource ID for a Replication Network +type ReplicationNetworkId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationNetworkName string +} + +// NewReplicationNetworkID returns a new ReplicationNetworkId struct +func NewReplicationNetworkID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationNetworkName string) ReplicationNetworkId { + return ReplicationNetworkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationNetworkName: replicationNetworkName, + } +} + +// ParseReplicationNetworkID parses 'input' into a ReplicationNetworkId +func ParseReplicationNetworkID(input string) (*ReplicationNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationNetworkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationNetworkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationNetworkIDInsensitively parses 'input' case-insensitively into a ReplicationNetworkId +// note: this method should only be used for API response data and not user input +func ParseReplicationNetworkIDInsensitively(input string) (*ReplicationNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationNetworkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationNetworkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationNetworkId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationNetworkName, ok = input.Parsed["replicationNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationNetworkName", input) + } + + return nil +} + +// ValidateReplicationNetworkID checks that 'input' can be parsed as a Replication Network ID +func ValidateReplicationNetworkID(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 := ParseReplicationNetworkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Network ID +func (id ReplicationNetworkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationNetworks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationNetworkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Network ID +func (id ReplicationNetworkId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationNetworks", "replicationNetworks", "replicationNetworks"), + resourceids.UserSpecifiedSegment("replicationNetworkName", "replicationNetworkName"), + } +} + +// String returns a human-readable description of this Replication Network ID +func (id ReplicationNetworkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Network Name: %q", id.ReplicationNetworkName), + } + return fmt.Sprintf("Replication Network (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/id_replicationnetwork_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/id_replicationnetwork_test.go new file mode 100644 index 00000000000..876c102db90 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/id_replicationnetwork_test.go @@ -0,0 +1,372 @@ +package replicationnetworks + +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 = &ReplicationNetworkId{} + +func TestNewReplicationNetworkID(t *testing.T) { + id := NewReplicationNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationNetworkName != "replicationNetworkName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationNetworkName'", id.ReplicationNetworkName, "replicationNetworkName") + } +} + +func TestFormatReplicationNetworkID(t *testing.T) { + actual := NewReplicationNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationNetworkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationNetworkId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName", + Expected: &ReplicationNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationNetworkName: "replicationNetworkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationNetworkID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationNetworkName != v.Expected.ReplicationNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkName", v.Expected.ReplicationNetworkName, actual.ReplicationNetworkName) + } + + } +} + +func TestParseReplicationNetworkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationNetworkId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnNeTwOrKs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName", + Expected: &ReplicationNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationNetworkName: "replicationNetworkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKnAmE", + Expected: &ReplicationNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationNetworkName: "rEpLiCaTiOnNeTwOrKnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationNetworkIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationNetworkName != v.Expected.ReplicationNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkName", v.Expected.ReplicationNetworkName, actual.ReplicationNetworkName) + } + + } +} + +func TestSegmentsForReplicationNetworkId(t *testing.T) { + segments := ReplicationNetworkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationNetworkId 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/recoveryservicessiterecovery/2024-10-01/replicationnetworks/id_vault.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/id_vault.go new file mode 100644 index 00000000000..57c8e9dba03 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/id_vault.go @@ -0,0 +1,130 @@ +package replicationnetworks + +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(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(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 := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/id_vault_test.go new file mode 100644 index 00000000000..4baea566f21 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationnetworks + +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 = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId 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/recoveryservicessiterecovery/2024-10-01/replicationnetworks/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/method_get.go new file mode 100644 index 00000000000..0c5d3fefb65 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/method_get.go @@ -0,0 +1,53 @@ +package replicationnetworks + +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 *Network +} + +// Get ... +func (c ReplicationNetworksClient) Get(ctx context.Context, id ReplicationNetworkId) (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 Network + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/method_list.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/method_list.go new file mode 100644 index 00000000000..930b8eccb31 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/method_list.go @@ -0,0 +1,105 @@ +package replicationnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Network +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Network +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ReplicationNetworksClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/replicationNetworks", 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 *[]Network `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationNetworksClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, NetworkOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationNetworksClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate NetworkOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Network, 0) + + resp, err := c.List(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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/method_listbyreplicationfabrics.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/method_listbyreplicationfabrics.go new file mode 100644 index 00000000000..88b6def873c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/method_listbyreplicationfabrics.go @@ -0,0 +1,105 @@ +package replicationnetworks + +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 ListByReplicationFabricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Network +} + +type ListByReplicationFabricsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Network +} + +type ListByReplicationFabricsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationFabricsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationFabrics ... +func (c ReplicationNetworksClient) ListByReplicationFabrics(ctx context.Context, id ReplicationFabricId) (result ListByReplicationFabricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationFabricsCustomPager{}, + Path: fmt.Sprintf("%s/replicationNetworks", 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 *[]Network `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationFabricsComplete retrieves all the results into a single object +func (c ReplicationNetworksClient) ListByReplicationFabricsComplete(ctx context.Context, id ReplicationFabricId) (ListByReplicationFabricsCompleteResult, error) { + return c.ListByReplicationFabricsCompleteMatchingPredicate(ctx, id, NetworkOperationPredicate{}) +} + +// ListByReplicationFabricsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationNetworksClient) ListByReplicationFabricsCompleteMatchingPredicate(ctx context.Context, id ReplicationFabricId, predicate NetworkOperationPredicate) (result ListByReplicationFabricsCompleteResult, err error) { + items := make([]Network, 0) + + resp, err := c.ListByReplicationFabrics(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 = ListByReplicationFabricsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/model_network.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/model_network.go new file mode 100644 index 00000000000..a55b39eacf2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/model_network.go @@ -0,0 +1,12 @@ +package replicationnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Network struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/model_networkproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/model_networkproperties.go new file mode 100644 index 00000000000..7a2c7204a97 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/model_networkproperties.go @@ -0,0 +1,11 @@ +package replicationnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkProperties struct { + FabricType *string `json:"fabricType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + NetworkType *string `json:"networkType,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/model_subnet.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/model_subnet.go new file mode 100644 index 00000000000..fed1f4919d8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/model_subnet.go @@ -0,0 +1,10 @@ +package replicationnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + AddressList *[]string `json:"addressList,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/predicates.go new file mode 100644 index 00000000000..98e4bcc158c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/predicates.go @@ -0,0 +1,32 @@ +package replicationnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p NetworkOperationPredicate) Matches(input Network) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/version.go new file mode 100644 index 00000000000..3cf53a4cf65 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationnetworks/version.go @@ -0,0 +1,10 @@ +package replicationnetworks + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationnetworks/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/README.md new file mode 100644 index 00000000000..500be6eab3f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/README.md @@ -0,0 +1,99 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies` Documentation + +The `replicationpolicies` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationpolicies" +``` + + +### Client Initialization + +```go +client := replicationpolicies.NewReplicationPoliciesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationPoliciesClient.Create` + +```go +ctx := context.TODO() +id := replicationpolicies.NewReplicationPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationPolicyName") + +payload := replicationpolicies.CreatePolicyInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationPoliciesClient.Delete` + +```go +ctx := context.TODO() +id := replicationpolicies.NewReplicationPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationPolicyName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationPoliciesClient.Get` + +```go +ctx := context.TODO() +id := replicationpolicies.NewReplicationPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationPolicyName") + +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: `ReplicationPoliciesClient.List` + +```go +ctx := context.TODO() +id := replicationpolicies.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationPoliciesClient.Update` + +```go +ctx := context.TODO() +id := replicationpolicies.NewReplicationPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationPolicyName") + +payload := replicationpolicies.UpdatePolicyInput{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/client.go new file mode 100644 index 00000000000..0ebc718b0e0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/client.go @@ -0,0 +1,26 @@ +package replicationpolicies + +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 ReplicationPoliciesClient struct { + Client *resourcemanager.Client +} + +func NewReplicationPoliciesClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationPoliciesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationpolicies", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationPoliciesClient: %+v", err) + } + + return &ReplicationPoliciesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/constants.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/constants.go new file mode 100644 index 00000000000..b57ea3f114f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/constants.go @@ -0,0 +1,51 @@ +package replicationpolicies + +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 SetMultiVMSyncStatus string + +const ( + SetMultiVMSyncStatusDisable SetMultiVMSyncStatus = "Disable" + SetMultiVMSyncStatusEnable SetMultiVMSyncStatus = "Enable" +) + +func PossibleValuesForSetMultiVMSyncStatus() []string { + return []string{ + string(SetMultiVMSyncStatusDisable), + string(SetMultiVMSyncStatusEnable), + } +} + +func (s *SetMultiVMSyncStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSetMultiVMSyncStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSetMultiVMSyncStatus(input string) (*SetMultiVMSyncStatus, error) { + vals := map[string]SetMultiVMSyncStatus{ + "disable": SetMultiVMSyncStatusDisable, + "enable": SetMultiVMSyncStatusEnable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SetMultiVMSyncStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/id_replicationpolicy.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/id_replicationpolicy.go new file mode 100644 index 00000000000..8e52815a483 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/id_replicationpolicy.go @@ -0,0 +1,139 @@ +package replicationpolicies + +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(&ReplicationPolicyId{}) +} + +var _ resourceids.ResourceId = &ReplicationPolicyId{} + +// ReplicationPolicyId is a struct representing the Resource ID for a Replication Policy +type ReplicationPolicyId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationPolicyName string +} + +// NewReplicationPolicyID returns a new ReplicationPolicyId struct +func NewReplicationPolicyID(subscriptionId string, resourceGroupName string, vaultName string, replicationPolicyName string) ReplicationPolicyId { + return ReplicationPolicyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationPolicyName: replicationPolicyName, + } +} + +// ParseReplicationPolicyID parses 'input' into a ReplicationPolicyId +func ParseReplicationPolicyID(input string) (*ReplicationPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationPolicyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationPolicyIDInsensitively parses 'input' case-insensitively into a ReplicationPolicyId +// note: this method should only be used for API response data and not user input +func ParseReplicationPolicyIDInsensitively(input string) (*ReplicationPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationPolicyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationPolicyId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationPolicyName, ok = input.Parsed["replicationPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationPolicyName", input) + } + + return nil +} + +// ValidateReplicationPolicyID checks that 'input' can be parsed as a Replication Policy ID +func ValidateReplicationPolicyID(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 := ParseReplicationPolicyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Policy ID +func (id ReplicationPolicyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationPolicies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationPolicyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Policy ID +func (id ReplicationPolicyId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationPolicies", "replicationPolicies", "replicationPolicies"), + resourceids.UserSpecifiedSegment("replicationPolicyName", "replicationPolicyName"), + } +} + +// String returns a human-readable description of this Replication Policy ID +func (id ReplicationPolicyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Policy Name: %q", id.ReplicationPolicyName), + } + return fmt.Sprintf("Replication Policy (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/id_replicationpolicy_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/id_replicationpolicy_test.go new file mode 100644 index 00000000000..a22bec723f0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/id_replicationpolicy_test.go @@ -0,0 +1,327 @@ +package replicationpolicies + +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 = &ReplicationPolicyId{} + +func TestNewReplicationPolicyID(t *testing.T) { + id := NewReplicationPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationPolicyName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationPolicyName != "replicationPolicyName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationPolicyName'", id.ReplicationPolicyName, "replicationPolicyName") + } +} + +func TestFormatReplicationPolicyID(t *testing.T) { + actual := NewReplicationPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationPolicyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationPolicies/replicationPolicyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationPolicyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationPolicies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationPolicies/replicationPolicyName", + Expected: &ReplicationPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationPolicyName: "replicationPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationPolicies/replicationPolicyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationPolicyID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationPolicyName != v.Expected.ReplicationPolicyName { + t.Fatalf("Expected %q but got %q for ReplicationPolicyName", v.Expected.ReplicationPolicyName, actual.ReplicationPolicyName) + } + + } +} + +func TestParseReplicationPolicyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationPolicies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnPoLiCiEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationPolicies/replicationPolicyName", + Expected: &ReplicationPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationPolicyName: "replicationPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationPolicies/replicationPolicyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnPoLiCiEs/rEpLiCaTiOnPoLiCyNaMe", + Expected: &ReplicationPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationPolicyName: "rEpLiCaTiOnPoLiCyNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnPoLiCiEs/rEpLiCaTiOnPoLiCyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationPolicyIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationPolicyName != v.Expected.ReplicationPolicyName { + t.Fatalf("Expected %q but got %q for ReplicationPolicyName", v.Expected.ReplicationPolicyName, actual.ReplicationPolicyName) + } + + } +} + +func TestSegmentsForReplicationPolicyId(t *testing.T) { + segments := ReplicationPolicyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationPolicyId 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/recoveryservicessiterecovery/2024-10-01/replicationpolicies/id_vault.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/id_vault.go new file mode 100644 index 00000000000..e16dd3da492 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/id_vault.go @@ -0,0 +1,130 @@ +package replicationpolicies + +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(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(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 := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/id_vault_test.go new file mode 100644 index 00000000000..8c7119dc1f2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationpolicies + +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 = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId 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/recoveryservicessiterecovery/2024-10-01/replicationpolicies/method_create.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/method_create.go new file mode 100644 index 00000000000..2fa363134e7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/method_create.go @@ -0,0 +1,75 @@ +package replicationpolicies + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Policy +} + +// Create ... +func (c ReplicationPoliciesClient) Create(ctx context.Context, id ReplicationPolicyId, input CreatePolicyInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationPoliciesClient) CreateThenPoll(ctx context.Context, id ReplicationPolicyId, input CreatePolicyInput) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/method_delete.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/method_delete.go new file mode 100644 index 00000000000..4e3017160f7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/method_delete.go @@ -0,0 +1,70 @@ +package replicationpolicies + +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 ReplicationPoliciesClient) Delete(ctx context.Context, id ReplicationPolicyId) (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 ReplicationPoliciesClient) DeleteThenPoll(ctx context.Context, id ReplicationPolicyId) 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/recoveryservicessiterecovery/2024-10-01/replicationpolicies/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/method_get.go new file mode 100644 index 00000000000..711498c7141 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/method_get.go @@ -0,0 +1,53 @@ +package replicationpolicies + +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 *Policy +} + +// Get ... +func (c ReplicationPoliciesClient) Get(ctx context.Context, id ReplicationPolicyId) (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 Policy + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/method_list.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/method_list.go new file mode 100644 index 00000000000..28ba613b34b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/method_list.go @@ -0,0 +1,105 @@ +package replicationpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Policy +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Policy +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ReplicationPoliciesClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/replicationPolicies", 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 *[]Policy `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationPoliciesClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, PolicyOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationPoliciesClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate PolicyOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Policy, 0) + + resp, err := c.List(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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/method_update.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/method_update.go new file mode 100644 index 00000000000..91f76915b75 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/method_update.go @@ -0,0 +1,75 @@ +package replicationpolicies + +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 *Policy +} + +// Update ... +func (c ReplicationPoliciesClient) Update(ctx context.Context, id ReplicationPolicyId, input UpdatePolicyInput) (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 ReplicationPoliciesClient) UpdateThenPoll(ctx context.Context, id ReplicationPolicyId, input UpdatePolicyInput) 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/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_a2acrossclustermigrationpolicycreationinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_a2acrossclustermigrationpolicycreationinput.go new file mode 100644 index 00000000000..fb391222f09 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_a2acrossclustermigrationpolicycreationinput.go @@ -0,0 +1,49 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificInput = A2ACrossClusterMigrationPolicyCreationInput{} + +type A2ACrossClusterMigrationPolicyCreationInput struct { + + // Fields inherited from PolicyProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2ACrossClusterMigrationPolicyCreationInput) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return BasePolicyProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ACrossClusterMigrationPolicyCreationInput{} + +func (s A2ACrossClusterMigrationPolicyCreationInput) MarshalJSON() ([]byte, error) { + type wrapper A2ACrossClusterMigrationPolicyCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ACrossClusterMigrationPolicyCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ACrossClusterMigrationPolicyCreationInput: %+v", err) + } + + decoded["instanceType"] = "A2ACrossClusterMigration" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ACrossClusterMigrationPolicyCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_a2apolicycreationinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_a2apolicycreationinput.go new file mode 100644 index 00000000000..7e7b12aefc1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_a2apolicycreationinput.go @@ -0,0 +1,53 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificInput = A2APolicyCreationInput{} + +type A2APolicyCreationInput struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus SetMultiVMSyncStatus `json:"multiVmSyncStatus"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2APolicyCreationInput) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return BasePolicyProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2APolicyCreationInput{} + +func (s A2APolicyCreationInput) MarshalJSON() ([]byte, error) { + type wrapper A2APolicyCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2APolicyCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2APolicyCreationInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2APolicyCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_a2apolicydetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_a2apolicydetails.go new file mode 100644 index 00000000000..de32bcd7ca6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_a2apolicydetails.go @@ -0,0 +1,54 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificDetails = A2APolicyDetails{} + +type A2APolicyDetails struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + RecoveryPointThresholdInMinutes *int64 `json:"recoveryPointThresholdInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s A2APolicyDetails) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return BasePolicyProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2APolicyDetails{} + +func (s A2APolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper A2APolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2APolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2APolicyDetails: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2APolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_createpolicyinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_createpolicyinput.go new file mode 100644 index 00000000000..a1cb3c60fe8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_createpolicyinput.go @@ -0,0 +1,8 @@ +package replicationpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreatePolicyInput struct { + Properties *CreatePolicyInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_createpolicyinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_createpolicyinputproperties.go new file mode 100644 index 00000000000..ed5af5dd2d4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_createpolicyinputproperties.go @@ -0,0 +1,33 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreatePolicyInputProperties struct { + ProviderSpecificInput PolicyProviderSpecificInput `json:"providerSpecificInput"` +} + +var _ json.Unmarshaler = &CreatePolicyInputProperties{} + +func (s *CreatePolicyInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CreatePolicyInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificInput"]; ok { + impl, err := UnmarshalPolicyProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificInput' for 'CreatePolicyInputProperties': %+v", err) + } + s.ProviderSpecificInput = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_hypervreplicaazurepolicydetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_hypervreplicaazurepolicydetails.go new file mode 100644 index 00000000000..09456d1aa8f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_hypervreplicaazurepolicydetails.go @@ -0,0 +1,55 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificDetails = HyperVReplicaAzurePolicyDetails{} + +type HyperVReplicaAzurePolicyDetails struct { + ActiveStorageAccountId *string `json:"activeStorageAccountId,omitempty"` + ApplicationConsistentSnapshotFrequencyInHours *int64 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + Encryption *string `json:"encryption,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + RecoveryPointHistoryDurationInHours *int64 `json:"recoveryPointHistoryDurationInHours,omitempty"` + ReplicationInterval *int64 `json:"replicationInterval,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzurePolicyDetails) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return BasePolicyProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzurePolicyDetails{} + +func (s HyperVReplicaAzurePolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzurePolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzurePolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzurePolicyDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzurePolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_hypervreplicaazurepolicyinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_hypervreplicaazurepolicyinput.go new file mode 100644 index 00000000000..e186a0c6ca4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_hypervreplicaazurepolicyinput.go @@ -0,0 +1,54 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificInput = HyperVReplicaAzurePolicyInput{} + +type HyperVReplicaAzurePolicyInput struct { + ApplicationConsistentSnapshotFrequencyInHours *int64 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + RecoveryPointHistoryDuration *int64 `json:"recoveryPointHistoryDuration,omitempty"` + ReplicationInterval *int64 `json:"replicationInterval,omitempty"` + StorageAccounts *[]string `json:"storageAccounts,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzurePolicyInput) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return BasePolicyProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzurePolicyInput{} + +func (s HyperVReplicaAzurePolicyInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzurePolicyInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzurePolicyInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzurePolicyInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzurePolicyInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_hypervreplicabasepolicydetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_hypervreplicabasepolicydetails.go new file mode 100644 index 00000000000..54e54a624bc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_hypervreplicabasepolicydetails.go @@ -0,0 +1,59 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificDetails = HyperVReplicaBasePolicyDetails{} + +type HyperVReplicaBasePolicyDetails struct { + AllowedAuthenticationType *int64 `json:"allowedAuthenticationType,omitempty"` + ApplicationConsistentSnapshotFrequencyInHours *int64 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + Compression *string `json:"compression,omitempty"` + InitialReplicationMethod *string `json:"initialReplicationMethod,omitempty"` + OfflineReplicationExportPath *string `json:"offlineReplicationExportPath,omitempty"` + OfflineReplicationImportPath *string `json:"offlineReplicationImportPath,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + RecoveryPoints *int64 `json:"recoveryPoints,omitempty"` + ReplicaDeletionOption *string `json:"replicaDeletionOption,omitempty"` + ReplicationPort *int64 `json:"replicationPort,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaBasePolicyDetails) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return BasePolicyProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaBasePolicyDetails{} + +func (s HyperVReplicaBasePolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaBasePolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaBasePolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaBasePolicyDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaBasePolicyDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaBasePolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_hypervreplicabluepolicydetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_hypervreplicabluepolicydetails.go new file mode 100644 index 00000000000..2fcb7bb9422 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_hypervreplicabluepolicydetails.go @@ -0,0 +1,60 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificDetails = HyperVReplicaBluePolicyDetails{} + +type HyperVReplicaBluePolicyDetails struct { + AllowedAuthenticationType *int64 `json:"allowedAuthenticationType,omitempty"` + ApplicationConsistentSnapshotFrequencyInHours *int64 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + Compression *string `json:"compression,omitempty"` + InitialReplicationMethod *string `json:"initialReplicationMethod,omitempty"` + OfflineReplicationExportPath *string `json:"offlineReplicationExportPath,omitempty"` + OfflineReplicationImportPath *string `json:"offlineReplicationImportPath,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + RecoveryPoints *int64 `json:"recoveryPoints,omitempty"` + ReplicaDeletionOption *string `json:"replicaDeletionOption,omitempty"` + ReplicationFrequencyInSeconds *int64 `json:"replicationFrequencyInSeconds,omitempty"` + ReplicationPort *int64 `json:"replicationPort,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaBluePolicyDetails) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return BasePolicyProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaBluePolicyDetails{} + +func (s HyperVReplicaBluePolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaBluePolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaBluePolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaBluePolicyDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplica2012R2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaBluePolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_hypervreplicabluepolicyinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_hypervreplicabluepolicyinput.go new file mode 100644 index 00000000000..408e43857b3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_hypervreplicabluepolicyinput.go @@ -0,0 +1,50 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificInput = HyperVReplicaBluePolicyInput{} + +type HyperVReplicaBluePolicyInput struct { + ReplicationFrequencyInSeconds *int64 `json:"replicationFrequencyInSeconds,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaBluePolicyInput) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return BasePolicyProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaBluePolicyInput{} + +func (s HyperVReplicaBluePolicyInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaBluePolicyInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaBluePolicyInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaBluePolicyInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplica2012R2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaBluePolicyInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_hypervreplicapolicydetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_hypervreplicapolicydetails.go new file mode 100644 index 00000000000..13f18ff2e19 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_hypervreplicapolicydetails.go @@ -0,0 +1,59 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificDetails = HyperVReplicaPolicyDetails{} + +type HyperVReplicaPolicyDetails struct { + AllowedAuthenticationType *int64 `json:"allowedAuthenticationType,omitempty"` + ApplicationConsistentSnapshotFrequencyInHours *int64 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + Compression *string `json:"compression,omitempty"` + InitialReplicationMethod *string `json:"initialReplicationMethod,omitempty"` + OfflineReplicationExportPath *string `json:"offlineReplicationExportPath,omitempty"` + OfflineReplicationImportPath *string `json:"offlineReplicationImportPath,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + RecoveryPoints *int64 `json:"recoveryPoints,omitempty"` + ReplicaDeletionOption *string `json:"replicaDeletionOption,omitempty"` + ReplicationPort *int64 `json:"replicationPort,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaPolicyDetails) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return BasePolicyProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaPolicyDetails{} + +func (s HyperVReplicaPolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaPolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaPolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaPolicyDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplica2012" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaPolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_hypervreplicapolicyinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_hypervreplicapolicyinput.go new file mode 100644 index 00000000000..100c9e1d9f4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_hypervreplicapolicyinput.go @@ -0,0 +1,59 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificInput = HyperVReplicaPolicyInput{} + +type HyperVReplicaPolicyInput struct { + AllowedAuthenticationType *int64 `json:"allowedAuthenticationType,omitempty"` + ApplicationConsistentSnapshotFrequencyInHours *int64 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + Compression *string `json:"compression,omitempty"` + InitialReplicationMethod *string `json:"initialReplicationMethod,omitempty"` + OfflineReplicationExportPath *string `json:"offlineReplicationExportPath,omitempty"` + OfflineReplicationImportPath *string `json:"offlineReplicationImportPath,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + RecoveryPoints *int64 `json:"recoveryPoints,omitempty"` + ReplicaDeletion *string `json:"replicaDeletion,omitempty"` + ReplicationPort *int64 `json:"replicationPort,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaPolicyInput) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return BasePolicyProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaPolicyInput{} + +func (s HyperVReplicaPolicyInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaPolicyInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaPolicyInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaPolicyInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplica2012" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaPolicyInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmageazurev2policydetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmageazurev2policydetails.go new file mode 100644 index 00000000000..e8c78d43db9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmageazurev2policydetails.go @@ -0,0 +1,54 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificDetails = InMageAzureV2PolicyDetails{} + +type InMageAzureV2PolicyDetails struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + RecoveryPointThresholdInMinutes *int64 `json:"recoveryPointThresholdInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2PolicyDetails) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return BasePolicyProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2PolicyDetails{} + +func (s InMageAzureV2PolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2PolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2PolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2PolicyDetails: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2PolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmageazurev2policyinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmageazurev2policyinput.go new file mode 100644 index 00000000000..1d72287fec4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmageazurev2policyinput.go @@ -0,0 +1,54 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificInput = InMageAzureV2PolicyInput{} + +type InMageAzureV2PolicyInput struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus SetMultiVMSyncStatus `json:"multiVmSyncStatus"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + RecoveryPointThresholdInMinutes *int64 `json:"recoveryPointThresholdInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2PolicyInput) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return BasePolicyProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2PolicyInput{} + +func (s InMageAzureV2PolicyInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2PolicyInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2PolicyInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2PolicyInput: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2PolicyInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmagebasepolicydetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmagebasepolicydetails.go new file mode 100644 index 00000000000..cea2dc818ca --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmagebasepolicydetails.go @@ -0,0 +1,53 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificDetails = InMageBasePolicyDetails{} + +type InMageBasePolicyDetails struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + RecoveryPointThresholdInMinutes *int64 `json:"recoveryPointThresholdInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageBasePolicyDetails) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return BasePolicyProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageBasePolicyDetails{} + +func (s InMageBasePolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageBasePolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageBasePolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageBasePolicyDetails: %+v", err) + } + + decoded["instanceType"] = "InMageBasePolicyDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageBasePolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmagepolicydetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmagepolicydetails.go new file mode 100644 index 00000000000..785e7acebcf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmagepolicydetails.go @@ -0,0 +1,53 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificDetails = InMagePolicyDetails{} + +type InMagePolicyDetails struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + RecoveryPointThresholdInMinutes *int64 `json:"recoveryPointThresholdInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMagePolicyDetails) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return BasePolicyProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMagePolicyDetails{} + +func (s InMagePolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper InMagePolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMagePolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMagePolicyDetails: %+v", err) + } + + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMagePolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmagepolicyinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmagepolicyinput.go new file mode 100644 index 00000000000..8e2b3d62d36 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmagepolicyinput.go @@ -0,0 +1,53 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificInput = InMagePolicyInput{} + +type InMagePolicyInput struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus SetMultiVMSyncStatus `json:"multiVmSyncStatus"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + RecoveryPointThresholdInMinutes *int64 `json:"recoveryPointThresholdInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMagePolicyInput) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return BasePolicyProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMagePolicyInput{} + +func (s InMagePolicyInput) MarshalJSON() ([]byte, error) { + type wrapper InMagePolicyInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMagePolicyInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMagePolicyInput: %+v", err) + } + + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMagePolicyInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmagercmfailbackpolicycreationinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmagercmfailbackpolicycreationinput.go new file mode 100644 index 00000000000..7f9d9eff596 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmagercmfailbackpolicycreationinput.go @@ -0,0 +1,51 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificInput = InMageRcmFailbackPolicyCreationInput{} + +type InMageRcmFailbackPolicyCreationInput struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmFailbackPolicyCreationInput) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return BasePolicyProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmFailbackPolicyCreationInput{} + +func (s InMageRcmFailbackPolicyCreationInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFailbackPolicyCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFailbackPolicyCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFailbackPolicyCreationInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcmFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFailbackPolicyCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmagercmfailbackpolicydetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmagercmfailbackpolicydetails.go new file mode 100644 index 00000000000..98177d4e134 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmagercmfailbackpolicydetails.go @@ -0,0 +1,51 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificDetails = InMageRcmFailbackPolicyDetails{} + +type InMageRcmFailbackPolicyDetails struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmFailbackPolicyDetails) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return BasePolicyProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmFailbackPolicyDetails{} + +func (s InMageRcmFailbackPolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFailbackPolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFailbackPolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFailbackPolicyDetails: %+v", err) + } + + decoded["instanceType"] = "InMageRcmFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFailbackPolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmagercmpolicycreationinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmagercmpolicycreationinput.go new file mode 100644 index 00000000000..61e6e84a628 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmagercmpolicycreationinput.go @@ -0,0 +1,53 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificInput = InMageRcmPolicyCreationInput{} + +type InMageRcmPolicyCreationInput struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + EnableMultiVMSync *string `json:"enableMultiVmSync,omitempty"` + RecoveryPointHistoryInMinutes *int64 `json:"recoveryPointHistoryInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmPolicyCreationInput) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return BasePolicyProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmPolicyCreationInput{} + +func (s InMageRcmPolicyCreationInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmPolicyCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmPolicyCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmPolicyCreationInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmPolicyCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmagercmpolicydetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmagercmpolicydetails.go new file mode 100644 index 00000000000..589bab17807 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_inmagercmpolicydetails.go @@ -0,0 +1,53 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificDetails = InMageRcmPolicyDetails{} + +type InMageRcmPolicyDetails struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + EnableMultiVMSync *string `json:"enableMultiVmSync,omitempty"` + RecoveryPointHistoryInMinutes *int64 `json:"recoveryPointHistoryInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmPolicyDetails) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return BasePolicyProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmPolicyDetails{} + +func (s InMageRcmPolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmPolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmPolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmPolicyDetails: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmPolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_policy.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_policy.go new file mode 100644 index 00000000000..f57b4a8530b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_policy.go @@ -0,0 +1,12 @@ +package replicationpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Policy struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PolicyProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_policyproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_policyproperties.go new file mode 100644 index 00000000000..de051df248b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_policyproperties.go @@ -0,0 +1,42 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + ProviderSpecificDetails PolicyProviderSpecificDetails `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &PolicyProperties{} + +func (s *PolicyProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FriendlyName *string `json:"friendlyName,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FriendlyName = decoded.FriendlyName + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling PolicyProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalPolicyProviderSpecificDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'PolicyProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_policyproviderspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_policyproviderspecificdetails.go new file mode 100644 index 00000000000..65fecd406b4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_policyproviderspecificdetails.go @@ -0,0 +1,155 @@ +package replicationpolicies + +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 PolicyProviderSpecificDetails interface { + PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl +} + +var _ PolicyProviderSpecificDetails = BasePolicyProviderSpecificDetailsImpl{} + +type BasePolicyProviderSpecificDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BasePolicyProviderSpecificDetailsImpl) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return s +} + +var _ PolicyProviderSpecificDetails = RawPolicyProviderSpecificDetailsImpl{} + +// RawPolicyProviderSpecificDetailsImpl 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 RawPolicyProviderSpecificDetailsImpl struct { + policyProviderSpecificDetails BasePolicyProviderSpecificDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawPolicyProviderSpecificDetailsImpl) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return s.policyProviderSpecificDetails +} + +func UnmarshalPolicyProviderSpecificDetailsImplementation(input []byte) (PolicyProviderSpecificDetails, 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 PolicyProviderSpecificDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2APolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2APolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzurePolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzurePolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaBasePolicyDetails") { + var out HyperVReplicaBasePolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaBasePolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplica2012R2") { + var out HyperVReplicaBluePolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaBluePolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplica2012") { + var out HyperVReplicaPolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaPolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2PolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2PolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageBasePolicyDetails") { + var out InMageBasePolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageBasePolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out InMagePolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMagePolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcmFailback") { + var out InMageRcmFailbackPolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFailbackPolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmPolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmPolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtPolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtPolicyDetails: %+v", err) + } + return out, nil + } + + var parent BasePolicyProviderSpecificDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BasePolicyProviderSpecificDetailsImpl: %+v", err) + } + + return RawPolicyProviderSpecificDetailsImpl{ + policyProviderSpecificDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_policyproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_policyproviderspecificinput.go new file mode 100644 index 00000000000..b705d0e88c8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_policyproviderspecificinput.go @@ -0,0 +1,139 @@ +package replicationpolicies + +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 PolicyProviderSpecificInput interface { + PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl +} + +var _ PolicyProviderSpecificInput = BasePolicyProviderSpecificInputImpl{} + +type BasePolicyProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BasePolicyProviderSpecificInputImpl) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return s +} + +var _ PolicyProviderSpecificInput = RawPolicyProviderSpecificInputImpl{} + +// RawPolicyProviderSpecificInputImpl 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 RawPolicyProviderSpecificInputImpl struct { + policyProviderSpecificInput BasePolicyProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawPolicyProviderSpecificInputImpl) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return s.policyProviderSpecificInput +} + +func UnmarshalPolicyProviderSpecificInputImplementation(input []byte) (PolicyProviderSpecificInput, 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 PolicyProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2ACrossClusterMigration") { + var out A2ACrossClusterMigrationPolicyCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ACrossClusterMigrationPolicyCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2APolicyCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2APolicyCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzurePolicyInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzurePolicyInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplica2012") { + var out HyperVReplicaPolicyInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaPolicyInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2PolicyInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2PolicyInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out InMagePolicyInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMagePolicyInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcmFailback") { + var out InMageRcmFailbackPolicyCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFailbackPolicyCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmPolicyCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmPolicyCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtPolicyCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtPolicyCreationInput: %+v", err) + } + return out, nil + } + + var parent BasePolicyProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BasePolicyProviderSpecificInputImpl: %+v", err) + } + + return RawPolicyProviderSpecificInputImpl{ + policyProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_updatepolicyinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_updatepolicyinput.go new file mode 100644 index 00000000000..ca0f0a2c86e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_updatepolicyinput.go @@ -0,0 +1,8 @@ +package replicationpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdatePolicyInput struct { + Properties *UpdatePolicyInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_updatepolicyinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_updatepolicyinputproperties.go new file mode 100644 index 00000000000..ba3876b3319 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_updatepolicyinputproperties.go @@ -0,0 +1,33 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdatePolicyInputProperties struct { + ReplicationProviderSettings PolicyProviderSpecificInput `json:"replicationProviderSettings"` +} + +var _ json.Unmarshaler = &UpdatePolicyInputProperties{} + +func (s *UpdatePolicyInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling UpdatePolicyInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["replicationProviderSettings"]; ok { + impl, err := UnmarshalPolicyProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ReplicationProviderSettings' for 'UpdatePolicyInputProperties': %+v", err) + } + s.ReplicationProviderSettings = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_vmwarecbtpolicycreationinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_vmwarecbtpolicycreationinput.go new file mode 100644 index 00000000000..eaac5dcf2e3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_vmwarecbtpolicycreationinput.go @@ -0,0 +1,52 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificInput = VMwareCbtPolicyCreationInput{} + +type VMwareCbtPolicyCreationInput struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + RecoveryPointHistoryInMinutes *int64 `json:"recoveryPointHistoryInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtPolicyCreationInput) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return BasePolicyProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtPolicyCreationInput{} + +func (s VMwareCbtPolicyCreationInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtPolicyCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtPolicyCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtPolicyCreationInput: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtPolicyCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_vmwarecbtpolicydetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_vmwarecbtpolicydetails.go new file mode 100644 index 00000000000..d1398f83ff1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/model_vmwarecbtpolicydetails.go @@ -0,0 +1,52 @@ +package replicationpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PolicyProviderSpecificDetails = VMwareCbtPolicyDetails{} + +type VMwareCbtPolicyDetails struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + RecoveryPointHistoryInMinutes *int64 `json:"recoveryPointHistoryInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtPolicyDetails) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return BasePolicyProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtPolicyDetails{} + +func (s VMwareCbtPolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtPolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtPolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtPolicyDetails: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtPolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/predicates.go new file mode 100644 index 00000000000..3cb066948b0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/predicates.go @@ -0,0 +1,32 @@ +package replicationpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p PolicyOperationPredicate) Matches(input Policy) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/version.go new file mode 100644 index 00000000000..61532aa5ccc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationpolicies/version.go @@ -0,0 +1,10 @@ +package replicationpolicies + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationpolicies/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/README.md new file mode 100644 index 00000000000..af6abc37b3e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems` Documentation + +The `replicationprotectableitems` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems" +``` + + +### Client Initialization + +```go +client := replicationprotectableitems.NewReplicationProtectableItemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationProtectableItemsClient.Get` + +```go +ctx := context.TODO() +id := replicationprotectableitems.NewReplicationProtectableItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectableItemName") + +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: `ReplicationProtectableItemsClient.ListByReplicationProtectionContainers` + +```go +ctx := context.TODO() +id := replicationprotectableitems.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + +// alternatively `client.ListByReplicationProtectionContainers(ctx, id, replicationprotectableitems.DefaultListByReplicationProtectionContainersOperationOptions())` can be used to do batched pagination +items, err := client.ListByReplicationProtectionContainersComplete(ctx, id, replicationprotectableitems.DefaultListByReplicationProtectionContainersOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/client.go new file mode 100644 index 00000000000..0fe8f850abb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/client.go @@ -0,0 +1,26 @@ +package replicationprotectableitems + +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 ReplicationProtectableItemsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationProtectableItemsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationProtectableItemsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationprotectableitems", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationProtectableItemsClient: %+v", err) + } + + return &ReplicationProtectableItemsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/constants.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/constants.go new file mode 100644 index 00000000000..ba651c88667 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/constants.go @@ -0,0 +1,95 @@ +package replicationprotectableitems + +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 HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} + +type PresenceStatus string + +const ( + PresenceStatusNotPresent PresenceStatus = "NotPresent" + PresenceStatusPresent PresenceStatus = "Present" + PresenceStatusUnknown PresenceStatus = "Unknown" +) + +func PossibleValuesForPresenceStatus() []string { + return []string{ + string(PresenceStatusNotPresent), + string(PresenceStatusPresent), + string(PresenceStatusUnknown), + } +} + +func (s *PresenceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePresenceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePresenceStatus(input string) (*PresenceStatus, error) { + vals := map[string]PresenceStatus{ + "notpresent": PresenceStatusNotPresent, + "present": PresenceStatusPresent, + "unknown": PresenceStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PresenceStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/id_replicationprotectableitem.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/id_replicationprotectableitem.go new file mode 100644 index 00000000000..5688af5bd49 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/id_replicationprotectableitem.go @@ -0,0 +1,157 @@ +package replicationprotectableitems + +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(&ReplicationProtectableItemId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectableItemId{} + +// ReplicationProtectableItemId is a struct representing the Resource ID for a Replication Protectable Item +type ReplicationProtectableItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectableItemName string +} + +// NewReplicationProtectableItemID returns a new ReplicationProtectableItemId struct +func NewReplicationProtectableItemID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectableItemName string) ReplicationProtectableItemId { + return ReplicationProtectableItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectableItemName: replicationProtectableItemName, + } +} + +// ParseReplicationProtectableItemID parses 'input' into a ReplicationProtectableItemId +func ParseReplicationProtectableItemID(input string) (*ReplicationProtectableItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectableItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectableItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectableItemIDInsensitively parses 'input' case-insensitively into a ReplicationProtectableItemId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectableItemIDInsensitively(input string) (*ReplicationProtectableItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectableItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectableItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectableItemId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectableItemName, ok = input.Parsed["replicationProtectableItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectableItemName", input) + } + + return nil +} + +// ValidateReplicationProtectableItemID checks that 'input' can be parsed as a Replication Protectable Item ID +func ValidateReplicationProtectableItemID(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 := ParseReplicationProtectableItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protectable Item ID +func (id ReplicationProtectableItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectableItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectableItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protectable Item ID +func (id ReplicationProtectableItemId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationProtectableItems", "replicationProtectableItems", "replicationProtectableItems"), + resourceids.UserSpecifiedSegment("replicationProtectableItemName", "replicationProtectableItemName"), + } +} + +// String returns a human-readable description of this Replication Protectable Item ID +func (id ReplicationProtectableItemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protectable Item Name: %q", id.ReplicationProtectableItemName), + } + return fmt.Sprintf("Replication Protectable Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/id_replicationprotectableitem_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/id_replicationprotectableitem_test.go new file mode 100644 index 00000000000..5ca442edaf4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/id_replicationprotectableitem_test.go @@ -0,0 +1,417 @@ +package replicationprotectableitems + +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 = &ReplicationProtectableItemId{} + +func TestNewReplicationProtectableItemID(t *testing.T) { + id := NewReplicationProtectableItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectableItemName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationProtectableItemName != "replicationProtectableItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectableItemName'", id.ReplicationProtectableItemName, "replicationProtectableItemName") + } +} + +func TestFormatReplicationProtectableItemID(t *testing.T) { + actual := NewReplicationProtectableItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectableItemName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectableItems/replicationProtectableItemName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectableItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectableItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectableItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectableItems/replicationProtectableItemName", + Expected: &ReplicationProtectableItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectableItemName: "replicationProtectableItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectableItems/replicationProtectableItemName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectableItemID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectableItemName != v.Expected.ReplicationProtectableItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectableItemName", v.Expected.ReplicationProtectableItemName, actual.ReplicationProtectableItemName) + } + + } +} + +func TestParseReplicationProtectableItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectableItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectableItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTaBlEiTeMs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectableItems/replicationProtectableItemName", + Expected: &ReplicationProtectableItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectableItemName: "replicationProtectableItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectableItems/replicationProtectableItemName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTaBlEiTeMs/rEpLiCaTiOnPrOtEcTaBlEiTeMnAmE", + Expected: &ReplicationProtectableItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationProtectableItemName: "rEpLiCaTiOnPrOtEcTaBlEiTeMnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTaBlEiTeMs/rEpLiCaTiOnPrOtEcTaBlEiTeMnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectableItemIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectableItemName != v.Expected.ReplicationProtectableItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectableItemName", v.Expected.ReplicationProtectableItemName, actual.ReplicationProtectableItemName) + } + + } +} + +func TestSegmentsForReplicationProtectableItemId(t *testing.T) { + segments := ReplicationProtectableItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectableItemId 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/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/id_replicationprotectioncontainer.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/id_replicationprotectioncontainer.go new file mode 100644 index 00000000000..f23f4dd7edc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/id_replicationprotectioncontainer.go @@ -0,0 +1,148 @@ +package replicationprotectableitems + +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(&ReplicationProtectionContainerId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectionContainerId{} + +// ReplicationProtectionContainerId is a struct representing the Resource ID for a Replication Protection Container +type ReplicationProtectionContainerId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string +} + +// NewReplicationProtectionContainerID returns a new ReplicationProtectionContainerId struct +func NewReplicationProtectionContainerID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string) ReplicationProtectionContainerId { + return ReplicationProtectionContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + } +} + +// ParseReplicationProtectionContainerID parses 'input' into a ReplicationProtectionContainerId +func ParseReplicationProtectionContainerID(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionContainerIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionContainerId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionContainerIDInsensitively(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionContainerId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + return nil +} + +// ValidateReplicationProtectionContainerID checks that 'input' can be parsed as a Replication Protection Container ID +func ValidateReplicationProtectionContainerID(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 := ParseReplicationProtectionContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Container ID +func (id ReplicationProtectionContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Container ID +func (id ReplicationProtectionContainerId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + } +} + +// String returns a human-readable description of this Replication Protection Container ID +func (id ReplicationProtectionContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + } + return fmt.Sprintf("Replication Protection Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/id_replicationprotectioncontainer_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/id_replicationprotectioncontainer_test.go new file mode 100644 index 00000000000..34d92bb2295 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/id_replicationprotectioncontainer_test.go @@ -0,0 +1,372 @@ +package replicationprotectableitems + +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 = &ReplicationProtectionContainerId{} + +func TestNewReplicationProtectionContainerID(t *testing.T) { + id := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } +} + +func TestFormatReplicationProtectionContainerID(t *testing.T) { + actual := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestParseReplicationProtectionContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestSegmentsForReplicationProtectionContainerId(t *testing.T) { + segments := ReplicationProtectionContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionContainerId 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/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/method_get.go new file mode 100644 index 00000000000..c002604133f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/method_get.go @@ -0,0 +1,53 @@ +package replicationprotectableitems + +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 *ProtectableItem +} + +// Get ... +func (c ReplicationProtectableItemsClient) Get(ctx context.Context, id ReplicationProtectableItemId) (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 ProtectableItem + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/method_listbyreplicationprotectioncontainers.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/method_listbyreplicationprotectioncontainers.go new file mode 100644 index 00000000000..156271c76d1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/method_listbyreplicationprotectioncontainers.go @@ -0,0 +1,138 @@ +package replicationprotectableitems + +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 ListByReplicationProtectionContainersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProtectableItem +} + +type ListByReplicationProtectionContainersCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProtectableItem +} + +type ListByReplicationProtectionContainersOperationOptions struct { + Filter *string + Take *string +} + +func DefaultListByReplicationProtectionContainersOperationOptions() ListByReplicationProtectionContainersOperationOptions { + return ListByReplicationProtectionContainersOperationOptions{} +} + +func (o ListByReplicationProtectionContainersOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByReplicationProtectionContainersOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByReplicationProtectionContainersOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Take != nil { + out.Append("$take", fmt.Sprintf("%v", *o.Take)) + } + return &out +} + +type ListByReplicationProtectionContainersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationProtectionContainersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationProtectionContainers ... +func (c ReplicationProtectableItemsClient) ListByReplicationProtectionContainers(ctx context.Context, id ReplicationProtectionContainerId, options ListByReplicationProtectionContainersOperationOptions) (result ListByReplicationProtectionContainersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByReplicationProtectionContainersCustomPager{}, + Path: fmt.Sprintf("%s/replicationProtectableItems", 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 *[]ProtectableItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationProtectionContainersComplete retrieves all the results into a single object +func (c ReplicationProtectableItemsClient) ListByReplicationProtectionContainersComplete(ctx context.Context, id ReplicationProtectionContainerId, options ListByReplicationProtectionContainersOperationOptions) (ListByReplicationProtectionContainersCompleteResult, error) { + return c.ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx, id, options, ProtectableItemOperationPredicate{}) +} + +// ListByReplicationProtectionContainersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectableItemsClient) ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx context.Context, id ReplicationProtectionContainerId, options ListByReplicationProtectionContainersOperationOptions, predicate ProtectableItemOperationPredicate) (result ListByReplicationProtectionContainersCompleteResult, err error) { + items := make([]ProtectableItem, 0) + + resp, err := c.ListByReplicationProtectionContainers(ctx, id, options) + 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 = ListByReplicationProtectionContainersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_configurationsettings.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_configurationsettings.go new file mode 100644 index 00000000000..1bd6d6c2b38 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_configurationsettings.go @@ -0,0 +1,91 @@ +package replicationprotectableitems + +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 ConfigurationSettings interface { + ConfigurationSettings() BaseConfigurationSettingsImpl +} + +var _ ConfigurationSettings = BaseConfigurationSettingsImpl{} + +type BaseConfigurationSettingsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseConfigurationSettingsImpl) ConfigurationSettings() BaseConfigurationSettingsImpl { + return s +} + +var _ ConfigurationSettings = RawConfigurationSettingsImpl{} + +// RawConfigurationSettingsImpl 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 RawConfigurationSettingsImpl struct { + configurationSettings BaseConfigurationSettingsImpl + Type string + Values map[string]interface{} +} + +func (s RawConfigurationSettingsImpl) ConfigurationSettings() BaseConfigurationSettingsImpl { + return s.configurationSettings +} + +func UnmarshalConfigurationSettingsImplementation(input []byte) (ConfigurationSettings, 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 ConfigurationSettings into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "HyperVVirtualMachine") { + var out HyperVVirtualMachineDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVVirtualMachineDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ReplicationGroupDetails") { + var out ReplicationGroupDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ReplicationGroupDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareVirtualMachine") { + var out VMwareVirtualMachineDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareVirtualMachineDetails: %+v", err) + } + return out, nil + } + + var parent BaseConfigurationSettingsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseConfigurationSettingsImpl: %+v", err) + } + + return RawConfigurationSettingsImpl{ + configurationSettings: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_diskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_diskdetails.go new file mode 100644 index 00000000000..f418a8a199a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_diskdetails.go @@ -0,0 +1,11 @@ +package replicationprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskDetails struct { + MaxSizeMB *int64 `json:"maxSizeMB,omitempty"` + VhdId *string `json:"vhdId,omitempty"` + VhdName *string `json:"vhdName,omitempty"` + VhdType *string `json:"vhdType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_diskvolumedetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_diskvolumedetails.go new file mode 100644 index 00000000000..a1807b2e5d9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_diskvolumedetails.go @@ -0,0 +1,9 @@ +package replicationprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskVolumeDetails struct { + Label *string `json:"label,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_healtherror.go new file mode 100644 index 00000000000..dd836fd7405 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationprotectableitems + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_hypervvirtualmachinedetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_hypervvirtualmachinedetails.go new file mode 100644 index 00000000000..d9b640d45d9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_hypervvirtualmachinedetails.go @@ -0,0 +1,57 @@ +package replicationprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ConfigurationSettings = HyperVVirtualMachineDetails{} + +type HyperVVirtualMachineDetails struct { + DiskDetails *[]DiskDetails `json:"diskDetails,omitempty"` + Generation *string `json:"generation,omitempty"` + HasFibreChannelAdapter *PresenceStatus `json:"hasFibreChannelAdapter,omitempty"` + HasPhysicalDisk *PresenceStatus `json:"hasPhysicalDisk,omitempty"` + HasSharedVhd *PresenceStatus `json:"hasSharedVhd,omitempty"` + HyperVHostId *string `json:"hyperVHostId,omitempty"` + OsDetails *OSDetails `json:"osDetails,omitempty"` + SourceItemId *string `json:"sourceItemId,omitempty"` + + // Fields inherited from ConfigurationSettings + + InstanceType string `json:"instanceType"` +} + +func (s HyperVVirtualMachineDetails) ConfigurationSettings() BaseConfigurationSettingsImpl { + return BaseConfigurationSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVVirtualMachineDetails{} + +func (s HyperVVirtualMachineDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVVirtualMachineDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVVirtualMachineDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVVirtualMachineDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVVirtualMachine" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVVirtualMachineDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_inmagediskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_inmagediskdetails.go new file mode 100644 index 00000000000..a4233f28136 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_inmagediskdetails.go @@ -0,0 +1,13 @@ +package replicationprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageDiskDetails struct { + DiskConfiguration *string `json:"diskConfiguration,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskSizeInMB *string `json:"diskSizeInMB,omitempty"` + DiskType *string `json:"diskType,omitempty"` + VolumeList *[]DiskVolumeDetails `json:"volumeList,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_innerhealtherror.go new file mode 100644 index 00000000000..ee306e7b230 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationprotectableitems + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_osdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_osdetails.go new file mode 100644 index 00000000000..cfe4ba2336b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_osdetails.go @@ -0,0 +1,14 @@ +package replicationprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OSDetails struct { + OSMajorVersion *string `json:"oSMajorVersion,omitempty"` + OSMinorVersion *string `json:"oSMinorVersion,omitempty"` + OSVersion *string `json:"oSVersion,omitempty"` + OsEdition *string `json:"osEdition,omitempty"` + OsType *string `json:"osType,omitempty"` + ProductType *string `json:"productType,omitempty"` + UserSelectedOSName *string `json:"userSelectedOSName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_protectableitem.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_protectableitem.go new file mode 100644 index 00000000000..f2996c6b514 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_protectableitem.go @@ -0,0 +1,12 @@ +package replicationprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectableItem struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ProtectableItemProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_protectableitemproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_protectableitemproperties.go new file mode 100644 index 00000000000..525d23bc6b1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_protectableitemproperties.go @@ -0,0 +1,57 @@ +package replicationprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectableItemProperties struct { + CustomDetails ConfigurationSettings `json:"customDetails"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionReadinessErrors *[]string `json:"protectionReadinessErrors,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + RecoveryServicesProviderId *string `json:"recoveryServicesProviderId,omitempty"` + ReplicationProtectedItemId *string `json:"replicationProtectedItemId,omitempty"` + SupportedReplicationProviders *[]string `json:"supportedReplicationProviders,omitempty"` +} + +var _ json.Unmarshaler = &ProtectableItemProperties{} + +func (s *ProtectableItemProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionReadinessErrors *[]string `json:"protectionReadinessErrors,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + RecoveryServicesProviderId *string `json:"recoveryServicesProviderId,omitempty"` + ReplicationProtectedItemId *string `json:"replicationProtectedItemId,omitempty"` + SupportedReplicationProviders *[]string `json:"supportedReplicationProviders,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FriendlyName = decoded.FriendlyName + s.ProtectionReadinessErrors = decoded.ProtectionReadinessErrors + s.ProtectionStatus = decoded.ProtectionStatus + s.RecoveryServicesProviderId = decoded.RecoveryServicesProviderId + s.ReplicationProtectedItemId = decoded.ReplicationProtectedItemId + s.SupportedReplicationProviders = decoded.SupportedReplicationProviders + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectableItemProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["customDetails"]; ok { + impl, err := UnmarshalConfigurationSettingsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CustomDetails' for 'ProtectableItemProperties': %+v", err) + } + s.CustomDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_replicationgroupdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_replicationgroupdetails.go new file mode 100644 index 00000000000..2ba6c0e2112 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_replicationgroupdetails.go @@ -0,0 +1,49 @@ +package replicationprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ConfigurationSettings = ReplicationGroupDetails{} + +type ReplicationGroupDetails struct { + + // Fields inherited from ConfigurationSettings + + InstanceType string `json:"instanceType"` +} + +func (s ReplicationGroupDetails) ConfigurationSettings() BaseConfigurationSettingsImpl { + return BaseConfigurationSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = ReplicationGroupDetails{} + +func (s ReplicationGroupDetails) MarshalJSON() ([]byte, error) { + type wrapper ReplicationGroupDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ReplicationGroupDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ReplicationGroupDetails: %+v", err) + } + + decoded["instanceType"] = "ReplicationGroupDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ReplicationGroupDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_vmmvirtualmachinedetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_vmmvirtualmachinedetails.go new file mode 100644 index 00000000000..a23bbd99d96 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_vmmvirtualmachinedetails.go @@ -0,0 +1,49 @@ +package replicationprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ConfigurationSettings = VMmVirtualMachineDetails{} + +type VMmVirtualMachineDetails struct { + + // Fields inherited from ConfigurationSettings + + InstanceType string `json:"instanceType"` +} + +func (s VMmVirtualMachineDetails) ConfigurationSettings() BaseConfigurationSettingsImpl { + return BaseConfigurationSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMmVirtualMachineDetails{} + +func (s VMmVirtualMachineDetails) MarshalJSON() ([]byte, error) { + type wrapper VMmVirtualMachineDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmVirtualMachineDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmVirtualMachineDetails: %+v", err) + } + + decoded["instanceType"] = "VmmVirtualMachine" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmVirtualMachineDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_vmwarevirtualmachinedetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_vmwarevirtualmachinedetails.go new file mode 100644 index 00000000000..e372e550548 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/model_vmwarevirtualmachinedetails.go @@ -0,0 +1,59 @@ +package replicationprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ConfigurationSettings = VMwareVirtualMachineDetails{} + +type VMwareVirtualMachineDetails struct { + AgentGeneratedId *string `json:"agentGeneratedId,omitempty"` + AgentInstalled *string `json:"agentInstalled,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + DiscoveryType *string `json:"discoveryType,omitempty"` + DiskDetails *[]InMageDiskDetails `json:"diskDetails,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + OsType *string `json:"osType,omitempty"` + PoweredOn *string `json:"poweredOn,omitempty"` + VCenterInfrastructureId *string `json:"vCenterInfrastructureId,omitempty"` + ValidationErrors *[]HealthError `json:"validationErrors,omitempty"` + + // Fields inherited from ConfigurationSettings + + InstanceType string `json:"instanceType"` +} + +func (s VMwareVirtualMachineDetails) ConfigurationSettings() BaseConfigurationSettingsImpl { + return BaseConfigurationSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareVirtualMachineDetails{} + +func (s VMwareVirtualMachineDetails) MarshalJSON() ([]byte, error) { + type wrapper VMwareVirtualMachineDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareVirtualMachineDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareVirtualMachineDetails: %+v", err) + } + + decoded["instanceType"] = "VMwareVirtualMachine" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareVirtualMachineDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/predicates.go new file mode 100644 index 00000000000..cd7684d6433 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/predicates.go @@ -0,0 +1,32 @@ +package replicationprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectableItemOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ProtectableItemOperationPredicate) Matches(input ProtectableItem) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/version.go new file mode 100644 index 00000000000..36b33a97d4e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectableitems/version.go @@ -0,0 +1,10 @@ +package replicationprotectableitems + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationprotectableitems/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/README.md new file mode 100644 index 00000000000..92dd163da99 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/README.md @@ -0,0 +1,373 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems` Documentation + +The `replicationprotecteditems` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems" +``` + + +### Client Initialization + +```go +client := replicationprotecteditems.NewReplicationProtectedItemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationProtectedItemsClient.AddDisks` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.AddDisksInput{ + // ... +} + + +if err := client.AddDisksThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.ApplyRecoveryPoint` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.ApplyRecoveryPointInput{ + // ... +} + + +if err := client.ApplyRecoveryPointThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.Create` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.EnableProtectionInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.Delete` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.DisableProtectionInput{ + // ... +} + + +if err := client.DeleteThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.FailoverCancel` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +if err := client.FailoverCancelThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.FailoverCommit` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +if err := client.FailoverCommitThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.Get` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +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: `ReplicationProtectedItemsClient.List` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id, replicationprotecteditems.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, replicationprotecteditems.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.ListByReplicationProtectionContainers` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + +// alternatively `client.ListByReplicationProtectionContainers(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationProtectionContainersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.PlannedFailover` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.PlannedFailoverInput{ + // ... +} + + +if err := client.PlannedFailoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.Purge` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +if err := client.PurgeThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.RemoveDisks` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.RemoveDisksInput{ + // ... +} + + +if err := client.RemoveDisksThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.RepairReplication` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +if err := client.RepairReplicationThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.Reprotect` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.ReverseReplicationInput{ + // ... +} + + +if err := client.ReprotectThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.ResolveHealthErrors` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.ResolveHealthInput{ + // ... +} + + +if err := client.ResolveHealthErrorsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.SwitchProvider` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.SwitchProviderInput{ + // ... +} + + +if err := client.SwitchProviderThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.TestFailover` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.TestFailoverInput{ + // ... +} + + +if err := client.TestFailoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.TestFailoverCleanup` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.TestFailoverCleanupInput{ + // ... +} + + +if err := client.TestFailoverCleanupThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.UnplannedFailover` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.UnplannedFailoverInput{ + // ... +} + + +if err := client.UnplannedFailoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.Update` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.UpdateReplicationProtectedItemInput{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.UpdateAppliance` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.UpdateApplianceForReplicationProtectedItemInput{ + // ... +} + + +if err := client.UpdateApplianceThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.UpdateMobilityService` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.UpdateMobilityServiceRequest{ + // ... +} + + +if err := client.UpdateMobilityServiceThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/client.go new file mode 100644 index 00000000000..7b83bc196f5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/client.go @@ -0,0 +1,26 @@ +package replicationprotecteditems + +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 ReplicationProtectedItemsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationProtectedItemsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationProtectedItemsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationprotecteditems", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationProtectedItemsClient: %+v", err) + } + + return &ReplicationProtectedItemsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/constants.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/constants.go new file mode 100644 index 00000000000..59548c822b3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/constants.go @@ -0,0 +1,1020 @@ +package replicationprotecteditems + +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 AgentUpgradeBlockedReason string + +const ( + AgentUpgradeBlockedReasonAgentNoHeartbeat AgentUpgradeBlockedReason = "AgentNoHeartbeat" + AgentUpgradeBlockedReasonAlreadyOnLatestVersion AgentUpgradeBlockedReason = "AlreadyOnLatestVersion" + AgentUpgradeBlockedReasonDistroIsNotReported AgentUpgradeBlockedReason = "DistroIsNotReported" + AgentUpgradeBlockedReasonDistroNotSupportedForUpgrade AgentUpgradeBlockedReason = "DistroNotSupportedForUpgrade" + AgentUpgradeBlockedReasonIncompatibleApplianceVersion AgentUpgradeBlockedReason = "IncompatibleApplianceVersion" + AgentUpgradeBlockedReasonInvalidAgentVersion AgentUpgradeBlockedReason = "InvalidAgentVersion" + AgentUpgradeBlockedReasonInvalidDriverVersion AgentUpgradeBlockedReason = "InvalidDriverVersion" + AgentUpgradeBlockedReasonMissingUpgradePath AgentUpgradeBlockedReason = "MissingUpgradePath" + AgentUpgradeBlockedReasonNotProtected AgentUpgradeBlockedReason = "NotProtected" + AgentUpgradeBlockedReasonProcessServerNoHeartbeat AgentUpgradeBlockedReason = "ProcessServerNoHeartbeat" + AgentUpgradeBlockedReasonRcmProxyNoHeartbeat AgentUpgradeBlockedReason = "RcmProxyNoHeartbeat" + AgentUpgradeBlockedReasonRebootRequired AgentUpgradeBlockedReason = "RebootRequired" + AgentUpgradeBlockedReasonUnknown AgentUpgradeBlockedReason = "Unknown" + AgentUpgradeBlockedReasonUnsupportedProtectionScenario AgentUpgradeBlockedReason = "UnsupportedProtectionScenario" +) + +func PossibleValuesForAgentUpgradeBlockedReason() []string { + return []string{ + string(AgentUpgradeBlockedReasonAgentNoHeartbeat), + string(AgentUpgradeBlockedReasonAlreadyOnLatestVersion), + string(AgentUpgradeBlockedReasonDistroIsNotReported), + string(AgentUpgradeBlockedReasonDistroNotSupportedForUpgrade), + string(AgentUpgradeBlockedReasonIncompatibleApplianceVersion), + string(AgentUpgradeBlockedReasonInvalidAgentVersion), + string(AgentUpgradeBlockedReasonInvalidDriverVersion), + string(AgentUpgradeBlockedReasonMissingUpgradePath), + string(AgentUpgradeBlockedReasonNotProtected), + string(AgentUpgradeBlockedReasonProcessServerNoHeartbeat), + string(AgentUpgradeBlockedReasonRcmProxyNoHeartbeat), + string(AgentUpgradeBlockedReasonRebootRequired), + string(AgentUpgradeBlockedReasonUnknown), + string(AgentUpgradeBlockedReasonUnsupportedProtectionScenario), + } +} + +func (s *AgentUpgradeBlockedReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentUpgradeBlockedReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentUpgradeBlockedReason(input string) (*AgentUpgradeBlockedReason, error) { + vals := map[string]AgentUpgradeBlockedReason{ + "agentnoheartbeat": AgentUpgradeBlockedReasonAgentNoHeartbeat, + "alreadyonlatestversion": AgentUpgradeBlockedReasonAlreadyOnLatestVersion, + "distroisnotreported": AgentUpgradeBlockedReasonDistroIsNotReported, + "distronotsupportedforupgrade": AgentUpgradeBlockedReasonDistroNotSupportedForUpgrade, + "incompatibleapplianceversion": AgentUpgradeBlockedReasonIncompatibleApplianceVersion, + "invalidagentversion": AgentUpgradeBlockedReasonInvalidAgentVersion, + "invaliddriverversion": AgentUpgradeBlockedReasonInvalidDriverVersion, + "missingupgradepath": AgentUpgradeBlockedReasonMissingUpgradePath, + "notprotected": AgentUpgradeBlockedReasonNotProtected, + "processservernoheartbeat": AgentUpgradeBlockedReasonProcessServerNoHeartbeat, + "rcmproxynoheartbeat": AgentUpgradeBlockedReasonRcmProxyNoHeartbeat, + "rebootrequired": AgentUpgradeBlockedReasonRebootRequired, + "unknown": AgentUpgradeBlockedReasonUnknown, + "unsupportedprotectionscenario": AgentUpgradeBlockedReasonUnsupportedProtectionScenario, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentUpgradeBlockedReason(input) + return &out, nil +} + +type AutoProtectionOfDataDisk string + +const ( + AutoProtectionOfDataDiskDisabled AutoProtectionOfDataDisk = "Disabled" + AutoProtectionOfDataDiskEnabled AutoProtectionOfDataDisk = "Enabled" +) + +func PossibleValuesForAutoProtectionOfDataDisk() []string { + return []string{ + string(AutoProtectionOfDataDiskDisabled), + string(AutoProtectionOfDataDiskEnabled), + } +} + +func (s *AutoProtectionOfDataDisk) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoProtectionOfDataDisk(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoProtectionOfDataDisk(input string) (*AutoProtectionOfDataDisk, error) { + vals := map[string]AutoProtectionOfDataDisk{ + "disabled": AutoProtectionOfDataDiskDisabled, + "enabled": AutoProtectionOfDataDiskEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoProtectionOfDataDisk(input) + return &out, nil +} + +type ChurnOptionSelected string + +const ( + ChurnOptionSelectedHigh ChurnOptionSelected = "High" + ChurnOptionSelectedNormal ChurnOptionSelected = "Normal" +) + +func PossibleValuesForChurnOptionSelected() []string { + return []string{ + string(ChurnOptionSelectedHigh), + string(ChurnOptionSelectedNormal), + } +} + +func (s *ChurnOptionSelected) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseChurnOptionSelected(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseChurnOptionSelected(input string) (*ChurnOptionSelected, error) { + vals := map[string]ChurnOptionSelected{ + "high": ChurnOptionSelectedHigh, + "normal": ChurnOptionSelectedNormal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ChurnOptionSelected(input) + return &out, nil +} + +type DisableProtectionReason string + +const ( + DisableProtectionReasonMigrationComplete DisableProtectionReason = "MigrationComplete" + DisableProtectionReasonNotSpecified DisableProtectionReason = "NotSpecified" +) + +func PossibleValuesForDisableProtectionReason() []string { + return []string{ + string(DisableProtectionReasonMigrationComplete), + string(DisableProtectionReasonNotSpecified), + } +} + +func (s *DisableProtectionReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDisableProtectionReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDisableProtectionReason(input string) (*DisableProtectionReason, error) { + vals := map[string]DisableProtectionReason{ + "migrationcomplete": DisableProtectionReasonMigrationComplete, + "notspecified": DisableProtectionReasonNotSpecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DisableProtectionReason(input) + return &out, nil +} + +type DiskAccountType string + +const ( + DiskAccountTypePremiumLRS DiskAccountType = "Premium_LRS" + DiskAccountTypePremiumVTwoLRS DiskAccountType = "PremiumV2_LRS" + DiskAccountTypePremiumZRS DiskAccountType = "Premium_ZRS" + DiskAccountTypeStandardLRS DiskAccountType = "Standard_LRS" + DiskAccountTypeStandardSSDLRS DiskAccountType = "StandardSSD_LRS" + DiskAccountTypeStandardSSDZRS DiskAccountType = "StandardSSD_ZRS" + DiskAccountTypeUltraSSDLRS DiskAccountType = "UltraSSD_LRS" +) + +func PossibleValuesForDiskAccountType() []string { + return []string{ + string(DiskAccountTypePremiumLRS), + string(DiskAccountTypePremiumVTwoLRS), + string(DiskAccountTypePremiumZRS), + string(DiskAccountTypeStandardLRS), + string(DiskAccountTypeStandardSSDLRS), + string(DiskAccountTypeStandardSSDZRS), + string(DiskAccountTypeUltraSSDLRS), + } +} + +func (s *DiskAccountType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskAccountType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiskAccountType(input string) (*DiskAccountType, error) { + vals := map[string]DiskAccountType{ + "premium_lrs": DiskAccountTypePremiumLRS, + "premiumv2_lrs": DiskAccountTypePremiumVTwoLRS, + "premium_zrs": DiskAccountTypePremiumZRS, + "standard_lrs": DiskAccountTypeStandardLRS, + "standardssd_lrs": DiskAccountTypeStandardSSDLRS, + "standardssd_zrs": DiskAccountTypeStandardSSDZRS, + "ultrassd_lrs": DiskAccountTypeUltraSSDLRS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiskAccountType(input) + return &out, nil +} + +type DiskReplicationProgressHealth string + +const ( + DiskReplicationProgressHealthInProgress DiskReplicationProgressHealth = "InProgress" + DiskReplicationProgressHealthNoProgress DiskReplicationProgressHealth = "NoProgress" + DiskReplicationProgressHealthNone DiskReplicationProgressHealth = "None" + DiskReplicationProgressHealthQueued DiskReplicationProgressHealth = "Queued" + DiskReplicationProgressHealthSlowProgress DiskReplicationProgressHealth = "SlowProgress" +) + +func PossibleValuesForDiskReplicationProgressHealth() []string { + return []string{ + string(DiskReplicationProgressHealthInProgress), + string(DiskReplicationProgressHealthNoProgress), + string(DiskReplicationProgressHealthNone), + string(DiskReplicationProgressHealthQueued), + string(DiskReplicationProgressHealthSlowProgress), + } +} + +func (s *DiskReplicationProgressHealth) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskReplicationProgressHealth(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiskReplicationProgressHealth(input string) (*DiskReplicationProgressHealth, error) { + vals := map[string]DiskReplicationProgressHealth{ + "inprogress": DiskReplicationProgressHealthInProgress, + "noprogress": DiskReplicationProgressHealthNoProgress, + "none": DiskReplicationProgressHealthNone, + "queued": DiskReplicationProgressHealthQueued, + "slowprogress": DiskReplicationProgressHealthSlowProgress, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiskReplicationProgressHealth(input) + return &out, nil +} + +type DiskState string + +const ( + DiskStateInitialReplicationFailed DiskState = "InitialReplicationFailed" + DiskStateInitialReplicationPending DiskState = "InitialReplicationPending" + DiskStateProtected DiskState = "Protected" + DiskStateUnavailable DiskState = "Unavailable" +) + +func PossibleValuesForDiskState() []string { + return []string{ + string(DiskStateInitialReplicationFailed), + string(DiskStateInitialReplicationPending), + string(DiskStateProtected), + string(DiskStateUnavailable), + } +} + +func (s *DiskState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiskState(input string) (*DiskState, error) { + vals := map[string]DiskState{ + "initialreplicationfailed": DiskStateInitialReplicationFailed, + "initialreplicationpending": DiskStateInitialReplicationPending, + "protected": DiskStateProtected, + "unavailable": DiskStateUnavailable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiskState(input) + return &out, nil +} + +type EthernetAddressType string + +const ( + EthernetAddressTypeDynamic EthernetAddressType = "Dynamic" + EthernetAddressTypeStatic EthernetAddressType = "Static" +) + +func PossibleValuesForEthernetAddressType() []string { + return []string{ + string(EthernetAddressTypeDynamic), + string(EthernetAddressTypeStatic), + } +} + +func (s *EthernetAddressType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEthernetAddressType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEthernetAddressType(input string) (*EthernetAddressType, error) { + vals := map[string]EthernetAddressType{ + "dynamic": EthernetAddressTypeDynamic, + "static": EthernetAddressTypeStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EthernetAddressType(input) + return &out, nil +} + +type HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} + +type InMageRcmFailbackRecoveryPointType string + +const ( + InMageRcmFailbackRecoveryPointTypeApplicationConsistent InMageRcmFailbackRecoveryPointType = "ApplicationConsistent" + InMageRcmFailbackRecoveryPointTypeCrashConsistent InMageRcmFailbackRecoveryPointType = "CrashConsistent" +) + +func PossibleValuesForInMageRcmFailbackRecoveryPointType() []string { + return []string{ + string(InMageRcmFailbackRecoveryPointTypeApplicationConsistent), + string(InMageRcmFailbackRecoveryPointTypeCrashConsistent), + } +} + +func (s *InMageRcmFailbackRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInMageRcmFailbackRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInMageRcmFailbackRecoveryPointType(input string) (*InMageRcmFailbackRecoveryPointType, error) { + vals := map[string]InMageRcmFailbackRecoveryPointType{ + "applicationconsistent": InMageRcmFailbackRecoveryPointTypeApplicationConsistent, + "crashconsistent": InMageRcmFailbackRecoveryPointTypeCrashConsistent, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InMageRcmFailbackRecoveryPointType(input) + return &out, nil +} + +type LicenseType string + +const ( + LicenseTypeNoLicenseType LicenseType = "NoLicenseType" + LicenseTypeNotSpecified LicenseType = "NotSpecified" + LicenseTypeWindowsServer LicenseType = "WindowsServer" +) + +func PossibleValuesForLicenseType() []string { + return []string{ + string(LicenseTypeNoLicenseType), + string(LicenseTypeNotSpecified), + string(LicenseTypeWindowsServer), + } +} + +func (s *LicenseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLicenseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLicenseType(input string) (*LicenseType, error) { + vals := map[string]LicenseType{ + "nolicensetype": LicenseTypeNoLicenseType, + "notspecified": LicenseTypeNotSpecified, + "windowsserver": LicenseTypeWindowsServer, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LicenseType(input) + return &out, nil +} + +type LinuxLicenseType string + +const ( + LinuxLicenseTypeLinuxServer LinuxLicenseType = "LinuxServer" + LinuxLicenseTypeNoLicenseType LinuxLicenseType = "NoLicenseType" + LinuxLicenseTypeNotSpecified LinuxLicenseType = "NotSpecified" +) + +func PossibleValuesForLinuxLicenseType() []string { + return []string{ + string(LinuxLicenseTypeLinuxServer), + string(LinuxLicenseTypeNoLicenseType), + string(LinuxLicenseTypeNotSpecified), + } +} + +func (s *LinuxLicenseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLinuxLicenseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLinuxLicenseType(input string) (*LinuxLicenseType, error) { + vals := map[string]LinuxLicenseType{ + "linuxserver": LinuxLicenseTypeLinuxServer, + "nolicensetype": LinuxLicenseTypeNoLicenseType, + "notspecified": LinuxLicenseTypeNotSpecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LinuxLicenseType(input) + return &out, nil +} + +type MobilityAgentUpgradeState string + +const ( + MobilityAgentUpgradeStateCommit MobilityAgentUpgradeState = "Commit" + MobilityAgentUpgradeStateCompleted MobilityAgentUpgradeState = "Completed" + MobilityAgentUpgradeStateNone MobilityAgentUpgradeState = "None" + MobilityAgentUpgradeStateStarted MobilityAgentUpgradeState = "Started" +) + +func PossibleValuesForMobilityAgentUpgradeState() []string { + return []string{ + string(MobilityAgentUpgradeStateCommit), + string(MobilityAgentUpgradeStateCompleted), + string(MobilityAgentUpgradeStateNone), + string(MobilityAgentUpgradeStateStarted), + } +} + +func (s *MobilityAgentUpgradeState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMobilityAgentUpgradeState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMobilityAgentUpgradeState(input string) (*MobilityAgentUpgradeState, error) { + vals := map[string]MobilityAgentUpgradeState{ + "commit": MobilityAgentUpgradeStateCommit, + "completed": MobilityAgentUpgradeStateCompleted, + "none": MobilityAgentUpgradeStateNone, + "started": MobilityAgentUpgradeStateStarted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MobilityAgentUpgradeState(input) + return &out, nil +} + +type MultiVMGroupCreateOption string + +const ( + MultiVMGroupCreateOptionAutoCreated MultiVMGroupCreateOption = "AutoCreated" + MultiVMGroupCreateOptionUserSpecified MultiVMGroupCreateOption = "UserSpecified" +) + +func PossibleValuesForMultiVMGroupCreateOption() []string { + return []string{ + string(MultiVMGroupCreateOptionAutoCreated), + string(MultiVMGroupCreateOptionUserSpecified), + } +} + +func (s *MultiVMGroupCreateOption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMultiVMGroupCreateOption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMultiVMGroupCreateOption(input string) (*MultiVMGroupCreateOption, error) { + vals := map[string]MultiVMGroupCreateOption{ + "autocreated": MultiVMGroupCreateOptionAutoCreated, + "userspecified": MultiVMGroupCreateOptionUserSpecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MultiVMGroupCreateOption(input) + return &out, nil +} + +type PlannedFailoverStatus string + +const ( + PlannedFailoverStatusCancelled PlannedFailoverStatus = "Cancelled" + PlannedFailoverStatusFailed PlannedFailoverStatus = "Failed" + PlannedFailoverStatusSucceeded PlannedFailoverStatus = "Succeeded" + PlannedFailoverStatusUnknown PlannedFailoverStatus = "Unknown" +) + +func PossibleValuesForPlannedFailoverStatus() []string { + return []string{ + string(PlannedFailoverStatusCancelled), + string(PlannedFailoverStatusFailed), + string(PlannedFailoverStatusSucceeded), + string(PlannedFailoverStatusUnknown), + } +} + +func (s *PlannedFailoverStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePlannedFailoverStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePlannedFailoverStatus(input string) (*PlannedFailoverStatus, error) { + vals := map[string]PlannedFailoverStatus{ + "cancelled": PlannedFailoverStatusCancelled, + "failed": PlannedFailoverStatusFailed, + "succeeded": PlannedFailoverStatusSucceeded, + "unknown": PlannedFailoverStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PlannedFailoverStatus(input) + return &out, nil +} + +type RecoveryPointType string + +const ( + RecoveryPointTypeCustom RecoveryPointType = "Custom" + RecoveryPointTypeLatestTag RecoveryPointType = "LatestTag" + RecoveryPointTypeLatestTime RecoveryPointType = "LatestTime" +) + +func PossibleValuesForRecoveryPointType() []string { + return []string{ + string(RecoveryPointTypeCustom), + string(RecoveryPointTypeLatestTag), + string(RecoveryPointTypeLatestTime), + } +} + +func (s *RecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecoveryPointType(input string) (*RecoveryPointType, error) { + vals := map[string]RecoveryPointType{ + "custom": RecoveryPointTypeCustom, + "latesttag": RecoveryPointTypeLatestTag, + "latesttime": RecoveryPointTypeLatestTime, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointType(input) + return &out, nil +} + +type ResyncState string + +const ( + ResyncStateNone ResyncState = "None" + ResyncStatePreparedForResynchronization ResyncState = "PreparedForResynchronization" + ResyncStateStartedResynchronization ResyncState = "StartedResynchronization" +) + +func PossibleValuesForResyncState() []string { + return []string{ + string(ResyncStateNone), + string(ResyncStatePreparedForResynchronization), + string(ResyncStateStartedResynchronization), + } +} + +func (s *ResyncState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResyncState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResyncState(input string) (*ResyncState, error) { + vals := map[string]ResyncState{ + "none": ResyncStateNone, + "preparedforresynchronization": ResyncStatePreparedForResynchronization, + "startedresynchronization": ResyncStateStartedResynchronization, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResyncState(input) + return &out, nil +} + +type SecurityConfiguration string + +const ( + SecurityConfigurationDisabled SecurityConfiguration = "Disabled" + SecurityConfigurationEnabled SecurityConfiguration = "Enabled" +) + +func PossibleValuesForSecurityConfiguration() []string { + return []string{ + string(SecurityConfigurationDisabled), + string(SecurityConfigurationEnabled), + } +} + +func (s *SecurityConfiguration) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityConfiguration(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityConfiguration(input string) (*SecurityConfiguration, error) { + vals := map[string]SecurityConfiguration{ + "disabled": SecurityConfigurationDisabled, + "enabled": SecurityConfigurationEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityConfiguration(input) + return &out, nil +} + +type SecurityType string + +const ( + SecurityTypeConfidentialVM SecurityType = "ConfidentialVM" + SecurityTypeNone SecurityType = "None" + SecurityTypeTrustedLaunch SecurityType = "TrustedLaunch" +) + +func PossibleValuesForSecurityType() []string { + return []string{ + string(SecurityTypeConfidentialVM), + string(SecurityTypeNone), + string(SecurityTypeTrustedLaunch), + } +} + +func (s *SecurityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityType(input string) (*SecurityType, error) { + vals := map[string]SecurityType{ + "confidentialvm": SecurityTypeConfidentialVM, + "none": SecurityTypeNone, + "trustedlaunch": SecurityTypeTrustedLaunch, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityType(input) + return &out, nil +} + +type SqlServerLicenseType string + +const ( + SqlServerLicenseTypeAHUB SqlServerLicenseType = "AHUB" + SqlServerLicenseTypeNoLicenseType SqlServerLicenseType = "NoLicenseType" + SqlServerLicenseTypeNotSpecified SqlServerLicenseType = "NotSpecified" + SqlServerLicenseTypePAYG SqlServerLicenseType = "PAYG" +) + +func PossibleValuesForSqlServerLicenseType() []string { + return []string{ + string(SqlServerLicenseTypeAHUB), + string(SqlServerLicenseTypeNoLicenseType), + string(SqlServerLicenseTypeNotSpecified), + string(SqlServerLicenseTypePAYG), + } +} + +func (s *SqlServerLicenseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSqlServerLicenseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSqlServerLicenseType(input string) (*SqlServerLicenseType, error) { + vals := map[string]SqlServerLicenseType{ + "ahub": SqlServerLicenseTypeAHUB, + "nolicensetype": SqlServerLicenseTypeNoLicenseType, + "notspecified": SqlServerLicenseTypeNotSpecified, + "payg": SqlServerLicenseTypePAYG, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SqlServerLicenseType(input) + return &out, nil +} + +type VMEncryptionType string + +const ( + VMEncryptionTypeNotEncrypted VMEncryptionType = "NotEncrypted" + VMEncryptionTypeOnePassEncrypted VMEncryptionType = "OnePassEncrypted" + VMEncryptionTypeTwoPassEncrypted VMEncryptionType = "TwoPassEncrypted" +) + +func PossibleValuesForVMEncryptionType() []string { + return []string{ + string(VMEncryptionTypeNotEncrypted), + string(VMEncryptionTypeOnePassEncrypted), + string(VMEncryptionTypeTwoPassEncrypted), + } +} + +func (s *VMEncryptionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVMEncryptionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVMEncryptionType(input string) (*VMEncryptionType, error) { + vals := map[string]VMEncryptionType{ + "notencrypted": VMEncryptionTypeNotEncrypted, + "onepassencrypted": VMEncryptionTypeOnePassEncrypted, + "twopassencrypted": VMEncryptionTypeTwoPassEncrypted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VMEncryptionType(input) + return &out, nil +} + +type VMReplicationProgressHealth string + +const ( + VMReplicationProgressHealthInProgress VMReplicationProgressHealth = "InProgress" + VMReplicationProgressHealthNoProgress VMReplicationProgressHealth = "NoProgress" + VMReplicationProgressHealthNone VMReplicationProgressHealth = "None" + VMReplicationProgressHealthSlowProgress VMReplicationProgressHealth = "SlowProgress" +) + +func PossibleValuesForVMReplicationProgressHealth() []string { + return []string{ + string(VMReplicationProgressHealthInProgress), + string(VMReplicationProgressHealthNoProgress), + string(VMReplicationProgressHealthNone), + string(VMReplicationProgressHealthSlowProgress), + } +} + +func (s *VMReplicationProgressHealth) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVMReplicationProgressHealth(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVMReplicationProgressHealth(input string) (*VMReplicationProgressHealth, error) { + vals := map[string]VMReplicationProgressHealth{ + "inprogress": VMReplicationProgressHealthInProgress, + "noprogress": VMReplicationProgressHealthNoProgress, + "none": VMReplicationProgressHealthNone, + "slowprogress": VMReplicationProgressHealthSlowProgress, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VMReplicationProgressHealth(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/id_replicationprotecteditem.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/id_replicationprotecteditem.go new file mode 100644 index 00000000000..ec2c5d221c2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/id_replicationprotecteditem.go @@ -0,0 +1,157 @@ +package replicationprotecteditems + +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(&ReplicationProtectedItemId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectedItemId{} + +// ReplicationProtectedItemId is a struct representing the Resource ID for a Replication Protected Item +type ReplicationProtectedItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectedItemName string +} + +// NewReplicationProtectedItemID returns a new ReplicationProtectedItemId struct +func NewReplicationProtectedItemID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectedItemName string) ReplicationProtectedItemId { + return ReplicationProtectedItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectedItemName: replicationProtectedItemName, + } +} + +// ParseReplicationProtectedItemID parses 'input' into a ReplicationProtectedItemId +func ParseReplicationProtectedItemID(input string) (*ReplicationProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectedItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectedItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectedItemIDInsensitively parses 'input' case-insensitively into a ReplicationProtectedItemId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectedItemIDInsensitively(input string) (*ReplicationProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectedItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectedItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectedItemId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectedItemName, ok = input.Parsed["replicationProtectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectedItemName", input) + } + + return nil +} + +// ValidateReplicationProtectedItemID checks that 'input' can be parsed as a Replication Protected Item ID +func ValidateReplicationProtectedItemID(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 := ParseReplicationProtectedItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protected Item ID +func (id ReplicationProtectedItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectedItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectedItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protected Item ID +func (id ReplicationProtectedItemId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationProtectedItems", "replicationProtectedItems", "replicationProtectedItems"), + resourceids.UserSpecifiedSegment("replicationProtectedItemName", "replicationProtectedItemName"), + } +} + +// String returns a human-readable description of this Replication Protected Item ID +func (id ReplicationProtectedItemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protected Item Name: %q", id.ReplicationProtectedItemName), + } + return fmt.Sprintf("Replication Protected Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/id_replicationprotecteditem_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/id_replicationprotecteditem_test.go new file mode 100644 index 00000000000..af1be070147 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/id_replicationprotecteditem_test.go @@ -0,0 +1,417 @@ +package replicationprotecteditems + +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 = &ReplicationProtectedItemId{} + +func TestNewReplicationProtectedItemID(t *testing.T) { + id := NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationProtectedItemName != "replicationProtectedItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectedItemName'", id.ReplicationProtectedItemName, "replicationProtectedItemName") + } +} + +func TestFormatReplicationProtectedItemID(t *testing.T) { + actual := NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectedItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectedItemName: "replicationProtectedItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectedItemID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + } +} + +func TestParseReplicationProtectedItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectedItemName: "replicationProtectedItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMnAmE", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationProtectedItemName: "rEpLiCaTiOnPrOtEcTeDiTeMnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectedItemIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + } +} + +func TestSegmentsForReplicationProtectedItemId(t *testing.T) { + segments := ReplicationProtectedItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectedItemId 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/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/id_replicationprotectioncontainer.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/id_replicationprotectioncontainer.go new file mode 100644 index 00000000000..90d3e87f91d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/id_replicationprotectioncontainer.go @@ -0,0 +1,148 @@ +package replicationprotecteditems + +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(&ReplicationProtectionContainerId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectionContainerId{} + +// ReplicationProtectionContainerId is a struct representing the Resource ID for a Replication Protection Container +type ReplicationProtectionContainerId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string +} + +// NewReplicationProtectionContainerID returns a new ReplicationProtectionContainerId struct +func NewReplicationProtectionContainerID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string) ReplicationProtectionContainerId { + return ReplicationProtectionContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + } +} + +// ParseReplicationProtectionContainerID parses 'input' into a ReplicationProtectionContainerId +func ParseReplicationProtectionContainerID(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionContainerIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionContainerId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionContainerIDInsensitively(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionContainerId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + return nil +} + +// ValidateReplicationProtectionContainerID checks that 'input' can be parsed as a Replication Protection Container ID +func ValidateReplicationProtectionContainerID(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 := ParseReplicationProtectionContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Container ID +func (id ReplicationProtectionContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Container ID +func (id ReplicationProtectionContainerId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + } +} + +// String returns a human-readable description of this Replication Protection Container ID +func (id ReplicationProtectionContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + } + return fmt.Sprintf("Replication Protection Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/id_replicationprotectioncontainer_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/id_replicationprotectioncontainer_test.go new file mode 100644 index 00000000000..6a6c47d5d94 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/id_replicationprotectioncontainer_test.go @@ -0,0 +1,372 @@ +package replicationprotecteditems + +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 = &ReplicationProtectionContainerId{} + +func TestNewReplicationProtectionContainerID(t *testing.T) { + id := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } +} + +func TestFormatReplicationProtectionContainerID(t *testing.T) { + actual := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestParseReplicationProtectionContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestSegmentsForReplicationProtectionContainerId(t *testing.T) { + segments := ReplicationProtectionContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionContainerId 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/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/id_vault.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/id_vault.go new file mode 100644 index 00000000000..35eb0fa0277 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/id_vault.go @@ -0,0 +1,130 @@ +package replicationprotecteditems + +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(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(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 := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/id_vault_test.go new file mode 100644 index 00000000000..85390476d93 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationprotecteditems + +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 = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId 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/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_adddisks.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_adddisks.go new file mode 100644 index 00000000000..36621c48786 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_adddisks.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 AddDisksOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// AddDisks ... +func (c ReplicationProtectedItemsClient) AddDisks(ctx context.Context, id ReplicationProtectedItemId, input AddDisksInput) (result AddDisksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/addDisks", 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 +} + +// AddDisksThenPoll performs AddDisks then polls until it's completed +func (c ReplicationProtectedItemsClient) AddDisksThenPoll(ctx context.Context, id ReplicationProtectedItemId, input AddDisksInput) error { + result, err := c.AddDisks(ctx, id, input) + if err != nil { + return fmt.Errorf("performing AddDisks: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AddDisks: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_applyrecoverypoint.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_applyrecoverypoint.go new file mode 100644 index 00000000000..01aa0179078 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_applyrecoverypoint.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 ApplyRecoveryPointOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// ApplyRecoveryPoint ... +func (c ReplicationProtectedItemsClient) ApplyRecoveryPoint(ctx context.Context, id ReplicationProtectedItemId, input ApplyRecoveryPointInput) (result ApplyRecoveryPointOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/applyRecoveryPoint", 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 +} + +// ApplyRecoveryPointThenPoll performs ApplyRecoveryPoint then polls until it's completed +func (c ReplicationProtectedItemsClient) ApplyRecoveryPointThenPoll(ctx context.Context, id ReplicationProtectedItemId, input ApplyRecoveryPointInput) error { + result, err := c.ApplyRecoveryPoint(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ApplyRecoveryPoint: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ApplyRecoveryPoint: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_create.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_create.go new file mode 100644 index 00000000000..0058b44ea0f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_create.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// Create ... +func (c ReplicationProtectedItemsClient) Create(ctx context.Context, id ReplicationProtectedItemId, input EnableProtectionInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationProtectedItemsClient) CreateThenPoll(ctx context.Context, id ReplicationProtectedItemId, input EnableProtectionInput) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_delete.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_delete.go new file mode 100644 index 00000000000..6de58173ab5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_delete.go @@ -0,0 +1,74 @@ +package replicationprotecteditems + +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 ReplicationProtectedItemsClient) Delete(ctx context.Context, id ReplicationProtectedItemId, input DisableProtectionInput) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/remove", 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 +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ReplicationProtectedItemsClient) DeleteThenPoll(ctx context.Context, id ReplicationProtectedItemId, input DisableProtectionInput) error { + result, err := c.Delete(ctx, id, input) + 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/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_failovercancel.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_failovercancel.go new file mode 100644 index 00000000000..0232cdf2c30 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_failovercancel.go @@ -0,0 +1,71 @@ +package replicationprotecteditems + +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 FailoverCancelOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// FailoverCancel ... +func (c ReplicationProtectedItemsClient) FailoverCancel(ctx context.Context, id ReplicationProtectedItemId) (result FailoverCancelOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/failoverCancel", 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 +} + +// FailoverCancelThenPoll performs FailoverCancel then polls until it's completed +func (c ReplicationProtectedItemsClient) FailoverCancelThenPoll(ctx context.Context, id ReplicationProtectedItemId) error { + result, err := c.FailoverCancel(ctx, id) + if err != nil { + return fmt.Errorf("performing FailoverCancel: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after FailoverCancel: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_failovercommit.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_failovercommit.go new file mode 100644 index 00000000000..be595e3aeda --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_failovercommit.go @@ -0,0 +1,71 @@ +package replicationprotecteditems + +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 FailoverCommitOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// FailoverCommit ... +func (c ReplicationProtectedItemsClient) FailoverCommit(ctx context.Context, id ReplicationProtectedItemId) (result FailoverCommitOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/failoverCommit", 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 +} + +// FailoverCommitThenPoll performs FailoverCommit then polls until it's completed +func (c ReplicationProtectedItemsClient) FailoverCommitThenPoll(ctx context.Context, id ReplicationProtectedItemId) error { + result, err := c.FailoverCommit(ctx, id) + if err != nil { + return fmt.Errorf("performing FailoverCommit: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after FailoverCommit: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_get.go new file mode 100644 index 00000000000..5d46e4204f4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_get.go @@ -0,0 +1,53 @@ +package replicationprotecteditems + +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 *ReplicationProtectedItem +} + +// Get ... +func (c ReplicationProtectedItemsClient) Get(ctx context.Context, id ReplicationProtectedItemId) (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 ReplicationProtectedItem + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_list.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_list.go new file mode 100644 index 00000000000..5fe3f745f8f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_list.go @@ -0,0 +1,138 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReplicationProtectedItem +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ReplicationProtectedItem +} + +type ListOperationOptions struct { + Filter *string + SkipToken *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.SkipToken != nil { + out.Append("skipToken", fmt.Sprintf("%v", *o.SkipToken)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ReplicationProtectedItemsClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/replicationProtectedItems", 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 *[]ReplicationProtectedItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationProtectedItemsClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ReplicationProtectedItemOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectedItemsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate ReplicationProtectedItemOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ReplicationProtectedItem, 0) + + resp, err := c.List(ctx, id, options) + 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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_listbyreplicationprotectioncontainers.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_listbyreplicationprotectioncontainers.go new file mode 100644 index 00000000000..c51a013c266 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_listbyreplicationprotectioncontainers.go @@ -0,0 +1,105 @@ +package replicationprotecteditems + +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 ListByReplicationProtectionContainersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReplicationProtectedItem +} + +type ListByReplicationProtectionContainersCompleteResult struct { + LatestHttpResponse *http.Response + Items []ReplicationProtectedItem +} + +type ListByReplicationProtectionContainersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationProtectionContainersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationProtectionContainers ... +func (c ReplicationProtectedItemsClient) ListByReplicationProtectionContainers(ctx context.Context, id ReplicationProtectionContainerId) (result ListByReplicationProtectionContainersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationProtectionContainersCustomPager{}, + Path: fmt.Sprintf("%s/replicationProtectedItems", 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 *[]ReplicationProtectedItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationProtectionContainersComplete retrieves all the results into a single object +func (c ReplicationProtectedItemsClient) ListByReplicationProtectionContainersComplete(ctx context.Context, id ReplicationProtectionContainerId) (ListByReplicationProtectionContainersCompleteResult, error) { + return c.ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx, id, ReplicationProtectedItemOperationPredicate{}) +} + +// ListByReplicationProtectionContainersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectedItemsClient) ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx context.Context, id ReplicationProtectionContainerId, predicate ReplicationProtectedItemOperationPredicate) (result ListByReplicationProtectionContainersCompleteResult, err error) { + items := make([]ReplicationProtectedItem, 0) + + resp, err := c.ListByReplicationProtectionContainers(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 = ListByReplicationProtectionContainersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_plannedfailover.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_plannedfailover.go new file mode 100644 index 00000000000..12c98413547 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_plannedfailover.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 PlannedFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// PlannedFailover ... +func (c ReplicationProtectedItemsClient) PlannedFailover(ctx context.Context, id ReplicationProtectedItemId, input PlannedFailoverInput) (result PlannedFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/plannedFailover", 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 +} + +// PlannedFailoverThenPoll performs PlannedFailover then polls until it's completed +func (c ReplicationProtectedItemsClient) PlannedFailoverThenPoll(ctx context.Context, id ReplicationProtectedItemId, input PlannedFailoverInput) error { + result, err := c.PlannedFailover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PlannedFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PlannedFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_purge.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_purge.go new file mode 100644 index 00000000000..9917dd3997d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_purge.go @@ -0,0 +1,70 @@ +package replicationprotecteditems + +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 PurgeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Purge ... +func (c ReplicationProtectedItemsClient) Purge(ctx context.Context, id ReplicationProtectedItemId) (result PurgeOperationResponse, 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 +} + +// PurgeThenPoll performs Purge then polls until it's completed +func (c ReplicationProtectedItemsClient) PurgeThenPoll(ctx context.Context, id ReplicationProtectedItemId) error { + result, err := c.Purge(ctx, id) + if err != nil { + return fmt.Errorf("performing Purge: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Purge: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_removedisks.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_removedisks.go new file mode 100644 index 00000000000..13caa5a940e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_removedisks.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 RemoveDisksOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// RemoveDisks ... +func (c ReplicationProtectedItemsClient) RemoveDisks(ctx context.Context, id ReplicationProtectedItemId, input RemoveDisksInput) (result RemoveDisksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/removeDisks", 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 +} + +// RemoveDisksThenPoll performs RemoveDisks then polls until it's completed +func (c ReplicationProtectedItemsClient) RemoveDisksThenPoll(ctx context.Context, id ReplicationProtectedItemId, input RemoveDisksInput) error { + result, err := c.RemoveDisks(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RemoveDisks: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RemoveDisks: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_repairreplication.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_repairreplication.go new file mode 100644 index 00000000000..f755248eff3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_repairreplication.go @@ -0,0 +1,71 @@ +package replicationprotecteditems + +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 RepairReplicationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// RepairReplication ... +func (c ReplicationProtectedItemsClient) RepairReplication(ctx context.Context, id ReplicationProtectedItemId) (result RepairReplicationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/repairReplication", 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 +} + +// RepairReplicationThenPoll performs RepairReplication then polls until it's completed +func (c ReplicationProtectedItemsClient) RepairReplicationThenPoll(ctx context.Context, id ReplicationProtectedItemId) error { + result, err := c.RepairReplication(ctx, id) + if err != nil { + return fmt.Errorf("performing RepairReplication: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RepairReplication: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_reprotect.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_reprotect.go new file mode 100644 index 00000000000..3da5ec114b7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_reprotect.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 ReprotectOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// Reprotect ... +func (c ReplicationProtectedItemsClient) Reprotect(ctx context.Context, id ReplicationProtectedItemId, input ReverseReplicationInput) (result ReprotectOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reProtect", 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 +} + +// ReprotectThenPoll performs Reprotect then polls until it's completed +func (c ReplicationProtectedItemsClient) ReprotectThenPoll(ctx context.Context, id ReplicationProtectedItemId, input ReverseReplicationInput) error { + result, err := c.Reprotect(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Reprotect: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Reprotect: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_resolvehealtherrors.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_resolvehealtherrors.go new file mode 100644 index 00000000000..8d61f1ff79d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_resolvehealtherrors.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 ResolveHealthErrorsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// ResolveHealthErrors ... +func (c ReplicationProtectedItemsClient) ResolveHealthErrors(ctx context.Context, id ReplicationProtectedItemId, input ResolveHealthInput) (result ResolveHealthErrorsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resolveHealthErrors", 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 +} + +// ResolveHealthErrorsThenPoll performs ResolveHealthErrors then polls until it's completed +func (c ReplicationProtectedItemsClient) ResolveHealthErrorsThenPoll(ctx context.Context, id ReplicationProtectedItemId, input ResolveHealthInput) error { + result, err := c.ResolveHealthErrors(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ResolveHealthErrors: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ResolveHealthErrors: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_switchprovider.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_switchprovider.go new file mode 100644 index 00000000000..b49df7171d5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_switchprovider.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 SwitchProviderOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// SwitchProvider ... +func (c ReplicationProtectedItemsClient) SwitchProvider(ctx context.Context, id ReplicationProtectedItemId, input SwitchProviderInput) (result SwitchProviderOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/switchProvider", 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 +} + +// SwitchProviderThenPoll performs SwitchProvider then polls until it's completed +func (c ReplicationProtectedItemsClient) SwitchProviderThenPoll(ctx context.Context, id ReplicationProtectedItemId, input SwitchProviderInput) error { + result, err := c.SwitchProvider(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SwitchProvider: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SwitchProvider: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_testfailover.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_testfailover.go new file mode 100644 index 00000000000..b9e2751e6ab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_testfailover.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 TestFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// TestFailover ... +func (c ReplicationProtectedItemsClient) TestFailover(ctx context.Context, id ReplicationProtectedItemId, input TestFailoverInput) (result TestFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testFailover", 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 +} + +// TestFailoverThenPoll performs TestFailover then polls until it's completed +func (c ReplicationProtectedItemsClient) TestFailoverThenPoll(ctx context.Context, id ReplicationProtectedItemId, input TestFailoverInput) error { + result, err := c.TestFailover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TestFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TestFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_testfailovercleanup.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_testfailovercleanup.go new file mode 100644 index 00000000000..70adce69ef2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_testfailovercleanup.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 TestFailoverCleanupOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// TestFailoverCleanup ... +func (c ReplicationProtectedItemsClient) TestFailoverCleanup(ctx context.Context, id ReplicationProtectedItemId, input TestFailoverCleanupInput) (result TestFailoverCleanupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testFailoverCleanup", 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 +} + +// TestFailoverCleanupThenPoll performs TestFailoverCleanup then polls until it's completed +func (c ReplicationProtectedItemsClient) TestFailoverCleanupThenPoll(ctx context.Context, id ReplicationProtectedItemId, input TestFailoverCleanupInput) error { + result, err := c.TestFailoverCleanup(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TestFailoverCleanup: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TestFailoverCleanup: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_unplannedfailover.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_unplannedfailover.go new file mode 100644 index 00000000000..dce055d914d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_unplannedfailover.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 UnplannedFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// UnplannedFailover ... +func (c ReplicationProtectedItemsClient) UnplannedFailover(ctx context.Context, id ReplicationProtectedItemId, input UnplannedFailoverInput) (result UnplannedFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/unplannedFailover", 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 +} + +// UnplannedFailoverThenPoll performs UnplannedFailover then polls until it's completed +func (c ReplicationProtectedItemsClient) UnplannedFailoverThenPoll(ctx context.Context, id ReplicationProtectedItemId, input UnplannedFailoverInput) error { + result, err := c.UnplannedFailover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UnplannedFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UnplannedFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_update.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_update.go new file mode 100644 index 00000000000..2c21514383f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_update.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 *ReplicationProtectedItem +} + +// Update ... +func (c ReplicationProtectedItemsClient) Update(ctx context.Context, id ReplicationProtectedItemId, input UpdateReplicationProtectedItemInput) (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 ReplicationProtectedItemsClient) UpdateThenPoll(ctx context.Context, id ReplicationProtectedItemId, input UpdateReplicationProtectedItemInput) 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/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_updateappliance.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_updateappliance.go new file mode 100644 index 00000000000..e4dbc3fbd83 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_updateappliance.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 UpdateApplianceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// UpdateAppliance ... +func (c ReplicationProtectedItemsClient) UpdateAppliance(ctx context.Context, id ReplicationProtectedItemId, input UpdateApplianceForReplicationProtectedItemInput) (result UpdateApplianceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/updateAppliance", 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 +} + +// UpdateApplianceThenPoll performs UpdateAppliance then polls until it's completed +func (c ReplicationProtectedItemsClient) UpdateApplianceThenPoll(ctx context.Context, id ReplicationProtectedItemId, input UpdateApplianceForReplicationProtectedItemInput) error { + result, err := c.UpdateAppliance(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UpdateAppliance: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UpdateAppliance: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_updatemobilityservice.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_updatemobilityservice.go new file mode 100644 index 00000000000..36e2bbdfc24 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/method_updatemobilityservice.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 UpdateMobilityServiceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// UpdateMobilityService ... +func (c ReplicationProtectedItemsClient) UpdateMobilityService(ctx context.Context, id ReplicationProtectedItemId, input UpdateMobilityServiceRequest) (result UpdateMobilityServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/updateMobilityService", 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 +} + +// UpdateMobilityServiceThenPoll performs UpdateMobilityService then polls until it's completed +func (c ReplicationProtectedItemsClient) UpdateMobilityServiceThenPoll(ctx context.Context, id ReplicationProtectedItemId, input UpdateMobilityServiceRequest) error { + result, err := c.UpdateMobilityService(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UpdateMobilityService: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UpdateMobilityService: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aadddisksinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aadddisksinput.go new file mode 100644 index 00000000000..fee67d43e65 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aadddisksinput.go @@ -0,0 +1,51 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AddDisksProviderSpecificInput = A2AAddDisksInput{} + +type A2AAddDisksInput struct { + VMDisks *[]A2AVMDiskInputDetails `json:"vmDisks,omitempty"` + VMManagedDisks *[]A2AVMManagedDiskInputDetails `json:"vmManagedDisks,omitempty"` + + // Fields inherited from AddDisksProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AAddDisksInput) AddDisksProviderSpecificInput() BaseAddDisksProviderSpecificInputImpl { + return BaseAddDisksProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AAddDisksInput{} + +func (s A2AAddDisksInput) MarshalJSON() ([]byte, error) { + type wrapper A2AAddDisksInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AAddDisksInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AAddDisksInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AAddDisksInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aapplyrecoverypointinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aapplyrecoverypointinput.go new file mode 100644 index 00000000000..b119a4a2cb1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aapplyrecoverypointinput.go @@ -0,0 +1,49 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ApplyRecoveryPointProviderSpecificInput = A2AApplyRecoveryPointInput{} + +type A2AApplyRecoveryPointInput struct { + + // Fields inherited from ApplyRecoveryPointProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AApplyRecoveryPointInput) ApplyRecoveryPointProviderSpecificInput() BaseApplyRecoveryPointProviderSpecificInputImpl { + return BaseApplyRecoveryPointProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AApplyRecoveryPointInput{} + +func (s A2AApplyRecoveryPointInput) MarshalJSON() ([]byte, error) { + type wrapper A2AApplyRecoveryPointInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AApplyRecoveryPointInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AApplyRecoveryPointInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AApplyRecoveryPointInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2acrossclustermigrationapplyrecoverypointinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2acrossclustermigrationapplyrecoverypointinput.go new file mode 100644 index 00000000000..208b0ec18ba --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2acrossclustermigrationapplyrecoverypointinput.go @@ -0,0 +1,49 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ApplyRecoveryPointProviderSpecificInput = A2ACrossClusterMigrationApplyRecoveryPointInput{} + +type A2ACrossClusterMigrationApplyRecoveryPointInput struct { + + // Fields inherited from ApplyRecoveryPointProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2ACrossClusterMigrationApplyRecoveryPointInput) ApplyRecoveryPointProviderSpecificInput() BaseApplyRecoveryPointProviderSpecificInputImpl { + return BaseApplyRecoveryPointProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ACrossClusterMigrationApplyRecoveryPointInput{} + +func (s A2ACrossClusterMigrationApplyRecoveryPointInput) MarshalJSON() ([]byte, error) { + type wrapper A2ACrossClusterMigrationApplyRecoveryPointInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ACrossClusterMigrationApplyRecoveryPointInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ACrossClusterMigrationApplyRecoveryPointInput: %+v", err) + } + + decoded["instanceType"] = "A2ACrossClusterMigration" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ACrossClusterMigrationApplyRecoveryPointInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2acrossclustermigrationenableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2acrossclustermigrationenableprotectioninput.go new file mode 100644 index 00000000000..ee057b3e0c5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2acrossclustermigrationenableprotectioninput.go @@ -0,0 +1,51 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EnableProtectionProviderSpecificInput = A2ACrossClusterMigrationEnableProtectionInput{} + +type A2ACrossClusterMigrationEnableProtectionInput struct { + FabricObjectId *string `json:"fabricObjectId,omitempty"` + RecoveryContainerId *string `json:"recoveryContainerId,omitempty"` + + // Fields inherited from EnableProtectionProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2ACrossClusterMigrationEnableProtectionInput) EnableProtectionProviderSpecificInput() BaseEnableProtectionProviderSpecificInputImpl { + return BaseEnableProtectionProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ACrossClusterMigrationEnableProtectionInput{} + +func (s A2ACrossClusterMigrationEnableProtectionInput) MarshalJSON() ([]byte, error) { + type wrapper A2ACrossClusterMigrationEnableProtectionInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ACrossClusterMigrationEnableProtectionInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ACrossClusterMigrationEnableProtectionInput: %+v", err) + } + + decoded["instanceType"] = "A2ACrossClusterMigration" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ACrossClusterMigrationEnableProtectionInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2acrossclustermigrationreplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2acrossclustermigrationreplicationdetails.go new file mode 100644 index 00000000000..afc9553bcd0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2acrossclustermigrationreplicationdetails.go @@ -0,0 +1,55 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificSettings = A2ACrossClusterMigrationReplicationDetails{} + +type A2ACrossClusterMigrationReplicationDetails struct { + FabricObjectId *string `json:"fabricObjectId,omitempty"` + LifecycleId *string `json:"lifecycleId,omitempty"` + OsType *string `json:"osType,omitempty"` + PrimaryFabricLocation *string `json:"primaryFabricLocation,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s A2ACrossClusterMigrationReplicationDetails) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return BaseReplicationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ACrossClusterMigrationReplicationDetails{} + +func (s A2ACrossClusterMigrationReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper A2ACrossClusterMigrationReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ACrossClusterMigrationReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ACrossClusterMigrationReplicationDetails: %+v", err) + } + + decoded["instanceType"] = "A2ACrossClusterMigration" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ACrossClusterMigrationReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aenableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aenableprotectioninput.go new file mode 100644 index 00000000000..90a041ca1b2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aenableprotectioninput.go @@ -0,0 +1,71 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EnableProtectionProviderSpecificInput = A2AEnableProtectionInput{} + +type A2AEnableProtectionInput struct { + AutoProtectionOfDataDisk *AutoProtectionOfDataDisk `json:"autoProtectionOfDataDisk,omitempty"` + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + FabricObjectId string `json:"fabricObjectId"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + ProtectionClusterId *string `json:"protectionClusterId,omitempty"` + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + RecoveryAvailabilityZone *string `json:"recoveryAvailabilityZone,omitempty"` + RecoveryAzureNetworkId *string `json:"recoveryAzureNetworkId,omitempty"` + RecoveryBootDiagStorageAccountId *string `json:"recoveryBootDiagStorageAccountId,omitempty"` + RecoveryCapacityReservationGroupId *string `json:"recoveryCapacityReservationGroupId,omitempty"` + RecoveryCloudServiceId *string `json:"recoveryCloudServiceId,omitempty"` + RecoveryContainerId *string `json:"recoveryContainerId,omitempty"` + RecoveryExtendedLocation *edgezones.Model `json:"recoveryExtendedLocation,omitempty"` + RecoveryProximityPlacementGroupId *string `json:"recoveryProximityPlacementGroupId,omitempty"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + RecoverySubnetName *string `json:"recoverySubnetName,omitempty"` + RecoveryVirtualMachineScaleSetId *string `json:"recoveryVirtualMachineScaleSetId,omitempty"` + VMDisks *[]A2AVMDiskInputDetails `json:"vmDisks,omitempty"` + VMManagedDisks *[]A2AVMManagedDiskInputDetails `json:"vmManagedDisks,omitempty"` + + // Fields inherited from EnableProtectionProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AEnableProtectionInput) EnableProtectionProviderSpecificInput() BaseEnableProtectionProviderSpecificInputImpl { + return BaseEnableProtectionProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AEnableProtectionInput{} + +func (s A2AEnableProtectionInput) MarshalJSON() ([]byte, error) { + type wrapper A2AEnableProtectionInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AEnableProtectionInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AEnableProtectionInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AEnableProtectionInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aprotecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aprotecteddiskdetails.go new file mode 100644 index 00000000000..1f03409b8f6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aprotecteddiskdetails.go @@ -0,0 +1,30 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AProtectedDiskDetails struct { + AllowedDiskLevelOperation *[]string `json:"allowedDiskLevelOperation,omitempty"` + DataPendingAtSourceAgentInMB *float64 `json:"dataPendingAtSourceAgentInMB,omitempty"` + DataPendingInStagingStorageAccountInMB *float64 `json:"dataPendingInStagingStorageAccountInMB,omitempty"` + DekKeyVaultArmId *string `json:"dekKeyVaultArmId,omitempty"` + DiskCapacityInBytes *int64 `json:"diskCapacityInBytes,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskState *string `json:"diskState,omitempty"` + DiskType *string `json:"diskType,omitempty"` + DiskUri *string `json:"diskUri,omitempty"` + FailoverDiskName *string `json:"failoverDiskName,omitempty"` + IsDiskEncrypted *bool `json:"isDiskEncrypted,omitempty"` + IsDiskKeyEncrypted *bool `json:"isDiskKeyEncrypted,omitempty"` + KekKeyVaultArmId *string `json:"kekKeyVaultArmId,omitempty"` + KeyIdentifier *string `json:"keyIdentifier,omitempty"` + MonitoringJobType *string `json:"monitoringJobType,omitempty"` + MonitoringPercentageCompletion *int64 `json:"monitoringPercentageCompletion,omitempty"` + PrimaryDiskAzureStorageAccountId *string `json:"primaryDiskAzureStorageAccountId,omitempty"` + PrimaryStagingAzureStorageAccountId *string `json:"primaryStagingAzureStorageAccountId,omitempty"` + RecoveryAzureStorageAccountId *string `json:"recoveryAzureStorageAccountId,omitempty"` + RecoveryDiskUri *string `json:"recoveryDiskUri,omitempty"` + ResyncRequired *bool `json:"resyncRequired,omitempty"` + SecretIdentifier *string `json:"secretIdentifier,omitempty"` + TfoDiskName *string `json:"tfoDiskName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aprotectedmanageddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aprotectedmanageddiskdetails.go new file mode 100644 index 00000000000..f531b7431ce --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aprotectedmanageddiskdetails.go @@ -0,0 +1,35 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AProtectedManagedDiskDetails struct { + AllowedDiskLevelOperation *[]string `json:"allowedDiskLevelOperation,omitempty"` + DataPendingAtSourceAgentInMB *float64 `json:"dataPendingAtSourceAgentInMB,omitempty"` + DataPendingInStagingStorageAccountInMB *float64 `json:"dataPendingInStagingStorageAccountInMB,omitempty"` + DekKeyVaultArmId *string `json:"dekKeyVaultArmId,omitempty"` + DiskCapacityInBytes *int64 `json:"diskCapacityInBytes,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskState *string `json:"diskState,omitempty"` + DiskType *string `json:"diskType,omitempty"` + FailoverDiskName *string `json:"failoverDiskName,omitempty"` + IsDiskEncrypted *bool `json:"isDiskEncrypted,omitempty"` + IsDiskKeyEncrypted *bool `json:"isDiskKeyEncrypted,omitempty"` + KekKeyVaultArmId *string `json:"kekKeyVaultArmId,omitempty"` + KeyIdentifier *string `json:"keyIdentifier,omitempty"` + MonitoringJobType *string `json:"monitoringJobType,omitempty"` + MonitoringPercentageCompletion *int64 `json:"monitoringPercentageCompletion,omitempty"` + PrimaryDiskEncryptionSetId *string `json:"primaryDiskEncryptionSetId,omitempty"` + PrimaryStagingAzureStorageAccountId *string `json:"primaryStagingAzureStorageAccountId,omitempty"` + RecoveryDiskEncryptionSetId *string `json:"recoveryDiskEncryptionSetId,omitempty"` + RecoveryOrignalTargetDiskId *string `json:"recoveryOrignalTargetDiskId,omitempty"` + RecoveryReplicaDiskAccountType *string `json:"recoveryReplicaDiskAccountType,omitempty"` + RecoveryReplicaDiskId *string `json:"recoveryReplicaDiskId,omitempty"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + RecoveryTargetDiskAccountType *string `json:"recoveryTargetDiskAccountType,omitempty"` + RecoveryTargetDiskId *string `json:"recoveryTargetDiskId,omitempty"` + ResyncRequired *bool `json:"resyncRequired,omitempty"` + SecretIdentifier *string `json:"secretIdentifier,omitempty"` + TfoDiskName *string `json:"tfoDiskName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aremovedisksinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aremovedisksinput.go new file mode 100644 index 00000000000..b5f9961fdfc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aremovedisksinput.go @@ -0,0 +1,51 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RemoveDisksProviderSpecificInput = A2ARemoveDisksInput{} + +type A2ARemoveDisksInput struct { + VMDisksUris *[]string `json:"vmDisksUris,omitempty"` + VMManagedDisksIds *[]string `json:"vmManagedDisksIds,omitempty"` + + // Fields inherited from RemoveDisksProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2ARemoveDisksInput) RemoveDisksProviderSpecificInput() BaseRemoveDisksProviderSpecificInputImpl { + return BaseRemoveDisksProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ARemoveDisksInput{} + +func (s A2ARemoveDisksInput) MarshalJSON() ([]byte, error) { + type wrapper A2ARemoveDisksInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ARemoveDisksInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ARemoveDisksInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ARemoveDisksInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2areplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2areplicationdetails.go new file mode 100644 index 00000000000..11126570f85 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2areplicationdetails.go @@ -0,0 +1,107 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificSettings = A2AReplicationDetails{} + +type A2AReplicationDetails struct { + AgentCertificateExpiryDate *string `json:"agentCertificateExpiryDate,omitempty"` + AgentExpiryDate *string `json:"agentExpiryDate,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + AutoProtectionOfDataDisk *AutoProtectionOfDataDisk `json:"autoProtectionOfDataDisk,omitempty"` + ChurnOptionSelected *ChurnOptionSelected `json:"churnOptionSelected,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + InitialPrimaryExtendedLocation *edgezones.Model `json:"initialPrimaryExtendedLocation,omitempty"` + InitialPrimaryFabricLocation *string `json:"initialPrimaryFabricLocation,omitempty"` + InitialPrimaryZone *string `json:"initialPrimaryZone,omitempty"` + InitialRecoveryExtendedLocation *edgezones.Model `json:"initialRecoveryExtendedLocation,omitempty"` + InitialRecoveryFabricLocation *string `json:"initialRecoveryFabricLocation,omitempty"` + InitialRecoveryZone *string `json:"initialRecoveryZone,omitempty"` + IsClusterInfraReady *bool `json:"isClusterInfraReady,omitempty"` + IsReplicationAgentCertificateUpdateRequired *bool `json:"isReplicationAgentCertificateUpdateRequired,omitempty"` + IsReplicationAgentUpdateRequired *bool `json:"isReplicationAgentUpdateRequired,omitempty"` + LastHeartbeat *string `json:"lastHeartbeat,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + LifecycleId *string `json:"lifecycleId,omitempty"` + ManagementId *string `json:"managementId,omitempty"` + MonitoringJobType *string `json:"monitoringJobType,omitempty"` + MonitoringPercentageCompletion *int64 `json:"monitoringPercentageCompletion,omitempty"` + MultiVMGroupCreateOption *MultiVMGroupCreateOption `json:"multiVmGroupCreateOption,omitempty"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + OsType *string `json:"osType,omitempty"` + PrimaryAvailabilityZone *string `json:"primaryAvailabilityZone,omitempty"` + PrimaryExtendedLocation *edgezones.Model `json:"primaryExtendedLocation,omitempty"` + PrimaryFabricLocation *string `json:"primaryFabricLocation,omitempty"` + ProtectedDisks *[]A2AProtectedDiskDetails `json:"protectedDisks,omitempty"` + ProtectedManagedDisks *[]A2AProtectedManagedDiskDetails `json:"protectedManagedDisks,omitempty"` + ProtectionClusterId *string `json:"protectionClusterId,omitempty"` + RecoveryAvailabilitySet *string `json:"recoveryAvailabilitySet,omitempty"` + RecoveryAvailabilityZone *string `json:"recoveryAvailabilityZone,omitempty"` + RecoveryAzureGeneration *string `json:"recoveryAzureGeneration,omitempty"` + RecoveryAzureResourceGroupId *string `json:"recoveryAzureResourceGroupId,omitempty"` + RecoveryAzureVMName *string `json:"recoveryAzureVMName,omitempty"` + RecoveryAzureVMSize *string `json:"recoveryAzureVMSize,omitempty"` + RecoveryBootDiagStorageAccountId *string `json:"recoveryBootDiagStorageAccountId,omitempty"` + RecoveryCapacityReservationGroupId *string `json:"recoveryCapacityReservationGroupId,omitempty"` + RecoveryCloudService *string `json:"recoveryCloudService,omitempty"` + RecoveryExtendedLocation *edgezones.Model `json:"recoveryExtendedLocation,omitempty"` + RecoveryFabricLocation *string `json:"recoveryFabricLocation,omitempty"` + RecoveryFabricObjectId *string `json:"recoveryFabricObjectId,omitempty"` + RecoveryProximityPlacementGroupId *string `json:"recoveryProximityPlacementGroupId,omitempty"` + RecoveryVirtualMachineScaleSetId *string `json:"recoveryVirtualMachineScaleSetId,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + SelectedRecoveryAzureNetworkId *string `json:"selectedRecoveryAzureNetworkId,omitempty"` + SelectedTfoAzureNetworkId *string `json:"selectedTfoAzureNetworkId,omitempty"` + TestFailoverRecoveryFabricObjectId *string `json:"testFailoverRecoveryFabricObjectId,omitempty"` + TfoAzureVMName *string `json:"tfoAzureVMName,omitempty"` + UnprotectedDisks *[]A2AUnprotectedDiskDetails `json:"unprotectedDisks,omitempty"` + VMEncryptionType *VMEncryptionType `json:"vmEncryptionType,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + VMSyncedConfigDetails *AzureToAzureVMSyncedConfigDetails `json:"vmSyncedConfigDetails,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s A2AReplicationDetails) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return BaseReplicationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AReplicationDetails{} + +func (s A2AReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper A2AReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AReplicationDetails: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2areprotectinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2areprotectinput.go new file mode 100644 index 00000000000..a4d37006651 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2areprotectinput.go @@ -0,0 +1,55 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReverseReplicationProviderSpecificInput = A2AReprotectInput{} + +type A2AReprotectInput struct { + PolicyId *string `json:"policyId,omitempty"` + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + RecoveryCloudServiceId *string `json:"recoveryCloudServiceId,omitempty"` + RecoveryContainerId *string `json:"recoveryContainerId,omitempty"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + VMDisks *[]A2AVMDiskInputDetails `json:"vmDisks,omitempty"` + + // Fields inherited from ReverseReplicationProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AReprotectInput) ReverseReplicationProviderSpecificInput() BaseReverseReplicationProviderSpecificInputImpl { + return BaseReverseReplicationProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AReprotectInput{} + +func (s A2AReprotectInput) MarshalJSON() ([]byte, error) { + type wrapper A2AReprotectInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AReprotectInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AReprotectInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AReprotectInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2atestfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2atestfailoverinput.go new file mode 100644 index 00000000000..40bfb26f8a7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2atestfailoverinput.go @@ -0,0 +1,51 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TestFailoverProviderSpecificInput = A2ATestFailoverInput{} + +type A2ATestFailoverInput struct { + CloudServiceCreationOption *string `json:"cloudServiceCreationOption,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + + // Fields inherited from TestFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2ATestFailoverInput) TestFailoverProviderSpecificInput() BaseTestFailoverProviderSpecificInputImpl { + return BaseTestFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ATestFailoverInput{} + +func (s A2ATestFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper A2ATestFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ATestFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ATestFailoverInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ATestFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aunplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aunplannedfailoverinput.go new file mode 100644 index 00000000000..2248e7c8354 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aunplannedfailoverinput.go @@ -0,0 +1,51 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ UnplannedFailoverProviderSpecificInput = A2AUnplannedFailoverInput{} + +type A2AUnplannedFailoverInput struct { + CloudServiceCreationOption *string `json:"cloudServiceCreationOption,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + + // Fields inherited from UnplannedFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AUnplannedFailoverInput) UnplannedFailoverProviderSpecificInput() BaseUnplannedFailoverProviderSpecificInputImpl { + return BaseUnplannedFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AUnplannedFailoverInput{} + +func (s A2AUnplannedFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper A2AUnplannedFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AUnplannedFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AUnplannedFailoverInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AUnplannedFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aunprotecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aunprotecteddiskdetails.go new file mode 100644 index 00000000000..e0a224a5724 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aunprotecteddiskdetails.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AUnprotectedDiskDetails struct { + DiskAutoProtectionStatus *AutoProtectionOfDataDisk `json:"diskAutoProtectionStatus,omitempty"` + DiskLunId *int64 `json:"diskLunId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aupdatereplicationprotectediteminput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aupdatereplicationprotectediteminput.go new file mode 100644 index 00000000000..aae1b7f832e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2aupdatereplicationprotectediteminput.go @@ -0,0 +1,58 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ UpdateReplicationProtectedItemProviderInput = A2AUpdateReplicationProtectedItemInput{} + +type A2AUpdateReplicationProtectedItemInput struct { + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + ManagedDiskUpdateDetails *[]A2AVMManagedDiskUpdateDetails `json:"managedDiskUpdateDetails,omitempty"` + RecoveryBootDiagStorageAccountId *string `json:"recoveryBootDiagStorageAccountId,omitempty"` + RecoveryCapacityReservationGroupId *string `json:"recoveryCapacityReservationGroupId,omitempty"` + RecoveryCloudServiceId *string `json:"recoveryCloudServiceId,omitempty"` + RecoveryProximityPlacementGroupId *string `json:"recoveryProximityPlacementGroupId,omitempty"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + RecoveryVirtualMachineScaleSetId *string `json:"recoveryVirtualMachineScaleSetId,omitempty"` + TfoAzureVMName *string `json:"tfoAzureVMName,omitempty"` + + // Fields inherited from UpdateReplicationProtectedItemProviderInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AUpdateReplicationProtectedItemInput) UpdateReplicationProtectedItemProviderInput() BaseUpdateReplicationProtectedItemProviderInputImpl { + return BaseUpdateReplicationProtectedItemProviderInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AUpdateReplicationProtectedItemInput{} + +func (s A2AUpdateReplicationProtectedItemInput) MarshalJSON() ([]byte, error) { + type wrapper A2AUpdateReplicationProtectedItemInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AUpdateReplicationProtectedItemInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AUpdateReplicationProtectedItemInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AUpdateReplicationProtectedItemInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2avmdiskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2avmdiskinputdetails.go new file mode 100644 index 00000000000..c7aef1ff04a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2avmdiskinputdetails.go @@ -0,0 +1,10 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AVMDiskInputDetails struct { + DiskUri string `json:"diskUri"` + PrimaryStagingAzureStorageAccountId string `json:"primaryStagingAzureStorageAccountId"` + RecoveryAzureStorageAccountId string `json:"recoveryAzureStorageAccountId"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2avmmanageddiskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2avmmanageddiskinputdetails.go new file mode 100644 index 00000000000..d233d499b30 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2avmmanageddiskinputdetails.go @@ -0,0 +1,14 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AVMManagedDiskInputDetails struct { + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + DiskId string `json:"diskId"` + PrimaryStagingAzureStorageAccountId string `json:"primaryStagingAzureStorageAccountId"` + RecoveryDiskEncryptionSetId *string `json:"recoveryDiskEncryptionSetId,omitempty"` + RecoveryReplicaDiskAccountType *string `json:"recoveryReplicaDiskAccountType,omitempty"` + RecoveryResourceGroupId string `json:"recoveryResourceGroupId"` + RecoveryTargetDiskAccountType *string `json:"recoveryTargetDiskAccountType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2avmmanageddiskupdatedetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2avmmanageddiskupdatedetails.go new file mode 100644 index 00000000000..a021eaff3de --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_a2avmmanageddiskupdatedetails.go @@ -0,0 +1,13 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AVMManagedDiskUpdateDetails struct { + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + DiskId *string `json:"diskId,omitempty"` + FailoverDiskName *string `json:"failoverDiskName,omitempty"` + RecoveryReplicaDiskAccountType *string `json:"recoveryReplicaDiskAccountType,omitempty"` + RecoveryTargetDiskAccountType *string `json:"recoveryTargetDiskAccountType,omitempty"` + TfoDiskName *string `json:"tfoDiskName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_adddisksinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_adddisksinput.go new file mode 100644 index 00000000000..fb324e0c8f7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_adddisksinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddDisksInput struct { + Properties *AddDisksInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_adddisksinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_adddisksinputproperties.go new file mode 100644 index 00000000000..b1f6c4bf18d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_adddisksinputproperties.go @@ -0,0 +1,33 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddDisksInputProperties struct { + ProviderSpecificDetails AddDisksProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &AddDisksInputProperties{} + +func (s *AddDisksInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AddDisksInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalAddDisksProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'AddDisksInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_adddisksproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_adddisksproviderspecificinput.go new file mode 100644 index 00000000000..c9d2aacc5fc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_adddisksproviderspecificinput.go @@ -0,0 +1,83 @@ +package replicationprotecteditems + +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 AddDisksProviderSpecificInput interface { + AddDisksProviderSpecificInput() BaseAddDisksProviderSpecificInputImpl +} + +var _ AddDisksProviderSpecificInput = BaseAddDisksProviderSpecificInputImpl{} + +type BaseAddDisksProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseAddDisksProviderSpecificInputImpl) AddDisksProviderSpecificInput() BaseAddDisksProviderSpecificInputImpl { + return s +} + +var _ AddDisksProviderSpecificInput = RawAddDisksProviderSpecificInputImpl{} + +// RawAddDisksProviderSpecificInputImpl 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 RawAddDisksProviderSpecificInputImpl struct { + addDisksProviderSpecificInput BaseAddDisksProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawAddDisksProviderSpecificInputImpl) AddDisksProviderSpecificInput() BaseAddDisksProviderSpecificInputImpl { + return s.addDisksProviderSpecificInput +} + +func UnmarshalAddDisksProviderSpecificInputImplementation(input []byte) (AddDisksProviderSpecificInput, 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 AddDisksProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AAddDisksInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AAddDisksInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmAddDisksInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmAddDisksInput: %+v", err) + } + return out, nil + } + + var parent BaseAddDisksProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseAddDisksProviderSpecificInputImpl: %+v", err) + } + + return RawAddDisksProviderSpecificInputImpl{ + addDisksProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_applyrecoverypointinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_applyrecoverypointinput.go new file mode 100644 index 00000000000..6ae39e3cd2f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_applyrecoverypointinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplyRecoveryPointInput struct { + Properties ApplyRecoveryPointInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_applyrecoverypointinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_applyrecoverypointinputproperties.go new file mode 100644 index 00000000000..dddab909551 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_applyrecoverypointinputproperties.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplyRecoveryPointInputProperties struct { + ProviderSpecificDetails ApplyRecoveryPointProviderSpecificInput `json:"providerSpecificDetails"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` +} + +var _ json.Unmarshaler = &ApplyRecoveryPointInputProperties{} + +func (s *ApplyRecoveryPointInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.RecoveryPointId = decoded.RecoveryPointId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ApplyRecoveryPointInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalApplyRecoveryPointProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ApplyRecoveryPointInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_applyrecoverypointproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_applyrecoverypointproviderspecificinput.go new file mode 100644 index 00000000000..cc3ce3c881f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_applyrecoverypointproviderspecificinput.go @@ -0,0 +1,107 @@ +package replicationprotecteditems + +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 ApplyRecoveryPointProviderSpecificInput interface { + ApplyRecoveryPointProviderSpecificInput() BaseApplyRecoveryPointProviderSpecificInputImpl +} + +var _ ApplyRecoveryPointProviderSpecificInput = BaseApplyRecoveryPointProviderSpecificInputImpl{} + +type BaseApplyRecoveryPointProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseApplyRecoveryPointProviderSpecificInputImpl) ApplyRecoveryPointProviderSpecificInput() BaseApplyRecoveryPointProviderSpecificInputImpl { + return s +} + +var _ ApplyRecoveryPointProviderSpecificInput = RawApplyRecoveryPointProviderSpecificInputImpl{} + +// RawApplyRecoveryPointProviderSpecificInputImpl 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 RawApplyRecoveryPointProviderSpecificInputImpl struct { + applyRecoveryPointProviderSpecificInput BaseApplyRecoveryPointProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawApplyRecoveryPointProviderSpecificInputImpl) ApplyRecoveryPointProviderSpecificInput() BaseApplyRecoveryPointProviderSpecificInputImpl { + return s.applyRecoveryPointProviderSpecificInput +} + +func UnmarshalApplyRecoveryPointProviderSpecificInputImplementation(input []byte) (ApplyRecoveryPointProviderSpecificInput, 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 ApplyRecoveryPointProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AApplyRecoveryPointInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AApplyRecoveryPointInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "A2ACrossClusterMigration") { + var out A2ACrossClusterMigrationApplyRecoveryPointInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ACrossClusterMigrationApplyRecoveryPointInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureApplyRecoveryPointInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureApplyRecoveryPointInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2ApplyRecoveryPointInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2ApplyRecoveryPointInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmApplyRecoveryPointInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmApplyRecoveryPointInput: %+v", err) + } + return out, nil + } + + var parent BaseApplyRecoveryPointProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseApplyRecoveryPointProviderSpecificInputImpl: %+v", err) + } + + return RawApplyRecoveryPointProviderSpecificInputImpl{ + applyRecoveryPointProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_azuretoazurevmsyncedconfigdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_azuretoazurevmsyncedconfigdetails.go new file mode 100644 index 00000000000..7632016e150 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_azuretoazurevmsyncedconfigdetails.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureToAzureVMSyncedConfigDetails struct { + InputEndpoints *[]InputEndpoint `json:"inputEndpoints,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_azurevmdiskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_azurevmdiskdetails.go new file mode 100644 index 00000000000..d2778fb03f3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_azurevmdiskdetails.go @@ -0,0 +1,17 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureVMDiskDetails struct { + CustomTargetDiskName *string `json:"customTargetDiskName,omitempty"` + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId *string `json:"diskId,omitempty"` + LunId *string `json:"lunId,omitempty"` + MaxSizeMB *string `json:"maxSizeMB,omitempty"` + TargetDiskLocation *string `json:"targetDiskLocation,omitempty"` + TargetDiskName *string `json:"targetDiskName,omitempty"` + VhdId *string `json:"vhdId,omitempty"` + VhdName *string `json:"vhdName,omitempty"` + VhdType *string `json:"vhdType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_currentscenariodetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_currentscenariodetails.go new file mode 100644 index 00000000000..af5783a8a50 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_currentscenariodetails.go @@ -0,0 +1,28 @@ +package replicationprotecteditems + +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 CurrentScenarioDetails struct { + JobId *string `json:"jobId,omitempty"` + ScenarioName *string `json:"scenarioName,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *CurrentScenarioDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CurrentScenarioDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_disableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_disableprotectioninput.go new file mode 100644 index 00000000000..c09eed86ccb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_disableprotectioninput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DisableProtectionInput struct { + Properties DisableProtectionInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_disableprotectioninputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_disableprotectioninputproperties.go new file mode 100644 index 00000000000..d451a95c96c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_disableprotectioninputproperties.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DisableProtectionInputProperties struct { + DisableProtectionReason *DisableProtectionReason `json:"disableProtectionReason,omitempty"` + ReplicationProviderInput DisableProtectionProviderSpecificInput `json:"replicationProviderInput"` +} + +var _ json.Unmarshaler = &DisableProtectionInputProperties{} + +func (s *DisableProtectionInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + DisableProtectionReason *DisableProtectionReason `json:"disableProtectionReason,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.DisableProtectionReason = decoded.DisableProtectionReason + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling DisableProtectionInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["replicationProviderInput"]; ok { + impl, err := UnmarshalDisableProtectionProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ReplicationProviderInput' for 'DisableProtectionInputProperties': %+v", err) + } + s.ReplicationProviderInput = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_disableprotectionproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_disableprotectionproviderspecificinput.go new file mode 100644 index 00000000000..ce187d71b83 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_disableprotectionproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 DisableProtectionProviderSpecificInput interface { + DisableProtectionProviderSpecificInput() BaseDisableProtectionProviderSpecificInputImpl +} + +var _ DisableProtectionProviderSpecificInput = BaseDisableProtectionProviderSpecificInputImpl{} + +type BaseDisableProtectionProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseDisableProtectionProviderSpecificInputImpl) DisableProtectionProviderSpecificInput() BaseDisableProtectionProviderSpecificInputImpl { + return s +} + +var _ DisableProtectionProviderSpecificInput = RawDisableProtectionProviderSpecificInputImpl{} + +// RawDisableProtectionProviderSpecificInputImpl 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 RawDisableProtectionProviderSpecificInputImpl struct { + disableProtectionProviderSpecificInput BaseDisableProtectionProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawDisableProtectionProviderSpecificInputImpl) DisableProtectionProviderSpecificInput() BaseDisableProtectionProviderSpecificInputImpl { + return s.disableProtectionProviderSpecificInput +} + +func UnmarshalDisableProtectionProviderSpecificInputImplementation(input []byte) (DisableProtectionProviderSpecificInput, 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 DisableProtectionProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "InMage") { + var out InMageDisableProtectionProviderSpecificInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageDisableProtectionProviderSpecificInput: %+v", err) + } + return out, nil + } + + var parent BaseDisableProtectionProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseDisableProtectionProviderSpecificInputImpl: %+v", err) + } + + return RawDisableProtectionProviderSpecificInputImpl{ + disableProtectionProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_diskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_diskdetails.go new file mode 100644 index 00000000000..f64e47bcb4c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_diskdetails.go @@ -0,0 +1,11 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskDetails struct { + MaxSizeMB *int64 `json:"maxSizeMB,omitempty"` + VhdId *string `json:"vhdId,omitempty"` + VhdName *string `json:"vhdName,omitempty"` + VhdType *string `json:"vhdType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_diskencryptioninfo.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_diskencryptioninfo.go new file mode 100644 index 00000000000..57df685211a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_diskencryptioninfo.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskEncryptionInfo struct { + DiskEncryptionKeyInfo *DiskEncryptionKeyInfo `json:"diskEncryptionKeyInfo,omitempty"` + KeyEncryptionKeyInfo *KeyEncryptionKeyInfo `json:"keyEncryptionKeyInfo,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_diskencryptionkeyinfo.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_diskencryptionkeyinfo.go new file mode 100644 index 00000000000..6ccd7c74d35 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_diskencryptionkeyinfo.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskEncryptionKeyInfo struct { + KeyVaultResourceArmId *string `json:"keyVaultResourceArmId,omitempty"` + SecretIdentifier *string `json:"secretIdentifier,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_enableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_enableprotectioninput.go new file mode 100644 index 00000000000..1fc5ffdfc7b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_enableprotectioninput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnableProtectionInput struct { + Properties *EnableProtectionInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_enableprotectioninputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_enableprotectioninputproperties.go new file mode 100644 index 00000000000..7993d8aa7cf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_enableprotectioninputproperties.go @@ -0,0 +1,45 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnableProtectionInputProperties struct { + PolicyId *string `json:"policyId,omitempty"` + ProtectableItemId *string `json:"protectableItemId,omitempty"` + ProviderSpecificDetails EnableProtectionProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &EnableProtectionInputProperties{} + +func (s *EnableProtectionInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + PolicyId *string `json:"policyId,omitempty"` + ProtectableItemId *string `json:"protectableItemId,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.PolicyId = decoded.PolicyId + s.ProtectableItemId = decoded.ProtectableItemId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling EnableProtectionInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalEnableProtectionProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'EnableProtectionInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_enableprotectionproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_enableprotectionproviderspecificinput.go new file mode 100644 index 00000000000..976ea1ce44f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_enableprotectionproviderspecificinput.go @@ -0,0 +1,115 @@ +package replicationprotecteditems + +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 EnableProtectionProviderSpecificInput interface { + EnableProtectionProviderSpecificInput() BaseEnableProtectionProviderSpecificInputImpl +} + +var _ EnableProtectionProviderSpecificInput = BaseEnableProtectionProviderSpecificInputImpl{} + +type BaseEnableProtectionProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseEnableProtectionProviderSpecificInputImpl) EnableProtectionProviderSpecificInput() BaseEnableProtectionProviderSpecificInputImpl { + return s +} + +var _ EnableProtectionProviderSpecificInput = RawEnableProtectionProviderSpecificInputImpl{} + +// RawEnableProtectionProviderSpecificInputImpl 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 RawEnableProtectionProviderSpecificInputImpl struct { + enableProtectionProviderSpecificInput BaseEnableProtectionProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawEnableProtectionProviderSpecificInputImpl) EnableProtectionProviderSpecificInput() BaseEnableProtectionProviderSpecificInputImpl { + return s.enableProtectionProviderSpecificInput +} + +func UnmarshalEnableProtectionProviderSpecificInputImplementation(input []byte) (EnableProtectionProviderSpecificInput, 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 EnableProtectionProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2ACrossClusterMigration") { + var out A2ACrossClusterMigrationEnableProtectionInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ACrossClusterMigrationEnableProtectionInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2AEnableProtectionInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AEnableProtectionInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureEnableProtectionInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureEnableProtectionInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2EnableProtectionInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2EnableProtectionInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out InMageEnableProtectionInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageEnableProtectionInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmEnableProtectionInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmEnableProtectionInput: %+v", err) + } + return out, nil + } + + var parent BaseEnableProtectionProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseEnableProtectionProviderSpecificInputImpl: %+v", err) + } + + return RawEnableProtectionProviderSpecificInputImpl{ + enableProtectionProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_healtherror.go new file mode 100644 index 00000000000..9b403536983 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationprotecteditems + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazureapplyrecoverypointinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazureapplyrecoverypointinput.go new file mode 100644 index 00000000000..12d33abedde --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazureapplyrecoverypointinput.go @@ -0,0 +1,51 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ApplyRecoveryPointProviderSpecificInput = HyperVReplicaAzureApplyRecoveryPointInput{} + +type HyperVReplicaAzureApplyRecoveryPointInput struct { + PrimaryKekCertificatePfx *string `json:"primaryKekCertificatePfx,omitempty"` + SecondaryKekCertificatePfx *string `json:"secondaryKekCertificatePfx,omitempty"` + + // Fields inherited from ApplyRecoveryPointProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzureApplyRecoveryPointInput) ApplyRecoveryPointProviderSpecificInput() BaseApplyRecoveryPointProviderSpecificInputImpl { + return BaseApplyRecoveryPointProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzureApplyRecoveryPointInput{} + +func (s HyperVReplicaAzureApplyRecoveryPointInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureApplyRecoveryPointInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureApplyRecoveryPointInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureApplyRecoveryPointInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureApplyRecoveryPointInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazurediskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazurediskinputdetails.go new file mode 100644 index 00000000000..907f9b0c0dd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazurediskinputdetails.go @@ -0,0 +1,12 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HyperVReplicaAzureDiskInputDetails struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskType *DiskAccountType `json:"diskType,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` + SectorSizeInBytes *int64 `json:"sectorSizeInBytes,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazureenableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazureenableprotectioninput.go new file mode 100644 index 00000000000..849a469b3df --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazureenableprotectioninput.go @@ -0,0 +1,80 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EnableProtectionProviderSpecificInput = HyperVReplicaAzureEnableProtectionInput{} + +type HyperVReplicaAzureEnableProtectionInput struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskType *DiskAccountType `json:"diskType,omitempty"` + DisksToInclude *[]string `json:"disksToInclude,omitempty"` + DisksToIncludeForManagedDisks *[]HyperVReplicaAzureDiskInputDetails `json:"disksToIncludeForManagedDisks,omitempty"` + EnableRdpOnTargetOption *string `json:"enableRdpOnTargetOption,omitempty"` + HvHostVMId *string `json:"hvHostVmId,omitempty"` + LicenseType *LicenseType `json:"licenseType,omitempty"` + LinuxLicenseType *LinuxLicenseType `json:"linuxLicenseType,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` + OsType *string `json:"osType,omitempty"` + SeedManagedDiskTags *map[string]string `json:"seedManagedDiskTags,omitempty"` + SqlServerLicenseType *SqlServerLicenseType `json:"sqlServerLicenseType,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetAzureNetworkId *string `json:"targetAzureNetworkId,omitempty"` + TargetAzureSubnetId *string `json:"targetAzureSubnetId,omitempty"` + TargetAzureV1ResourceGroupId *string `json:"targetAzureV1ResourceGroupId,omitempty"` + TargetAzureV2ResourceGroupId *string `json:"targetAzureV2ResourceGroupId,omitempty"` + TargetAzureVMName *string `json:"targetAzureVmName,omitempty"` + TargetManagedDiskTags *map[string]string `json:"targetManagedDiskTags,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetStorageAccountId *string `json:"targetStorageAccountId,omitempty"` + TargetVMSecurityProfile *SecurityProfileProperties `json:"targetVmSecurityProfile,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + UseManagedDisks *string `json:"useManagedDisks,omitempty"` + UseManagedDisksForReplication *string `json:"useManagedDisksForReplication,omitempty"` + UserSelectedOSName *string `json:"userSelectedOSName,omitempty"` + VhdId *string `json:"vhdId,omitempty"` + VirtualMachineName *string `json:"vmName,omitempty"` + + // Fields inherited from EnableProtectionProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzureEnableProtectionInput) EnableProtectionProviderSpecificInput() BaseEnableProtectionProviderSpecificInputImpl { + return BaseEnableProtectionProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzureEnableProtectionInput{} + +func (s HyperVReplicaAzureEnableProtectionInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureEnableProtectionInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureEnableProtectionInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureEnableProtectionInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureEnableProtectionInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazurefailbackproviderinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazurefailbackproviderinput.go new file mode 100644 index 00000000000..94d265f86a2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazurefailbackproviderinput.go @@ -0,0 +1,52 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PlannedFailoverProviderSpecificFailoverInput = HyperVReplicaAzureFailbackProviderInput{} + +type HyperVReplicaAzureFailbackProviderInput struct { + DataSyncOption *string `json:"dataSyncOption,omitempty"` + ProviderIdForAlternateRecovery *string `json:"providerIdForAlternateRecovery,omitempty"` + RecoveryVMCreationOption *string `json:"recoveryVmCreationOption,omitempty"` + + // Fields inherited from PlannedFailoverProviderSpecificFailoverInput + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzureFailbackProviderInput) PlannedFailoverProviderSpecificFailoverInput() BasePlannedFailoverProviderSpecificFailoverInputImpl { + return BasePlannedFailoverProviderSpecificFailoverInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzureFailbackProviderInput{} + +func (s HyperVReplicaAzureFailbackProviderInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureFailbackProviderInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureFailbackProviderInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureFailbackProviderInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzureFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureFailbackProviderInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazuremanageddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazuremanageddiskdetails.go new file mode 100644 index 00000000000..ba050c877ef --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazuremanageddiskdetails.go @@ -0,0 +1,13 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HyperVReplicaAzureManagedDiskDetails struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId *string `json:"diskId,omitempty"` + ReplicaDiskType *string `json:"replicaDiskType,omitempty"` + SectorSizeInBytes *int64 `json:"sectorSizeInBytes,omitempty"` + SeedManagedDiskId *string `json:"seedManagedDiskId,omitempty"` + TargetDiskAccountType *DiskAccountType `json:"targetDiskAccountType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazureplannedfailoverproviderinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazureplannedfailoverproviderinput.go new file mode 100644 index 00000000000..839fa291aea --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazureplannedfailoverproviderinput.go @@ -0,0 +1,53 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PlannedFailoverProviderSpecificFailoverInput = HyperVReplicaAzurePlannedFailoverProviderInput{} + +type HyperVReplicaAzurePlannedFailoverProviderInput struct { + OsUpgradeVersion *string `json:"osUpgradeVersion,omitempty"` + PrimaryKekCertificatePfx *string `json:"primaryKekCertificatePfx,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + SecondaryKekCertificatePfx *string `json:"secondaryKekCertificatePfx,omitempty"` + + // Fields inherited from PlannedFailoverProviderSpecificFailoverInput + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzurePlannedFailoverProviderInput) PlannedFailoverProviderSpecificFailoverInput() BasePlannedFailoverProviderSpecificFailoverInputImpl { + return BasePlannedFailoverProviderSpecificFailoverInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzurePlannedFailoverProviderInput{} + +func (s HyperVReplicaAzurePlannedFailoverProviderInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzurePlannedFailoverProviderInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzurePlannedFailoverProviderInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzurePlannedFailoverProviderInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzurePlannedFailoverProviderInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazurereplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazurereplicationdetails.go new file mode 100644 index 00000000000..65e383b091e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazurereplicationdetails.go @@ -0,0 +1,85 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificSettings = HyperVReplicaAzureReplicationDetails{} + +type HyperVReplicaAzureReplicationDetails struct { + AllAvailableOSUpgradeConfigurations *[]OSUpgradeSupportedVersions `json:"allAvailableOSUpgradeConfigurations,omitempty"` + AzureVMDiskDetails *[]AzureVMDiskDetails `json:"azureVmDiskDetails,omitempty"` + EnableRdpOnTargetOption *string `json:"enableRdpOnTargetOption,omitempty"` + Encryption *string `json:"encryption,omitempty"` + InitialReplicationDetails *InitialReplicationDetails `json:"initialReplicationDetails,omitempty"` + LastRecoveryPointReceived *string `json:"lastRecoveryPointReceived,omitempty"` + LastReplicatedTime *string `json:"lastReplicatedTime,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + LicenseType *string `json:"licenseType,omitempty"` + LinuxLicenseType *LinuxLicenseType `json:"linuxLicenseType,omitempty"` + OSDetails *OSDetails `json:"oSDetails,omitempty"` + ProtectedManagedDisks *[]HyperVReplicaAzureManagedDiskDetails `json:"protectedManagedDisks,omitempty"` + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + RecoveryAzureLogStorageAccountId *string `json:"recoveryAzureLogStorageAccountId,omitempty"` + RecoveryAzureResourceGroupId *string `json:"recoveryAzureResourceGroupId,omitempty"` + RecoveryAzureStorageAccount *string `json:"recoveryAzureStorageAccount,omitempty"` + RecoveryAzureVMName *string `json:"recoveryAzureVmName,omitempty"` + RecoveryAzureVMSize *string `json:"recoveryAzureVMSize,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + SeedManagedDiskTags *map[string]string `json:"seedManagedDiskTags,omitempty"` + SelectedRecoveryAzureNetworkId *string `json:"selectedRecoveryAzureNetworkId,omitempty"` + SelectedSourceNicId *string `json:"selectedSourceNicId,omitempty"` + SourceVMCPUCount *int64 `json:"sourceVmCpuCount,omitempty"` + SourceVMRamSizeInMB *int64 `json:"sourceVmRamSizeInMB,omitempty"` + SqlServerLicenseType *string `json:"sqlServerLicenseType,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetManagedDiskTags *map[string]string `json:"targetManagedDiskTags,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetVMSecurityProfile *SecurityProfileProperties `json:"targetVmSecurityProfile,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + UseManagedDisks *string `json:"useManagedDisks,omitempty"` + VMId *string `json:"vmId,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzureReplicationDetails) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return BaseReplicationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzureReplicationDetails{} + +func (s HyperVReplicaAzureReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureReplicationDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazurereprotectinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazurereprotectinput.go new file mode 100644 index 00000000000..9627e00f825 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazurereprotectinput.go @@ -0,0 +1,55 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReverseReplicationProviderSpecificInput = HyperVReplicaAzureReprotectInput{} + +type HyperVReplicaAzureReprotectInput struct { + HvHostVMId *string `json:"hvHostVmId,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` + OsType *string `json:"osType,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + VHDId *string `json:"vHDId,omitempty"` + VirtualMachineName *string `json:"vmName,omitempty"` + + // Fields inherited from ReverseReplicationProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzureReprotectInput) ReverseReplicationProviderSpecificInput() BaseReverseReplicationProviderSpecificInputImpl { + return BaseReverseReplicationProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzureReprotectInput{} + +func (s HyperVReplicaAzureReprotectInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureReprotectInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureReprotectInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureReprotectInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureReprotectInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazuretestfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazuretestfailoverinput.go new file mode 100644 index 00000000000..155efe538d3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazuretestfailoverinput.go @@ -0,0 +1,53 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TestFailoverProviderSpecificInput = HyperVReplicaAzureTestFailoverInput{} + +type HyperVReplicaAzureTestFailoverInput struct { + OsUpgradeVersion *string `json:"osUpgradeVersion,omitempty"` + PrimaryKekCertificatePfx *string `json:"primaryKekCertificatePfx,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + SecondaryKekCertificatePfx *string `json:"secondaryKekCertificatePfx,omitempty"` + + // Fields inherited from TestFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzureTestFailoverInput) TestFailoverProviderSpecificInput() BaseTestFailoverProviderSpecificInputImpl { + return BaseTestFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzureTestFailoverInput{} + +func (s HyperVReplicaAzureTestFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureTestFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureTestFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureTestFailoverInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureTestFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazureunplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazureunplannedfailoverinput.go new file mode 100644 index 00000000000..b0a3d75f455 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazureunplannedfailoverinput.go @@ -0,0 +1,52 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ UnplannedFailoverProviderSpecificInput = HyperVReplicaAzureUnplannedFailoverInput{} + +type HyperVReplicaAzureUnplannedFailoverInput struct { + PrimaryKekCertificatePfx *string `json:"primaryKekCertificatePfx,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + SecondaryKekCertificatePfx *string `json:"secondaryKekCertificatePfx,omitempty"` + + // Fields inherited from UnplannedFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzureUnplannedFailoverInput) UnplannedFailoverProviderSpecificInput() BaseUnplannedFailoverProviderSpecificInputImpl { + return BaseUnplannedFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzureUnplannedFailoverInput{} + +func (s HyperVReplicaAzureUnplannedFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureUnplannedFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureUnplannedFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureUnplannedFailoverInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureUnplannedFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazureupdatereplicationprotectediteminput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazureupdatereplicationprotectediteminput.go new file mode 100644 index 00000000000..bcfa9cac1fc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicaazureupdatereplicationprotectediteminput.go @@ -0,0 +1,62 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ UpdateReplicationProtectedItemProviderInput = HyperVReplicaAzureUpdateReplicationProtectedItemInput{} + +type HyperVReplicaAzureUpdateReplicationProtectedItemInput struct { + DiskIdToDiskEncryptionMap *map[string]string `json:"diskIdToDiskEncryptionMap,omitempty"` + LinuxLicenseType *LinuxLicenseType `json:"linuxLicenseType,omitempty"` + RecoveryAzureV1ResourceGroupId *string `json:"recoveryAzureV1ResourceGroupId,omitempty"` + RecoveryAzureV2ResourceGroupId *string `json:"recoveryAzureV2ResourceGroupId,omitempty"` + SqlServerLicenseType *SqlServerLicenseType `json:"sqlServerLicenseType,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetManagedDiskTags *map[string]string `json:"targetManagedDiskTags,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + UseManagedDisks *string `json:"useManagedDisks,omitempty"` + UserSelectedOSName *string `json:"userSelectedOSName,omitempty"` + VMDisks *[]UpdateDiskInput `json:"vmDisks,omitempty"` + + // Fields inherited from UpdateReplicationProtectedItemProviderInput + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzureUpdateReplicationProtectedItemInput) UpdateReplicationProtectedItemProviderInput() BaseUpdateReplicationProtectedItemProviderInputImpl { + return BaseUpdateReplicationProtectedItemProviderInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzureUpdateReplicationProtectedItemInput{} + +func (s HyperVReplicaAzureUpdateReplicationProtectedItemInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureUpdateReplicationProtectedItemInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureUpdateReplicationProtectedItemInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureUpdateReplicationProtectedItemInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureUpdateReplicationProtectedItemInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicabasereplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicabasereplicationdetails.go new file mode 100644 index 00000000000..e00c68803e4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicabasereplicationdetails.go @@ -0,0 +1,56 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificSettings = HyperVReplicaBaseReplicationDetails{} + +type HyperVReplicaBaseReplicationDetails struct { + InitialReplicationDetails *InitialReplicationDetails `json:"initialReplicationDetails,omitempty"` + LastReplicatedTime *string `json:"lastReplicatedTime,omitempty"` + VMDiskDetails *[]DiskDetails `json:"vMDiskDetails,omitempty"` + VMId *string `json:"vmId,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaBaseReplicationDetails) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return BaseReplicationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaBaseReplicationDetails{} + +func (s HyperVReplicaBaseReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaBaseReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaBaseReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaBaseReplicationDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaBaseReplicationDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaBaseReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicabluereplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicabluereplicationdetails.go new file mode 100644 index 00000000000..186d59debce --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicabluereplicationdetails.go @@ -0,0 +1,56 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificSettings = HyperVReplicaBlueReplicationDetails{} + +type HyperVReplicaBlueReplicationDetails struct { + InitialReplicationDetails *InitialReplicationDetails `json:"initialReplicationDetails,omitempty"` + LastReplicatedTime *string `json:"lastReplicatedTime,omitempty"` + VMDiskDetails *[]DiskDetails `json:"vMDiskDetails,omitempty"` + VMId *string `json:"vmId,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaBlueReplicationDetails) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return BaseReplicationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaBlueReplicationDetails{} + +func (s HyperVReplicaBlueReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaBlueReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaBlueReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaBlueReplicationDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplica2012R2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaBlueReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicareplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicareplicationdetails.go new file mode 100644 index 00000000000..979c2bca833 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_hypervreplicareplicationdetails.go @@ -0,0 +1,56 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificSettings = HyperVReplicaReplicationDetails{} + +type HyperVReplicaReplicationDetails struct { + InitialReplicationDetails *InitialReplicationDetails `json:"initialReplicationDetails,omitempty"` + LastReplicatedTime *string `json:"lastReplicatedTime,omitempty"` + VMDiskDetails *[]DiskDetails `json:"vMDiskDetails,omitempty"` + VMId *string `json:"vmId,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaReplicationDetails) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return BaseReplicationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaReplicationDetails{} + +func (s HyperVReplicaReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaReplicationDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplica2012" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_initialreplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_initialreplicationdetails.go new file mode 100644 index 00000000000..62fc3a51fc8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_initialreplicationdetails.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InitialReplicationDetails struct { + InitialReplicationProgressPercentage *string `json:"initialReplicationProgressPercentage,omitempty"` + InitialReplicationType *string `json:"initialReplicationType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageagentdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageagentdetails.go new file mode 100644 index 00000000000..f899ff2af9d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageagentdetails.go @@ -0,0 +1,29 @@ +package replicationprotecteditems + +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 InMageAgentDetails struct { + AgentExpiryDate *string `json:"agentExpiryDate,omitempty"` + AgentUpdateStatus *string `json:"agentUpdateStatus,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + PostUpdateRebootStatus *string `json:"postUpdateRebootStatus,omitempty"` +} + +func (o *InMageAgentDetails) GetAgentExpiryDateAsTime() (*time.Time, error) { + if o.AgentExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AgentExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageAgentDetails) SetAgentExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AgentExpiryDate = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2applyrecoverypointinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2applyrecoverypointinput.go new file mode 100644 index 00000000000..38010ccfe0d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2applyrecoverypointinput.go @@ -0,0 +1,49 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ApplyRecoveryPointProviderSpecificInput = InMageAzureV2ApplyRecoveryPointInput{} + +type InMageAzureV2ApplyRecoveryPointInput struct { + + // Fields inherited from ApplyRecoveryPointProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2ApplyRecoveryPointInput) ApplyRecoveryPointProviderSpecificInput() BaseApplyRecoveryPointProviderSpecificInputImpl { + return BaseApplyRecoveryPointProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2ApplyRecoveryPointInput{} + +func (s InMageAzureV2ApplyRecoveryPointInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2ApplyRecoveryPointInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2ApplyRecoveryPointInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2ApplyRecoveryPointInput: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2ApplyRecoveryPointInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2diskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2diskinputdetails.go new file mode 100644 index 00000000000..608f4030e29 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2diskinputdetails.go @@ -0,0 +1,11 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageAzureV2DiskInputDetails struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskType *DiskAccountType `json:"diskType,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2enableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2enableprotectioninput.go new file mode 100644 index 00000000000..d965ba09103 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2enableprotectioninput.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EnableProtectionProviderSpecificInput = InMageAzureV2EnableProtectionInput{} + +type InMageAzureV2EnableProtectionInput struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskType *DiskAccountType `json:"diskType,omitempty"` + DisksToInclude *[]InMageAzureV2DiskInputDetails `json:"disksToInclude,omitempty"` + EnableRdpOnTargetOption *string `json:"enableRdpOnTargetOption,omitempty"` + LicenseType *LicenseType `json:"licenseType,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` + MasterTargetId *string `json:"masterTargetId,omitempty"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + SeedManagedDiskTags *map[string]string `json:"seedManagedDiskTags,omitempty"` + SqlServerLicenseType *SqlServerLicenseType `json:"sqlServerLicenseType,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetAzureNetworkId *string `json:"targetAzureNetworkId,omitempty"` + TargetAzureSubnetId *string `json:"targetAzureSubnetId,omitempty"` + TargetAzureV1ResourceGroupId *string `json:"targetAzureV1ResourceGroupId,omitempty"` + TargetAzureV2ResourceGroupId *string `json:"targetAzureV2ResourceGroupId,omitempty"` + TargetAzureVMName *string `json:"targetAzureVmName,omitempty"` + TargetManagedDiskTags *map[string]string `json:"targetManagedDiskTags,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + + // Fields inherited from EnableProtectionProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2EnableProtectionInput) EnableProtectionProviderSpecificInput() BaseEnableProtectionProviderSpecificInputImpl { + return BaseEnableProtectionProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2EnableProtectionInput{} + +func (s InMageAzureV2EnableProtectionInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2EnableProtectionInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2EnableProtectionInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2EnableProtectionInput: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2EnableProtectionInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2manageddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2manageddiskdetails.go new file mode 100644 index 00000000000..3ee19942044 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2manageddiskdetails.go @@ -0,0 +1,12 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageAzureV2ManagedDiskDetails struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId *string `json:"diskId,omitempty"` + ReplicaDiskType *string `json:"replicaDiskType,omitempty"` + SeedManagedDiskId *string `json:"seedManagedDiskId,omitempty"` + TargetDiskName *string `json:"targetDiskName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2protecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2protecteddiskdetails.go new file mode 100644 index 00000000000..95a2304ffef --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2protecteddiskdetails.go @@ -0,0 +1,72 @@ +package replicationprotecteditems + +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 InMageAzureV2ProtectedDiskDetails struct { + DiskCapacityInBytes *int64 `json:"diskCapacityInBytes,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskResized *string `json:"diskResized,omitempty"` + FileSystemCapacityInBytes *int64 `json:"fileSystemCapacityInBytes,omitempty"` + HealthErrorCode *string `json:"healthErrorCode,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + ProgressHealth *string `json:"progressHealth,omitempty"` + ProgressStatus *string `json:"progressStatus,omitempty"` + ProtectionStage *string `json:"protectionStage,omitempty"` + PsDataInMegaBytes *float64 `json:"psDataInMegaBytes,omitempty"` + ResyncDurationInSeconds *int64 `json:"resyncDurationInSeconds,omitempty"` + ResyncLast15MinutesTransferredBytes *int64 `json:"resyncLast15MinutesTransferredBytes,omitempty"` + ResyncLastDataTransferTimeUTC *string `json:"resyncLastDataTransferTimeUTC,omitempty"` + ResyncProcessedBytes *int64 `json:"resyncProcessedBytes,omitempty"` + ResyncProgressPercentage *int64 `json:"resyncProgressPercentage,omitempty"` + ResyncRequired *string `json:"resyncRequired,omitempty"` + ResyncStartTime *string `json:"resyncStartTime,omitempty"` + ResyncTotalTransferredBytes *int64 `json:"resyncTotalTransferredBytes,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + SecondsToTakeSwitchProvider *int64 `json:"secondsToTakeSwitchProvider,omitempty"` + SourceDataInMegaBytes *float64 `json:"sourceDataInMegaBytes,omitempty"` + TargetDataInMegaBytes *float64 `json:"targetDataInMegaBytes,omitempty"` +} + +func (o *InMageAzureV2ProtectedDiskDetails) GetLastRpoCalculatedTimeAsTime() (*time.Time, error) { + if o.LastRpoCalculatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRpoCalculatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageAzureV2ProtectedDiskDetails) SetLastRpoCalculatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRpoCalculatedTime = &formatted +} + +func (o *InMageAzureV2ProtectedDiskDetails) GetResyncLastDataTransferTimeUTCAsTime() (*time.Time, error) { + if o.ResyncLastDataTransferTimeUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ResyncLastDataTransferTimeUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageAzureV2ProtectedDiskDetails) SetResyncLastDataTransferTimeUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ResyncLastDataTransferTimeUTC = &formatted +} + +func (o *InMageAzureV2ProtectedDiskDetails) GetResyncStartTimeAsTime() (*time.Time, error) { + if o.ResyncStartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ResyncStartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageAzureV2ProtectedDiskDetails) SetResyncStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ResyncStartTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2replicationdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2replicationdetails.go new file mode 100644 index 00000000000..f1927aace2c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2replicationdetails.go @@ -0,0 +1,119 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificSettings = InMageAzureV2ReplicationDetails{} + +type InMageAzureV2ReplicationDetails struct { + AgentExpiryDate *string `json:"agentExpiryDate,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + AllAvailableOSUpgradeConfigurations *[]OSUpgradeSupportedVersions `json:"allAvailableOSUpgradeConfigurations,omitempty"` + AzureVMDiskDetails *[]AzureVMDiskDetails `json:"azureVMDiskDetails,omitempty"` + AzureVMGeneration *string `json:"azureVmGeneration,omitempty"` + CompressedDataRateInMB *float64 `json:"compressedDataRateInMB,omitempty"` + DataStores *[]string `json:"datastores,omitempty"` + DiscoveryType *string `json:"discoveryType,omitempty"` + DiskResized *string `json:"diskResized,omitempty"` + EnableRdpOnTargetOption *string `json:"enableRdpOnTargetOption,omitempty"` + FirmwareType *string `json:"firmwareType,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InfrastructureVMId *string `json:"infrastructureVmId,omitempty"` + IsAdditionalStatsAvailable *bool `json:"isAdditionalStatsAvailable,omitempty"` + IsAgentUpdateRequired *string `json:"isAgentUpdateRequired,omitempty"` + IsRebootAfterUpdateRequired *string `json:"isRebootAfterUpdateRequired,omitempty"` + LastHeartbeat *string `json:"lastHeartbeat,omitempty"` + LastRecoveryPointReceived *string `json:"lastRecoveryPointReceived,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + LastUpdateReceivedTime *string `json:"lastUpdateReceivedTime,omitempty"` + LicenseType *string `json:"licenseType,omitempty"` + MasterTargetId *string `json:"masterTargetId,omitempty"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` + OsDiskId *string `json:"osDiskId,omitempty"` + OsName *string `json:"osName,omitempty"` + OsType *string `json:"osType,omitempty"` + OsVersion *string `json:"osVersion,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + ProcessServerName *string `json:"processServerName,omitempty"` + ProtectedDisks *[]InMageAzureV2ProtectedDiskDetails `json:"protectedDisks,omitempty"` + ProtectedManagedDisks *[]InMageAzureV2ManagedDiskDetails `json:"protectedManagedDisks,omitempty"` + ProtectionStage *string `json:"protectionStage,omitempty"` + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + RecoveryAzureLogStorageAccountId *string `json:"recoveryAzureLogStorageAccountId,omitempty"` + RecoveryAzureResourceGroupId *string `json:"recoveryAzureResourceGroupId,omitempty"` + RecoveryAzureStorageAccount *string `json:"recoveryAzureStorageAccount,omitempty"` + RecoveryAzureVMName *string `json:"recoveryAzureVMName,omitempty"` + RecoveryAzureVMSize *string `json:"recoveryAzureVMSize,omitempty"` + ReplicaId *string `json:"replicaId,omitempty"` + ResyncProgressPercentage *int64 `json:"resyncProgressPercentage,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + SeedManagedDiskTags *map[string]string `json:"seedManagedDiskTags,omitempty"` + SelectedRecoveryAzureNetworkId *string `json:"selectedRecoveryAzureNetworkId,omitempty"` + SelectedSourceNicId *string `json:"selectedSourceNicId,omitempty"` + SelectedTfoAzureNetworkId *string `json:"selectedTfoAzureNetworkId,omitempty"` + SourceVMCPUCount *int64 `json:"sourceVmCpuCount,omitempty"` + SourceVMRamSizeInMB *int64 `json:"sourceVmRamSizeInMB,omitempty"` + SqlServerLicenseType *string `json:"sqlServerLicenseType,omitempty"` + SupportedOSVersions *[]string `json:"supportedOSVersions,omitempty"` + SwitchProviderBlockingErrorDetails *[]InMageAzureV2SwitchProviderBlockingErrorDetails `json:"switchProviderBlockingErrorDetails,omitempty"` + SwitchProviderDetails *InMageAzureV2SwitchProviderDetails `json:"switchProviderDetails,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetManagedDiskTags *map[string]string `json:"targetManagedDiskTags,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetVMId *string `json:"targetVmId,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + TotalDataTransferred *int64 `json:"totalDataTransferred,omitempty"` + TotalProgressHealth *string `json:"totalProgressHealth,omitempty"` + UncompressedDataRateInMB *float64 `json:"uncompressedDataRateInMB,omitempty"` + UseManagedDisks *string `json:"useManagedDisks,omitempty"` + VCenterInfrastructureId *string `json:"vCenterInfrastructureId,omitempty"` + VMId *string `json:"vmId,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + ValidationErrors *[]HealthError `json:"validationErrors,omitempty"` + VhdName *string `json:"vhdName,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2ReplicationDetails) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return BaseReplicationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2ReplicationDetails{} + +func (s InMageAzureV2ReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2ReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2ReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2ReplicationDetails: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2ReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2reprotectinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2reprotectinput.go new file mode 100644 index 00000000000..81dd163dc48 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2reprotectinput.go @@ -0,0 +1,56 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReverseReplicationProviderSpecificInput = InMageAzureV2ReprotectInput{} + +type InMageAzureV2ReprotectInput struct { + DisksToInclude *[]string `json:"disksToInclude,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` + MasterTargetId *string `json:"masterTargetId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + + // Fields inherited from ReverseReplicationProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2ReprotectInput) ReverseReplicationProviderSpecificInput() BaseReverseReplicationProviderSpecificInputImpl { + return BaseReverseReplicationProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2ReprotectInput{} + +func (s InMageAzureV2ReprotectInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2ReprotectInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2ReprotectInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2ReprotectInput: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2ReprotectInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2switchproviderblockingerrordetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2switchproviderblockingerrordetails.go new file mode 100644 index 00000000000..d8507ad72aa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2switchproviderblockingerrordetails.go @@ -0,0 +1,13 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageAzureV2SwitchProviderBlockingErrorDetails struct { + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorMessageParameters *map[string]string `json:"errorMessageParameters,omitempty"` + ErrorTags *map[string]string `json:"errorTags,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2switchproviderdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2switchproviderdetails.go new file mode 100644 index 00000000000..5c6e64b3e06 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2switchproviderdetails.go @@ -0,0 +1,11 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageAzureV2SwitchProviderDetails struct { + TargetApplianceId *string `json:"targetApplianceId,omitempty"` + TargetFabricId *string `json:"targetFabricId,omitempty"` + TargetResourceId *string `json:"targetResourceId,omitempty"` + TargetVaultId *string `json:"targetVaultId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2switchproviderproviderinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2switchproviderproviderinput.go new file mode 100644 index 00000000000..15ae80129b4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2switchproviderproviderinput.go @@ -0,0 +1,52 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SwitchProviderProviderSpecificInput = InMageAzureV2SwitchProviderProviderInput{} + +type InMageAzureV2SwitchProviderProviderInput struct { + TargetApplianceID string `json:"targetApplianceID"` + TargetFabricID string `json:"targetFabricID"` + TargetVaultID string `json:"targetVaultID"` + + // Fields inherited from SwitchProviderProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2SwitchProviderProviderInput) SwitchProviderProviderSpecificInput() BaseSwitchProviderProviderSpecificInputImpl { + return BaseSwitchProviderProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2SwitchProviderProviderInput{} + +func (s InMageAzureV2SwitchProviderProviderInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2SwitchProviderProviderInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2SwitchProviderProviderInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2SwitchProviderProviderInput: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2SwitchProviderProviderInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2testfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2testfailoverinput.go new file mode 100644 index 00000000000..b44c5ce60d2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2testfailoverinput.go @@ -0,0 +1,51 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TestFailoverProviderSpecificInput = InMageAzureV2TestFailoverInput{} + +type InMageAzureV2TestFailoverInput struct { + OsUpgradeVersion *string `json:"osUpgradeVersion,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + + // Fields inherited from TestFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2TestFailoverInput) TestFailoverProviderSpecificInput() BaseTestFailoverProviderSpecificInputImpl { + return BaseTestFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2TestFailoverInput{} + +func (s InMageAzureV2TestFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2TestFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2TestFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2TestFailoverInput: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2TestFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2unplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2unplannedfailoverinput.go new file mode 100644 index 00000000000..5f99b8cb9ef --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2unplannedfailoverinput.go @@ -0,0 +1,51 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ UnplannedFailoverProviderSpecificInput = InMageAzureV2UnplannedFailoverInput{} + +type InMageAzureV2UnplannedFailoverInput struct { + OsUpgradeVersion *string `json:"osUpgradeVersion,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + + // Fields inherited from UnplannedFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2UnplannedFailoverInput) UnplannedFailoverProviderSpecificInput() BaseUnplannedFailoverProviderSpecificInputImpl { + return BaseUnplannedFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2UnplannedFailoverInput{} + +func (s InMageAzureV2UnplannedFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2UnplannedFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2UnplannedFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2UnplannedFailoverInput: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2UnplannedFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2updatereplicationprotectediteminput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2updatereplicationprotectediteminput.go new file mode 100644 index 00000000000..4a1f4a448d8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageazurev2updatereplicationprotectediteminput.go @@ -0,0 +1,59 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ UpdateReplicationProtectedItemProviderInput = InMageAzureV2UpdateReplicationProtectedItemInput{} + +type InMageAzureV2UpdateReplicationProtectedItemInput struct { + RecoveryAzureV1ResourceGroupId *string `json:"recoveryAzureV1ResourceGroupId,omitempty"` + RecoveryAzureV2ResourceGroupId *string `json:"recoveryAzureV2ResourceGroupId,omitempty"` + SqlServerLicenseType *SqlServerLicenseType `json:"sqlServerLicenseType,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetManagedDiskTags *map[string]string `json:"targetManagedDiskTags,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + UseManagedDisks *string `json:"useManagedDisks,omitempty"` + VMDisks *[]UpdateDiskInput `json:"vmDisks,omitempty"` + + // Fields inherited from UpdateReplicationProtectedItemProviderInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2UpdateReplicationProtectedItemInput) UpdateReplicationProtectedItemProviderInput() BaseUpdateReplicationProtectedItemProviderInputImpl { + return BaseUpdateReplicationProtectedItemProviderInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2UpdateReplicationProtectedItemInput{} + +func (s InMageAzureV2UpdateReplicationProtectedItemInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2UpdateReplicationProtectedItemInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2UpdateReplicationProtectedItemInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2UpdateReplicationProtectedItemInput: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2UpdateReplicationProtectedItemInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagedisableprotectionproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagedisableprotectionproviderspecificinput.go new file mode 100644 index 00000000000..9f9b8923881 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagedisableprotectionproviderspecificinput.go @@ -0,0 +1,50 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DisableProtectionProviderSpecificInput = InMageDisableProtectionProviderSpecificInput{} + +type InMageDisableProtectionProviderSpecificInput struct { + ReplicaVMDeletionStatus *string `json:"replicaVmDeletionStatus,omitempty"` + + // Fields inherited from DisableProtectionProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageDisableProtectionProviderSpecificInput) DisableProtectionProviderSpecificInput() BaseDisableProtectionProviderSpecificInputImpl { + return BaseDisableProtectionProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageDisableProtectionProviderSpecificInput{} + +func (s InMageDisableProtectionProviderSpecificInput) MarshalJSON() ([]byte, error) { + type wrapper InMageDisableProtectionProviderSpecificInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageDisableProtectionProviderSpecificInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageDisableProtectionProviderSpecificInput: %+v", err) + } + + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageDisableProtectionProviderSpecificInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagediskexclusioninput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagediskexclusioninput.go new file mode 100644 index 00000000000..f43893e5555 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagediskexclusioninput.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageDiskExclusionInput struct { + DiskSignatureOptions *[]InMageDiskSignatureExclusionOptions `json:"diskSignatureOptions,omitempty"` + VolumeOptions *[]InMageVolumeExclusionOptions `json:"volumeOptions,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagedisksignatureexclusionoptions.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagedisksignatureexclusionoptions.go new file mode 100644 index 00000000000..4668154b630 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagedisksignatureexclusionoptions.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageDiskSignatureExclusionOptions struct { + DiskSignature *string `json:"diskSignature,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageenableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageenableprotectioninput.go new file mode 100644 index 00000000000..ecb43d87f50 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageenableprotectioninput.go @@ -0,0 +1,59 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EnableProtectionProviderSpecificInput = InMageEnableProtectionInput{} + +type InMageEnableProtectionInput struct { + DatastoreName *string `json:"datastoreName,omitempty"` + DiskExclusionInput *InMageDiskExclusionInput `json:"diskExclusionInput,omitempty"` + DisksToInclude *[]string `json:"disksToInclude,omitempty"` + MasterTargetId string `json:"masterTargetId"` + MultiVMGroupId string `json:"multiVmGroupId"` + MultiVMGroupName string `json:"multiVmGroupName"` + ProcessServerId string `json:"processServerId"` + RetentionDrive string `json:"retentionDrive"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + VMFriendlyName *string `json:"vmFriendlyName,omitempty"` + + // Fields inherited from EnableProtectionProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageEnableProtectionInput) EnableProtectionProviderSpecificInput() BaseEnableProtectionProviderSpecificInputImpl { + return BaseEnableProtectionProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageEnableProtectionInput{} + +func (s InMageEnableProtectionInput) MarshalJSON() ([]byte, error) { + type wrapper InMageEnableProtectionInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageEnableProtectionInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageEnableProtectionInput: %+v", err) + } + + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageEnableProtectionInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageprotecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageprotecteddiskdetails.go new file mode 100644 index 00000000000..283ba9307e4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageprotecteddiskdetails.go @@ -0,0 +1,71 @@ +package replicationprotecteditems + +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 InMageProtectedDiskDetails struct { + DiskCapacityInBytes *int64 `json:"diskCapacityInBytes,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskResized *string `json:"diskResized,omitempty"` + FileSystemCapacityInBytes *int64 `json:"fileSystemCapacityInBytes,omitempty"` + HealthErrorCode *string `json:"healthErrorCode,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + ProgressHealth *string `json:"progressHealth,omitempty"` + ProgressStatus *string `json:"progressStatus,omitempty"` + ProtectionStage *string `json:"protectionStage,omitempty"` + PsDataInMB *float64 `json:"psDataInMB,omitempty"` + ResyncDurationInSeconds *int64 `json:"resyncDurationInSeconds,omitempty"` + ResyncLast15MinutesTransferredBytes *int64 `json:"resyncLast15MinutesTransferredBytes,omitempty"` + ResyncLastDataTransferTimeUTC *string `json:"resyncLastDataTransferTimeUTC,omitempty"` + ResyncProcessedBytes *int64 `json:"resyncProcessedBytes,omitempty"` + ResyncProgressPercentage *int64 `json:"resyncProgressPercentage,omitempty"` + ResyncRequired *string `json:"resyncRequired,omitempty"` + ResyncStartTime *string `json:"resyncStartTime,omitempty"` + ResyncTotalTransferredBytes *int64 `json:"resyncTotalTransferredBytes,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + SourceDataInMB *float64 `json:"sourceDataInMB,omitempty"` + TargetDataInMB *float64 `json:"targetDataInMB,omitempty"` +} + +func (o *InMageProtectedDiskDetails) GetLastRpoCalculatedTimeAsTime() (*time.Time, error) { + if o.LastRpoCalculatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRpoCalculatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageProtectedDiskDetails) SetLastRpoCalculatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRpoCalculatedTime = &formatted +} + +func (o *InMageProtectedDiskDetails) GetResyncLastDataTransferTimeUTCAsTime() (*time.Time, error) { + if o.ResyncLastDataTransferTimeUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ResyncLastDataTransferTimeUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageProtectedDiskDetails) SetResyncLastDataTransferTimeUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ResyncLastDataTransferTimeUTC = &formatted +} + +func (o *InMageProtectedDiskDetails) GetResyncStartTimeAsTime() (*time.Time, error) { + if o.ResyncStartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ResyncStartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageProtectedDiskDetails) SetResyncStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ResyncStartTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmadddisksinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmadddisksinput.go new file mode 100644 index 00000000000..91b0bc63cf5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmadddisksinput.go @@ -0,0 +1,50 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AddDisksProviderSpecificInput = InMageRcmAddDisksInput{} + +type InMageRcmAddDisksInput struct { + Disks []InMageRcmDiskInput `json:"disks"` + + // Fields inherited from AddDisksProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmAddDisksInput) AddDisksProviderSpecificInput() BaseAddDisksProviderSpecificInputImpl { + return BaseAddDisksProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmAddDisksInput{} + +func (s InMageRcmAddDisksInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmAddDisksInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmAddDisksInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmAddDisksInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmAddDisksInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmagentupgradeblockingerrordetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmagentupgradeblockingerrordetails.go new file mode 100644 index 00000000000..6235f92ce41 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmagentupgradeblockingerrordetails.go @@ -0,0 +1,13 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmAgentUpgradeBlockingErrorDetails struct { + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorMessageParameters *map[string]string `json:"errorMessageParameters,omitempty"` + ErrorTags *map[string]string `json:"errorTags,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmapplyrecoverypointinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmapplyrecoverypointinput.go new file mode 100644 index 00000000000..3f18666e7c5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmapplyrecoverypointinput.go @@ -0,0 +1,50 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ApplyRecoveryPointProviderSpecificInput = InMageRcmApplyRecoveryPointInput{} + +type InMageRcmApplyRecoveryPointInput struct { + RecoveryPointId string `json:"recoveryPointId"` + + // Fields inherited from ApplyRecoveryPointProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmApplyRecoveryPointInput) ApplyRecoveryPointProviderSpecificInput() BaseApplyRecoveryPointProviderSpecificInputImpl { + return BaseApplyRecoveryPointProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmApplyRecoveryPointInput{} + +func (s InMageRcmApplyRecoveryPointInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmApplyRecoveryPointInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmApplyRecoveryPointInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmApplyRecoveryPointInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmApplyRecoveryPointInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmdiscoveredprotectedvmdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmdiscoveredprotectedvmdetails.go new file mode 100644 index 00000000000..345e3b53683 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmdiscoveredprotectedvmdetails.go @@ -0,0 +1,61 @@ +package replicationprotecteditems + +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 InMageRcmDiscoveredProtectedVMDetails struct { + CreatedTimestamp *string `json:"createdTimestamp,omitempty"` + DataStores *[]string `json:"datastores,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` + IsDeleted *bool `json:"isDeleted,omitempty"` + LastDiscoveryTimeInUtc *string `json:"lastDiscoveryTimeInUtc,omitempty"` + OsName *string `json:"osName,omitempty"` + PowerStatus *string `json:"powerStatus,omitempty"` + UpdatedTimestamp *string `json:"updatedTimestamp,omitempty"` + VCenterFqdn *string `json:"vCenterFqdn,omitempty"` + VCenterId *string `json:"vCenterId,omitempty"` + VMFqdn *string `json:"vmFqdn,omitempty"` + VMwareToolsStatus *string `json:"vmwareToolsStatus,omitempty"` +} + +func (o *InMageRcmDiscoveredProtectedVMDetails) GetCreatedTimestampAsTime() (*time.Time, error) { + if o.CreatedTimestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTimestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmDiscoveredProtectedVMDetails) SetCreatedTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTimestamp = &formatted +} + +func (o *InMageRcmDiscoveredProtectedVMDetails) GetLastDiscoveryTimeInUtcAsTime() (*time.Time, error) { + if o.LastDiscoveryTimeInUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastDiscoveryTimeInUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmDiscoveredProtectedVMDetails) SetLastDiscoveryTimeInUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastDiscoveryTimeInUtc = &formatted +} + +func (o *InMageRcmDiscoveredProtectedVMDetails) GetUpdatedTimestampAsTime() (*time.Time, error) { + if o.UpdatedTimestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.UpdatedTimestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmDiscoveredProtectedVMDetails) SetUpdatedTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.UpdatedTimestamp = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmdiskinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmdiskinput.go new file mode 100644 index 00000000000..3e82fd2c7d4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmdiskinput.go @@ -0,0 +1,12 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmDiskInput struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId string `json:"diskId"` + DiskType DiskAccountType `json:"diskType"` + LogStorageAccountId string `json:"logStorageAccountId"` + SectorSizeInBytes *int64 `json:"sectorSizeInBytes,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmdisksdefaultinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmdisksdefaultinput.go new file mode 100644 index 00000000000..b74d47bf906 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmdisksdefaultinput.go @@ -0,0 +1,11 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmDisksDefaultInput struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskType DiskAccountType `json:"diskType"` + LogStorageAccountId string `json:"logStorageAccountId"` + SectorSizeInBytes *int64 `json:"sectorSizeInBytes,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmenableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmenableprotectioninput.go new file mode 100644 index 00000000000..d1b1cad972c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmenableprotectioninput.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EnableProtectionProviderSpecificInput = InMageRcmEnableProtectionInput{} + +type InMageRcmEnableProtectionInput struct { + DisksDefault *InMageRcmDisksDefaultInput `json:"disksDefault,omitempty"` + DisksToInclude *[]InMageRcmDiskInput `json:"disksToInclude,omitempty"` + FabricDiscoveryMachineId string `json:"fabricDiscoveryMachineId"` + LicenseType *LicenseType `json:"licenseType,omitempty"` + LinuxLicenseType *LinuxLicenseType `json:"linuxLicenseType,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + ProcessServerId string `json:"processServerId"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + SeedManagedDiskTags *[]UserCreatedResourceTag `json:"seedManagedDiskTags,omitempty"` + SqlServerLicenseType *SqlServerLicenseType `json:"sqlServerLicenseType,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetBootDiagnosticsStorageAccountId *string `json:"targetBootDiagnosticsStorageAccountId,omitempty"` + TargetManagedDiskTags *[]UserCreatedResourceTag `json:"targetManagedDiskTags,omitempty"` + TargetNetworkId *string `json:"targetNetworkId,omitempty"` + TargetNicTags *[]UserCreatedResourceTag `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetResourceGroupId string `json:"targetResourceGroupId"` + TargetSubnetName *string `json:"targetSubnetName,omitempty"` + TargetVMName *string `json:"targetVmName,omitempty"` + TargetVMSecurityProfile *SecurityProfileProperties `json:"targetVmSecurityProfile,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TargetVMTags *[]UserCreatedResourceTag `json:"targetVmTags,omitempty"` + TestNetworkId *string `json:"testNetworkId,omitempty"` + TestSubnetName *string `json:"testSubnetName,omitempty"` + UserSelectedOSName *string `json:"userSelectedOSName,omitempty"` + + // Fields inherited from EnableProtectionProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmEnableProtectionInput) EnableProtectionProviderSpecificInput() BaseEnableProtectionProviderSpecificInputImpl { + return BaseEnableProtectionProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmEnableProtectionInput{} + +func (s InMageRcmEnableProtectionInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmEnableProtectionInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmEnableProtectionInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmEnableProtectionInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmEnableProtectionInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbackdiscoveredprotectedvmdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbackdiscoveredprotectedvmdetails.go new file mode 100644 index 00000000000..e90a52a1048 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbackdiscoveredprotectedvmdetails.go @@ -0,0 +1,61 @@ +package replicationprotecteditems + +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 InMageRcmFailbackDiscoveredProtectedVMDetails struct { + CreatedTimestamp *string `json:"createdTimestamp,omitempty"` + DataStores *[]string `json:"datastores,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` + IsDeleted *bool `json:"isDeleted,omitempty"` + LastDiscoveryTimeInUtc *string `json:"lastDiscoveryTimeInUtc,omitempty"` + OsName *string `json:"osName,omitempty"` + PowerStatus *string `json:"powerStatus,omitempty"` + UpdatedTimestamp *string `json:"updatedTimestamp,omitempty"` + VCenterFqdn *string `json:"vCenterFqdn,omitempty"` + VCenterId *string `json:"vCenterId,omitempty"` + VMFqdn *string `json:"vmFqdn,omitempty"` + VMwareToolsStatus *string `json:"vmwareToolsStatus,omitempty"` +} + +func (o *InMageRcmFailbackDiscoveredProtectedVMDetails) GetCreatedTimestampAsTime() (*time.Time, error) { + if o.CreatedTimestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTimestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmFailbackDiscoveredProtectedVMDetails) SetCreatedTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTimestamp = &formatted +} + +func (o *InMageRcmFailbackDiscoveredProtectedVMDetails) GetLastDiscoveryTimeInUtcAsTime() (*time.Time, error) { + if o.LastDiscoveryTimeInUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastDiscoveryTimeInUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmFailbackDiscoveredProtectedVMDetails) SetLastDiscoveryTimeInUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastDiscoveryTimeInUtc = &formatted +} + +func (o *InMageRcmFailbackDiscoveredProtectedVMDetails) GetUpdatedTimestampAsTime() (*time.Time, error) { + if o.UpdatedTimestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.UpdatedTimestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmFailbackDiscoveredProtectedVMDetails) SetUpdatedTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.UpdatedTimestamp = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbackmobilityagentdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbackmobilityagentdetails.go new file mode 100644 index 00000000000..6ef3f5e7b37 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbackmobilityagentdetails.go @@ -0,0 +1,58 @@ +package replicationprotecteditems + +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 InMageRcmFailbackMobilityAgentDetails struct { + AgentVersionExpiryDate *string `json:"agentVersionExpiryDate,omitempty"` + DriverVersion *string `json:"driverVersion,omitempty"` + DriverVersionExpiryDate *string `json:"driverVersionExpiryDate,omitempty"` + IsUpgradeable *string `json:"isUpgradeable,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + LatestUpgradableVersionWithoutReboot *string `json:"latestUpgradableVersionWithoutReboot,omitempty"` + LatestVersion *string `json:"latestVersion,omitempty"` + ReasonsBlockingUpgrade *[]AgentUpgradeBlockedReason `json:"reasonsBlockingUpgrade,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *InMageRcmFailbackMobilityAgentDetails) GetAgentVersionExpiryDateAsTime() (*time.Time, error) { + if o.AgentVersionExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AgentVersionExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmFailbackMobilityAgentDetails) SetAgentVersionExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AgentVersionExpiryDate = &formatted +} + +func (o *InMageRcmFailbackMobilityAgentDetails) GetDriverVersionExpiryDateAsTime() (*time.Time, error) { + if o.DriverVersionExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DriverVersionExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmFailbackMobilityAgentDetails) SetDriverVersionExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DriverVersionExpiryDate = &formatted +} + +func (o *InMageRcmFailbackMobilityAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmFailbackMobilityAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbacknicdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbacknicdetails.go new file mode 100644 index 00000000000..44ac3499256 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbacknicdetails.go @@ -0,0 +1,11 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmFailbackNicDetails struct { + AdapterType *string `json:"adapterType,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + NetworkName *string `json:"networkName,omitempty"` + SourceIPAddress *string `json:"sourceIpAddress,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbackplannedfailoverproviderinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbackplannedfailoverproviderinput.go new file mode 100644 index 00000000000..f347a8ab887 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbackplannedfailoverproviderinput.go @@ -0,0 +1,50 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PlannedFailoverProviderSpecificFailoverInput = InMageRcmFailbackPlannedFailoverProviderInput{} + +type InMageRcmFailbackPlannedFailoverProviderInput struct { + RecoveryPointType InMageRcmFailbackRecoveryPointType `json:"recoveryPointType"` + + // Fields inherited from PlannedFailoverProviderSpecificFailoverInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmFailbackPlannedFailoverProviderInput) PlannedFailoverProviderSpecificFailoverInput() BasePlannedFailoverProviderSpecificFailoverInputImpl { + return BasePlannedFailoverProviderSpecificFailoverInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmFailbackPlannedFailoverProviderInput{} + +func (s InMageRcmFailbackPlannedFailoverProviderInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFailbackPlannedFailoverProviderInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFailbackPlannedFailoverProviderInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFailbackPlannedFailoverProviderInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcmFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFailbackPlannedFailoverProviderInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbackprotecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbackprotecteddiskdetails.go new file mode 100644 index 00000000000..0d93a99814a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbackprotecteddiskdetails.go @@ -0,0 +1,36 @@ +package replicationprotecteditems + +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 InMageRcmFailbackProtectedDiskDetails struct { + CapacityInBytes *int64 `json:"capacityInBytes,omitempty"` + DataPendingAtSourceAgentInMB *float64 `json:"dataPendingAtSourceAgentInMB,omitempty"` + DataPendingInLogDataStoreInMB *float64 `json:"dataPendingInLogDataStoreInMB,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskUuid *string `json:"diskUuid,omitempty"` + IrDetails *InMageRcmFailbackSyncDetails `json:"irDetails,omitempty"` + IsInitialReplicationComplete *string `json:"isInitialReplicationComplete,omitempty"` + IsOSDisk *string `json:"isOSDisk,omitempty"` + LastSyncTime *string `json:"lastSyncTime,omitempty"` + ResyncDetails *InMageRcmFailbackSyncDetails `json:"resyncDetails,omitempty"` +} + +func (o *InMageRcmFailbackProtectedDiskDetails) GetLastSyncTimeAsTime() (*time.Time, error) { + if o.LastSyncTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastSyncTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmFailbackProtectedDiskDetails) SetLastSyncTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastSyncTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbackreplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbackreplicationdetails.go new file mode 100644 index 00000000000..d0312afb7b2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbackreplicationdetails.go @@ -0,0 +1,78 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificSettings = InMageRcmFailbackReplicationDetails{} + +type InMageRcmFailbackReplicationDetails struct { + AzureVirtualMachineId *string `json:"azureVirtualMachineId,omitempty"` + DiscoveredVMDetails *InMageRcmFailbackDiscoveredProtectedVMDetails `json:"discoveredVmDetails,omitempty"` + InitialReplicationProcessedBytes *int64 `json:"initialReplicationProcessedBytes,omitempty"` + InitialReplicationProgressHealth *VMReplicationProgressHealth `json:"initialReplicationProgressHealth,omitempty"` + InitialReplicationProgressPercentage *int64 `json:"initialReplicationProgressPercentage,omitempty"` + InitialReplicationTransferredBytes *int64 `json:"initialReplicationTransferredBytes,omitempty"` + InternalIdentifier *string `json:"internalIdentifier,omitempty"` + IsAgentRegistrationSuccessfulAfterFailover *bool `json:"isAgentRegistrationSuccessfulAfterFailover,omitempty"` + LastPlannedFailoverStartTime *string `json:"lastPlannedFailoverStartTime,omitempty"` + LastPlannedFailoverStatus *PlannedFailoverStatus `json:"lastPlannedFailoverStatus,omitempty"` + LastUsedPolicyFriendlyName *string `json:"lastUsedPolicyFriendlyName,omitempty"` + LastUsedPolicyId *string `json:"lastUsedPolicyId,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` + MobilityAgentDetails *InMageRcmFailbackMobilityAgentDetails `json:"mobilityAgentDetails,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + OsType *string `json:"osType,omitempty"` + ProtectedDisks *[]InMageRcmFailbackProtectedDiskDetails `json:"protectedDisks,omitempty"` + ReprotectAgentId *string `json:"reprotectAgentId,omitempty"` + ReprotectAgentName *string `json:"reprotectAgentName,omitempty"` + ResyncProcessedBytes *int64 `json:"resyncProcessedBytes,omitempty"` + ResyncProgressHealth *VMReplicationProgressHealth `json:"resyncProgressHealth,omitempty"` + ResyncProgressPercentage *int64 `json:"resyncProgressPercentage,omitempty"` + ResyncRequired *string `json:"resyncRequired,omitempty"` + ResyncState *ResyncState `json:"resyncState,omitempty"` + ResyncTransferredBytes *int64 `json:"resyncTransferredBytes,omitempty"` + TargetDataStoreName *string `json:"targetDataStoreName,omitempty"` + TargetVMName *string `json:"targetVmName,omitempty"` + TargetvCenterId *string `json:"targetvCenterId,omitempty"` + VMNics *[]InMageRcmFailbackNicDetails `json:"vmNics,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmFailbackReplicationDetails) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return BaseReplicationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmFailbackReplicationDetails{} + +func (s InMageRcmFailbackReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFailbackReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFailbackReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFailbackReplicationDetails: %+v", err) + } + + decoded["instanceType"] = "InMageRcmFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFailbackReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbackreprotectinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbackreprotectinput.go new file mode 100644 index 00000000000..25a4835498d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbackreprotectinput.go @@ -0,0 +1,52 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReverseReplicationProviderSpecificInput = InMageRcmFailbackReprotectInput{} + +type InMageRcmFailbackReprotectInput struct { + PolicyId string `json:"policyId"` + ProcessServerId string `json:"processServerId"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + + // Fields inherited from ReverseReplicationProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmFailbackReprotectInput) ReverseReplicationProviderSpecificInput() BaseReverseReplicationProviderSpecificInputImpl { + return BaseReverseReplicationProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmFailbackReprotectInput{} + +func (s InMageRcmFailbackReprotectInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFailbackReprotectInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFailbackReprotectInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFailbackReprotectInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcmFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFailbackReprotectInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbacksyncdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbacksyncdetails.go new file mode 100644 index 00000000000..5451ccadcf1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmfailbacksyncdetails.go @@ -0,0 +1,15 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmFailbackSyncDetails struct { + Last15MinutesTransferredBytes *int64 `json:"last15MinutesTransferredBytes,omitempty"` + LastDataTransferTimeUtc *string `json:"lastDataTransferTimeUtc,omitempty"` + LastRefreshTime *string `json:"lastRefreshTime,omitempty"` + ProcessedBytes *int64 `json:"processedBytes,omitempty"` + ProgressHealth *DiskReplicationProgressHealth `json:"progressHealth,omitempty"` + ProgressPercentage *int64 `json:"progressPercentage,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TransferredBytes *int64 `json:"transferredBytes,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmlastagentupgradeerrordetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmlastagentupgradeerrordetails.go new file mode 100644 index 00000000000..8e87e3b48bc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmlastagentupgradeerrordetails.go @@ -0,0 +1,13 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmLastAgentUpgradeErrorDetails struct { + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorMessageParameters *map[string]string `json:"errorMessageParameters,omitempty"` + ErrorTags *map[string]string `json:"errorTags,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmmobilityagentdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmmobilityagentdetails.go new file mode 100644 index 00000000000..bc2431c22ae --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmmobilityagentdetails.go @@ -0,0 +1,59 @@ +package replicationprotecteditems + +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 InMageRcmMobilityAgentDetails struct { + AgentVersionExpiryDate *string `json:"agentVersionExpiryDate,omitempty"` + DriverVersion *string `json:"driverVersion,omitempty"` + DriverVersionExpiryDate *string `json:"driverVersionExpiryDate,omitempty"` + IsUpgradeable *string `json:"isUpgradeable,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + LatestAgentReleaseDate *string `json:"latestAgentReleaseDate,omitempty"` + LatestUpgradableVersionWithoutReboot *string `json:"latestUpgradableVersionWithoutReboot,omitempty"` + LatestVersion *string `json:"latestVersion,omitempty"` + ReasonsBlockingUpgrade *[]AgentUpgradeBlockedReason `json:"reasonsBlockingUpgrade,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *InMageRcmMobilityAgentDetails) GetAgentVersionExpiryDateAsTime() (*time.Time, error) { + if o.AgentVersionExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AgentVersionExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmMobilityAgentDetails) SetAgentVersionExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AgentVersionExpiryDate = &formatted +} + +func (o *InMageRcmMobilityAgentDetails) GetDriverVersionExpiryDateAsTime() (*time.Time, error) { + if o.DriverVersionExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DriverVersionExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmMobilityAgentDetails) SetDriverVersionExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DriverVersionExpiryDate = &formatted +} + +func (o *InMageRcmMobilityAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmMobilityAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmnicdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmnicdetails.go new file mode 100644 index 00000000000..2bfbf3a3e98 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmnicdetails.go @@ -0,0 +1,21 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmNicDetails struct { + IsPrimaryNic *string `json:"isPrimaryNic,omitempty"` + IsSelectedForFailover *string `json:"isSelectedForFailover,omitempty"` + NicId *string `json:"nicId,omitempty"` + SourceIPAddress *string `json:"sourceIPAddress,omitempty"` + SourceIPAddressType *EthernetAddressType `json:"sourceIPAddressType,omitempty"` + SourceNetworkId *string `json:"sourceNetworkId,omitempty"` + SourceSubnetName *string `json:"sourceSubnetName,omitempty"` + TargetIPAddress *string `json:"targetIPAddress,omitempty"` + TargetIPAddressType *EthernetAddressType `json:"targetIPAddressType,omitempty"` + TargetNicName *string `json:"targetNicName,omitempty"` + TargetSubnetName *string `json:"targetSubnetName,omitempty"` + TestIPAddress *string `json:"testIPAddress,omitempty"` + TestIPAddressType *EthernetAddressType `json:"testIPAddressType,omitempty"` + TestSubnetName *string `json:"testSubnetName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmnicinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmnicinput.go new file mode 100644 index 00000000000..2f632b4a8f1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmnicinput.go @@ -0,0 +1,15 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmNicInput struct { + IsPrimaryNic string `json:"isPrimaryNic"` + IsSelectedForFailover *string `json:"isSelectedForFailover,omitempty"` + NicId string `json:"nicId"` + TargetNicName *string `json:"targetNicName,omitempty"` + TargetStaticIPAddress *string `json:"targetStaticIPAddress,omitempty"` + TargetSubnetName *string `json:"targetSubnetName,omitempty"` + TestStaticIPAddress *string `json:"testStaticIPAddress,omitempty"` + TestSubnetName *string `json:"testSubnetName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmprotecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmprotecteddiskdetails.go new file mode 100644 index 00000000000..9d77f1ee74d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmprotecteddiskdetails.go @@ -0,0 +1,25 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmProtectedDiskDetails struct { + CapacityInBytes *int64 `json:"capacityInBytes,omitempty"` + CustomTargetDiskName *string `json:"customTargetDiskName,omitempty"` + DataPendingAtSourceAgentInMB *float64 `json:"dataPendingAtSourceAgentInMB,omitempty"` + DataPendingInLogDataStoreInMB *float64 `json:"dataPendingInLogDataStoreInMB,omitempty"` + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskState *DiskState `json:"diskState,omitempty"` + DiskType *DiskAccountType `json:"diskType,omitempty"` + IrDetails *InMageRcmSyncDetails `json:"irDetails,omitempty"` + IsInitialReplicationComplete *string `json:"isInitialReplicationComplete,omitempty"` + IsOSDisk *string `json:"isOSDisk,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` + ResyncDetails *InMageRcmSyncDetails `json:"resyncDetails,omitempty"` + SectorSizeInBytes *int64 `json:"sectorSizeInBytes,omitempty"` + SeedBlobUri *string `json:"seedBlobUri,omitempty"` + SeedManagedDiskId *string `json:"seedManagedDiskId,omitempty"` + TargetManagedDiskId *string `json:"targetManagedDiskId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmreplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmreplicationdetails.go new file mode 100644 index 00000000000..f2290953258 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmreplicationdetails.go @@ -0,0 +1,111 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificSettings = InMageRcmReplicationDetails{} + +type InMageRcmReplicationDetails struct { + AgentUpgradeAttemptToVersion *string `json:"agentUpgradeAttemptToVersion,omitempty"` + AgentUpgradeBlockingErrorDetails *[]InMageRcmAgentUpgradeBlockingErrorDetails `json:"agentUpgradeBlockingErrorDetails,omitempty"` + AgentUpgradeJobId *string `json:"agentUpgradeJobId,omitempty"` + AgentUpgradeState *MobilityAgentUpgradeState `json:"agentUpgradeState,omitempty"` + AllocatedMemoryInMB *float64 `json:"allocatedMemoryInMB,omitempty"` + DiscoveredVMDetails *InMageRcmDiscoveredProtectedVMDetails `json:"discoveredVmDetails,omitempty"` + DiscoveryType *string `json:"discoveryType,omitempty"` + FabricDiscoveryMachineId *string `json:"fabricDiscoveryMachineId,omitempty"` + FailoverRecoveryPointId *string `json:"failoverRecoveryPointId,omitempty"` + FirmwareType *string `json:"firmwareType,omitempty"` + InitialReplicationProcessedBytes *int64 `json:"initialReplicationProcessedBytes,omitempty"` + InitialReplicationProgressHealth *VMReplicationProgressHealth `json:"initialReplicationProgressHealth,omitempty"` + InitialReplicationProgressPercentage *int64 `json:"initialReplicationProgressPercentage,omitempty"` + InitialReplicationTransferredBytes *int64 `json:"initialReplicationTransferredBytes,omitempty"` + InternalIdentifier *string `json:"internalIdentifier,omitempty"` + IsAgentRegistrationSuccessfulAfterFailover *bool `json:"isAgentRegistrationSuccessfulAfterFailover,omitempty"` + IsLastUpgradeSuccessful *string `json:"isLastUpgradeSuccessful,omitempty"` + LastAgentUpgradeErrorDetails *[]InMageRcmLastAgentUpgradeErrorDetails `json:"lastAgentUpgradeErrorDetails,omitempty"` + LastAgentUpgradeType *string `json:"lastAgentUpgradeType,omitempty"` + LastRecoveryPointId *string `json:"lastRecoveryPointId,omitempty"` + LastRecoveryPointReceived *string `json:"lastRecoveryPointReceived,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + LastRpoInSeconds *int64 `json:"lastRpoInSeconds,omitempty"` + LicenseType *string `json:"licenseType,omitempty"` + LinuxLicenseType *LinuxLicenseType `json:"linuxLicenseType,omitempty"` + MobilityAgentDetails *InMageRcmMobilityAgentDetails `json:"mobilityAgentDetails,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + OsName *string `json:"osName,omitempty"` + OsType *string `json:"osType,omitempty"` + PrimaryNicIPAddress *string `json:"primaryNicIpAddress,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + ProcessServerName *string `json:"processServerName,omitempty"` + ProcessorCoreCount *int64 `json:"processorCoreCount,omitempty"` + ProtectedDisks *[]InMageRcmProtectedDiskDetails `json:"protectedDisks,omitempty"` + ResyncProcessedBytes *int64 `json:"resyncProcessedBytes,omitempty"` + ResyncProgressHealth *VMReplicationProgressHealth `json:"resyncProgressHealth,omitempty"` + ResyncProgressPercentage *int64 `json:"resyncProgressPercentage,omitempty"` + ResyncRequired *string `json:"resyncRequired,omitempty"` + ResyncState *ResyncState `json:"resyncState,omitempty"` + ResyncTransferredBytes *int64 `json:"resyncTransferredBytes,omitempty"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + SeedManagedDiskTags *[]UserCreatedResourceTag `json:"seedManagedDiskTags,omitempty"` + SqlServerLicenseType *string `json:"sqlServerLicenseType,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + SupportedOSVersions *[]string `json:"supportedOSVersions,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetBootDiagnosticsStorageAccountId *string `json:"targetBootDiagnosticsStorageAccountId,omitempty"` + TargetGeneration *string `json:"targetGeneration,omitempty"` + TargetLocation *string `json:"targetLocation,omitempty"` + TargetManagedDiskTags *[]UserCreatedResourceTag `json:"targetManagedDiskTags,omitempty"` + TargetNetworkId *string `json:"targetNetworkId,omitempty"` + TargetNicTags *[]UserCreatedResourceTag `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVMName *string `json:"targetVmName,omitempty"` + TargetVMSecurityProfile *SecurityProfileProperties `json:"targetVmSecurityProfile,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TargetVMTags *[]UserCreatedResourceTag `json:"targetVmTags,omitempty"` + TestNetworkId *string `json:"testNetworkId,omitempty"` + UnprotectedDisks *[]InMageRcmUnProtectedDiskDetails `json:"unprotectedDisks,omitempty"` + VMNics *[]InMageRcmNicDetails `json:"vmNics,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmReplicationDetails) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return BaseReplicationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmReplicationDetails{} + +func (s InMageRcmReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmReplicationDetails: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmreprotectinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmreprotectinput.go new file mode 100644 index 00000000000..a8a70b3cef6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmreprotectinput.go @@ -0,0 +1,53 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReverseReplicationProviderSpecificInput = InMageRcmReprotectInput{} + +type InMageRcmReprotectInput struct { + DatastoreName string `json:"datastoreName"` + LogStorageAccountId string `json:"logStorageAccountId"` + PolicyId *string `json:"policyId,omitempty"` + ReprotectAgentId string `json:"reprotectAgentId"` + + // Fields inherited from ReverseReplicationProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmReprotectInput) ReverseReplicationProviderSpecificInput() BaseReverseReplicationProviderSpecificInputImpl { + return BaseReverseReplicationProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmReprotectInput{} + +func (s InMageRcmReprotectInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmReprotectInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmReprotectInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmReprotectInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmReprotectInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmsyncdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmsyncdetails.go new file mode 100644 index 00000000000..a8388f3c5f8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmsyncdetails.go @@ -0,0 +1,15 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmSyncDetails struct { + Last15MinutesTransferredBytes *int64 `json:"last15MinutesTransferredBytes,omitempty"` + LastDataTransferTimeUtc *string `json:"lastDataTransferTimeUtc,omitempty"` + LastRefreshTime *string `json:"lastRefreshTime,omitempty"` + ProcessedBytes *int64 `json:"processedBytes,omitempty"` + ProgressHealth *DiskReplicationProgressHealth `json:"progressHealth,omitempty"` + ProgressPercentage *int64 `json:"progressPercentage,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TransferredBytes *int64 `json:"transferredBytes,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmtestfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmtestfailoverinput.go new file mode 100644 index 00000000000..92af54992fb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmtestfailoverinput.go @@ -0,0 +1,52 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TestFailoverProviderSpecificInput = InMageRcmTestFailoverInput{} + +type InMageRcmTestFailoverInput struct { + NetworkId *string `json:"networkId,omitempty"` + OsUpgradeVersion *string `json:"osUpgradeVersion,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + + // Fields inherited from TestFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmTestFailoverInput) TestFailoverProviderSpecificInput() BaseTestFailoverProviderSpecificInputImpl { + return BaseTestFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmTestFailoverInput{} + +func (s InMageRcmTestFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmTestFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmTestFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmTestFailoverInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmTestFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmunplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmunplannedfailoverinput.go new file mode 100644 index 00000000000..1d2555610f6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmunplannedfailoverinput.go @@ -0,0 +1,52 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ UnplannedFailoverProviderSpecificInput = InMageRcmUnplannedFailoverInput{} + +type InMageRcmUnplannedFailoverInput struct { + OsUpgradeVersion *string `json:"osUpgradeVersion,omitempty"` + PerformShutdown string `json:"performShutdown"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + + // Fields inherited from UnplannedFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmUnplannedFailoverInput) UnplannedFailoverProviderSpecificInput() BaseUnplannedFailoverProviderSpecificInputImpl { + return BaseUnplannedFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmUnplannedFailoverInput{} + +func (s InMageRcmUnplannedFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmUnplannedFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmUnplannedFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmUnplannedFailoverInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmUnplannedFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmunprotecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmunprotecteddiskdetails.go new file mode 100644 index 00000000000..95242854fa8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmunprotecteddiskdetails.go @@ -0,0 +1,10 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmUnProtectedDiskDetails struct { + CapacityInBytes *int64 `json:"capacityInBytes,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmupdateapplianceforreplicationprotectediteminput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmupdateapplianceforreplicationprotectediteminput.go new file mode 100644 index 00000000000..c3eb7e50380 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmupdateapplianceforreplicationprotectediteminput.go @@ -0,0 +1,50 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ UpdateApplianceForReplicationProtectedItemProviderSpecificInput = InMageRcmUpdateApplianceForReplicationProtectedItemInput{} + +type InMageRcmUpdateApplianceForReplicationProtectedItemInput struct { + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + + // Fields inherited from UpdateApplianceForReplicationProtectedItemProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmUpdateApplianceForReplicationProtectedItemInput) UpdateApplianceForReplicationProtectedItemProviderSpecificInput() BaseUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl { + return BaseUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmUpdateApplianceForReplicationProtectedItemInput{} + +func (s InMageRcmUpdateApplianceForReplicationProtectedItemInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmUpdateApplianceForReplicationProtectedItemInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmUpdateApplianceForReplicationProtectedItemInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmUpdateApplianceForReplicationProtectedItemInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmUpdateApplianceForReplicationProtectedItemInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmupdatereplicationprotectediteminput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmupdatereplicationprotectediteminput.go new file mode 100644 index 00000000000..a2a90639cc5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagercmupdatereplicationprotectediteminput.go @@ -0,0 +1,66 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ UpdateReplicationProtectedItemProviderInput = InMageRcmUpdateReplicationProtectedItemInput{} + +type InMageRcmUpdateReplicationProtectedItemInput struct { + LicenseType *LicenseType `json:"licenseType,omitempty"` + LinuxLicenseType *LinuxLicenseType `json:"linuxLicenseType,omitempty"` + SqlServerLicenseType *SqlServerLicenseType `json:"sqlServerLicenseType,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetBootDiagnosticsStorageAccountId *string `json:"targetBootDiagnosticsStorageAccountId,omitempty"` + TargetManagedDiskTags *[]UserCreatedResourceTag `json:"targetManagedDiskTags,omitempty"` + TargetNetworkId *string `json:"targetNetworkId,omitempty"` + TargetNicTags *[]UserCreatedResourceTag `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVMName *string `json:"targetVmName,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TargetVMTags *[]UserCreatedResourceTag `json:"targetVmTags,omitempty"` + TestNetworkId *string `json:"testNetworkId,omitempty"` + UserSelectedOSName *string `json:"userSelectedOSName,omitempty"` + VMNics *[]InMageRcmNicInput `json:"vmNics,omitempty"` + + // Fields inherited from UpdateReplicationProtectedItemProviderInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmUpdateReplicationProtectedItemInput) UpdateReplicationProtectedItemProviderInput() BaseUpdateReplicationProtectedItemProviderInputImpl { + return BaseUpdateReplicationProtectedItemProviderInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmUpdateReplicationProtectedItemInput{} + +func (s InMageRcmUpdateReplicationProtectedItemInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmUpdateReplicationProtectedItemInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmUpdateReplicationProtectedItemInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmUpdateReplicationProtectedItemInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmUpdateReplicationProtectedItemInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagereplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagereplicationdetails.go new file mode 100644 index 00000000000..5bd28404fcb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagereplicationdetails.go @@ -0,0 +1,89 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificSettings = InMageReplicationDetails{} + +type InMageReplicationDetails struct { + ActiveSiteType *string `json:"activeSiteType,omitempty"` + AgentDetails *InMageAgentDetails `json:"agentDetails,omitempty"` + AzureStorageAccountId *string `json:"azureStorageAccountId,omitempty"` + CompressedDataRateInMB *float64 `json:"compressedDataRateInMB,omitempty"` + ConsistencyPoints *map[string]string `json:"consistencyPoints,omitempty"` + DataStores *[]string `json:"datastores,omitempty"` + DiscoveryType *string `json:"discoveryType,omitempty"` + DiskResized *string `json:"diskResized,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InfrastructureVMId *string `json:"infrastructureVmId,omitempty"` + IsAdditionalStatsAvailable *bool `json:"isAdditionalStatsAvailable,omitempty"` + LastHeartbeat *string `json:"lastHeartbeat,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + LastUpdateReceivedTime *string `json:"lastUpdateReceivedTime,omitempty"` + MasterTargetId *string `json:"masterTargetId,omitempty"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` + OsDetails *OSDiskDetails `json:"osDetails,omitempty"` + OsVersion *string `json:"osVersion,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + ProtectedDisks *[]InMageProtectedDiskDetails `json:"protectedDisks,omitempty"` + ProtectionStage *string `json:"protectionStage,omitempty"` + RebootAfterUpdateStatus *string `json:"rebootAfterUpdateStatus,omitempty"` + ReplicaId *string `json:"replicaId,omitempty"` + ResyncDetails *InitialReplicationDetails `json:"resyncDetails,omitempty"` + RetentionWindowEnd *string `json:"retentionWindowEnd,omitempty"` + RetentionWindowStart *string `json:"retentionWindowStart,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + SourceVMCPUCount *int64 `json:"sourceVmCpuCount,omitempty"` + SourceVMRamSizeInMB *int64 `json:"sourceVmRamSizeInMB,omitempty"` + TotalDataTransferred *int64 `json:"totalDataTransferred,omitempty"` + TotalProgressHealth *string `json:"totalProgressHealth,omitempty"` + UncompressedDataRateInMB *float64 `json:"uncompressedDataRateInMB,omitempty"` + VCenterInfrastructureId *string `json:"vCenterInfrastructureId,omitempty"` + VMId *string `json:"vmId,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + ValidationErrors *[]HealthError `json:"validationErrors,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s InMageReplicationDetails) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return BaseReplicationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageReplicationDetails{} + +func (s InMageReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageReplicationDetails: %+v", err) + } + + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagereprotectinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagereprotectinput.go new file mode 100644 index 00000000000..f7f46d7e03c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagereprotectinput.go @@ -0,0 +1,57 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReverseReplicationProviderSpecificInput = InMageReprotectInput{} + +type InMageReprotectInput struct { + DatastoreName *string `json:"datastoreName,omitempty"` + DiskExclusionInput *InMageDiskExclusionInput `json:"diskExclusionInput,omitempty"` + DisksToInclude *[]string `json:"disksToInclude,omitempty"` + MasterTargetId string `json:"masterTargetId"` + ProcessServerId string `json:"processServerId"` + ProfileId string `json:"profileId"` + RetentionDrive string `json:"retentionDrive"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + + // Fields inherited from ReverseReplicationProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageReprotectInput) ReverseReplicationProviderSpecificInput() BaseReverseReplicationProviderSpecificInputImpl { + return BaseReverseReplicationProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageReprotectInput{} + +func (s InMageReprotectInput) MarshalJSON() ([]byte, error) { + type wrapper InMageReprotectInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageReprotectInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageReprotectInput: %+v", err) + } + + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageReprotectInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagetestfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagetestfailoverinput.go new file mode 100644 index 00000000000..c2c3cb6b741 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagetestfailoverinput.go @@ -0,0 +1,51 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TestFailoverProviderSpecificInput = InMageTestFailoverInput{} + +type InMageTestFailoverInput struct { + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RecoveryPointType *RecoveryPointType `json:"recoveryPointType,omitempty"` + + // Fields inherited from TestFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageTestFailoverInput) TestFailoverProviderSpecificInput() BaseTestFailoverProviderSpecificInputImpl { + return BaseTestFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageTestFailoverInput{} + +func (s InMageTestFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper InMageTestFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageTestFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageTestFailoverInput: %+v", err) + } + + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageTestFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageunplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageunplannedfailoverinput.go new file mode 100644 index 00000000000..9d97383ad62 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmageunplannedfailoverinput.go @@ -0,0 +1,51 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ UnplannedFailoverProviderSpecificInput = InMageUnplannedFailoverInput{} + +type InMageUnplannedFailoverInput struct { + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RecoveryPointType *RecoveryPointType `json:"recoveryPointType,omitempty"` + + // Fields inherited from UnplannedFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageUnplannedFailoverInput) UnplannedFailoverProviderSpecificInput() BaseUnplannedFailoverProviderSpecificInputImpl { + return BaseUnplannedFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageUnplannedFailoverInput{} + +func (s InMageUnplannedFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper InMageUnplannedFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageUnplannedFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageUnplannedFailoverInput: %+v", err) + } + + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageUnplannedFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagevolumeexclusionoptions.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagevolumeexclusionoptions.go new file mode 100644 index 00000000000..f8a523a289d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inmagevolumeexclusionoptions.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageVolumeExclusionOptions struct { + OnlyExcludeIfSingleVolume *string `json:"onlyExcludeIfSingleVolume,omitempty"` + VolumeLabel *string `json:"volumeLabel,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_innerhealtherror.go new file mode 100644 index 00000000000..dc06e717b80 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationprotecteditems + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inputendpoint.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inputendpoint.go new file mode 100644 index 00000000000..a0e3fd45e70 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_inputendpoint.go @@ -0,0 +1,11 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InputEndpoint struct { + EndpointName *string `json:"endpointName,omitempty"` + PrivatePort *int64 `json:"privatePort,omitempty"` + Protocol *string `json:"protocol,omitempty"` + PublicPort *int64 `json:"publicPort,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_ipconfigdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_ipconfigdetails.go new file mode 100644 index 00000000000..74ce87533d6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_ipconfigdetails.go @@ -0,0 +1,22 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigDetails struct { + IPAddressType *string `json:"ipAddressType,omitempty"` + IsPrimary *bool `json:"isPrimary,omitempty"` + IsSeletedForFailover *bool `json:"isSeletedForFailover,omitempty"` + Name *string `json:"name,omitempty"` + RecoveryIPAddressType *string `json:"recoveryIPAddressType,omitempty"` + RecoveryLBBackendAddressPoolIds *[]string `json:"recoveryLBBackendAddressPoolIds,omitempty"` + RecoveryPublicIPAddressId *string `json:"recoveryPublicIPAddressId,omitempty"` + RecoveryStaticIPAddress *string `json:"recoveryStaticIPAddress,omitempty"` + RecoverySubnetName *string `json:"recoverySubnetName,omitempty"` + StaticIPAddress *string `json:"staticIPAddress,omitempty"` + SubnetName *string `json:"subnetName,omitempty"` + TfoLBBackendAddressPoolIds *[]string `json:"tfoLBBackendAddressPoolIds,omitempty"` + TfoPublicIPAddressId *string `json:"tfoPublicIPAddressId,omitempty"` + TfoStaticIPAddress *string `json:"tfoStaticIPAddress,omitempty"` + TfoSubnetName *string `json:"tfoSubnetName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_ipconfiginputdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_ipconfiginputdetails.go new file mode 100644 index 00000000000..de0609e9a0d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_ipconfiginputdetails.go @@ -0,0 +1,18 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigInputDetails struct { + IPConfigName *string `json:"ipConfigName,omitempty"` + IsPrimary *bool `json:"isPrimary,omitempty"` + IsSeletedForFailover *bool `json:"isSeletedForFailover,omitempty"` + RecoveryLBBackendAddressPoolIds *[]string `json:"recoveryLBBackendAddressPoolIds,omitempty"` + RecoveryPublicIPAddressId *string `json:"recoveryPublicIPAddressId,omitempty"` + RecoveryStaticIPAddress *string `json:"recoveryStaticIPAddress,omitempty"` + RecoverySubnetName *string `json:"recoverySubnetName,omitempty"` + TfoLBBackendAddressPoolIds *[]string `json:"tfoLBBackendAddressPoolIds,omitempty"` + TfoPublicIPAddressId *string `json:"tfoPublicIPAddressId,omitempty"` + TfoStaticIPAddress *string `json:"tfoStaticIPAddress,omitempty"` + TfoSubnetName *string `json:"tfoSubnetName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_keyencryptionkeyinfo.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_keyencryptionkeyinfo.go new file mode 100644 index 00000000000..b0d163a1195 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_keyencryptionkeyinfo.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyEncryptionKeyInfo struct { + KeyIdentifier *string `json:"keyIdentifier,omitempty"` + KeyVaultResourceArmId *string `json:"keyVaultResourceArmId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_osdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_osdetails.go new file mode 100644 index 00000000000..141a3f39061 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_osdetails.go @@ -0,0 +1,14 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OSDetails struct { + OSMajorVersion *string `json:"oSMajorVersion,omitempty"` + OSMinorVersion *string `json:"oSMinorVersion,omitempty"` + OSVersion *string `json:"oSVersion,omitempty"` + OsEdition *string `json:"osEdition,omitempty"` + OsType *string `json:"osType,omitempty"` + ProductType *string `json:"productType,omitempty"` + UserSelectedOSName *string `json:"userSelectedOSName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_osdiskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_osdiskdetails.go new file mode 100644 index 00000000000..9686e06d452 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_osdiskdetails.go @@ -0,0 +1,10 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OSDiskDetails struct { + OsType *string `json:"osType,omitempty"` + OsVhdId *string `json:"osVhdId,omitempty"` + VhdName *string `json:"vhdName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_osupgradesupportedversions.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_osupgradesupportedversions.go new file mode 100644 index 00000000000..c67f7c6cdc9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_osupgradesupportedversions.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OSUpgradeSupportedVersions struct { + SupportedSourceOsVersion *string `json:"supportedSourceOsVersion,omitempty"` + SupportedTargetOsVersions *[]string `json:"supportedTargetOsVersions,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_plannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_plannedfailoverinput.go new file mode 100644 index 00000000000..ccf7d67c6ad --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_plannedfailoverinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PlannedFailoverInput struct { + Properties *PlannedFailoverInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_plannedfailoverinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_plannedfailoverinputproperties.go new file mode 100644 index 00000000000..24a70ce3078 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_plannedfailoverinputproperties.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PlannedFailoverInputProperties struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + ProviderSpecificDetails PlannedFailoverProviderSpecificFailoverInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &PlannedFailoverInputProperties{} + +func (s *PlannedFailoverInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling PlannedFailoverInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalPlannedFailoverProviderSpecificFailoverInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'PlannedFailoverInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_plannedfailoverproviderspecificfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_plannedfailoverproviderspecificfailoverinput.go new file mode 100644 index 00000000000..383a54e920c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_plannedfailoverproviderspecificfailoverinput.go @@ -0,0 +1,91 @@ +package replicationprotecteditems + +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 PlannedFailoverProviderSpecificFailoverInput interface { + PlannedFailoverProviderSpecificFailoverInput() BasePlannedFailoverProviderSpecificFailoverInputImpl +} + +var _ PlannedFailoverProviderSpecificFailoverInput = BasePlannedFailoverProviderSpecificFailoverInputImpl{} + +type BasePlannedFailoverProviderSpecificFailoverInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BasePlannedFailoverProviderSpecificFailoverInputImpl) PlannedFailoverProviderSpecificFailoverInput() BasePlannedFailoverProviderSpecificFailoverInputImpl { + return s +} + +var _ PlannedFailoverProviderSpecificFailoverInput = RawPlannedFailoverProviderSpecificFailoverInputImpl{} + +// RawPlannedFailoverProviderSpecificFailoverInputImpl 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 RawPlannedFailoverProviderSpecificFailoverInputImpl struct { + plannedFailoverProviderSpecificFailoverInput BasePlannedFailoverProviderSpecificFailoverInputImpl + Type string + Values map[string]interface{} +} + +func (s RawPlannedFailoverProviderSpecificFailoverInputImpl) PlannedFailoverProviderSpecificFailoverInput() BasePlannedFailoverProviderSpecificFailoverInputImpl { + return s.plannedFailoverProviderSpecificFailoverInput +} + +func UnmarshalPlannedFailoverProviderSpecificFailoverInputImplementation(input []byte) (PlannedFailoverProviderSpecificFailoverInput, 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 PlannedFailoverProviderSpecificFailoverInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "HyperVReplicaAzureFailback") { + var out HyperVReplicaAzureFailbackProviderInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureFailbackProviderInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzurePlannedFailoverProviderInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzurePlannedFailoverProviderInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcmFailback") { + var out InMageRcmFailbackPlannedFailoverProviderInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFailbackPlannedFailoverProviderInput: %+v", err) + } + return out, nil + } + + var parent BasePlannedFailoverProviderSpecificFailoverInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BasePlannedFailoverProviderSpecificFailoverInputImpl: %+v", err) + } + + return RawPlannedFailoverProviderSpecificFailoverInputImpl{ + plannedFailoverProviderSpecificFailoverInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_removedisksinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_removedisksinput.go new file mode 100644 index 00000000000..bfb58b0e932 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_removedisksinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemoveDisksInput struct { + Properties *RemoveDisksInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_removedisksinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_removedisksinputproperties.go new file mode 100644 index 00000000000..7f07f3f0bf7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_removedisksinputproperties.go @@ -0,0 +1,33 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemoveDisksInputProperties struct { + ProviderSpecificDetails RemoveDisksProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &RemoveDisksInputProperties{} + +func (s *RemoveDisksInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RemoveDisksInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalRemoveDisksProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'RemoveDisksInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_removedisksproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_removedisksproviderspecificinput.go new file mode 100644 index 00000000000..ee7ec283473 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_removedisksproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 RemoveDisksProviderSpecificInput interface { + RemoveDisksProviderSpecificInput() BaseRemoveDisksProviderSpecificInputImpl +} + +var _ RemoveDisksProviderSpecificInput = BaseRemoveDisksProviderSpecificInputImpl{} + +type BaseRemoveDisksProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseRemoveDisksProviderSpecificInputImpl) RemoveDisksProviderSpecificInput() BaseRemoveDisksProviderSpecificInputImpl { + return s +} + +var _ RemoveDisksProviderSpecificInput = RawRemoveDisksProviderSpecificInputImpl{} + +// RawRemoveDisksProviderSpecificInputImpl 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 RawRemoveDisksProviderSpecificInputImpl struct { + removeDisksProviderSpecificInput BaseRemoveDisksProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawRemoveDisksProviderSpecificInputImpl) RemoveDisksProviderSpecificInput() BaseRemoveDisksProviderSpecificInputImpl { + return s.removeDisksProviderSpecificInput +} + +func UnmarshalRemoveDisksProviderSpecificInputImplementation(input []byte) (RemoveDisksProviderSpecificInput, 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 RemoveDisksProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2ARemoveDisksInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ARemoveDisksInput: %+v", err) + } + return out, nil + } + + var parent BaseRemoveDisksProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRemoveDisksProviderSpecificInputImpl: %+v", err) + } + + return RawRemoveDisksProviderSpecificInputImpl{ + removeDisksProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_replicationprotecteditem.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_replicationprotecteditem.go new file mode 100644 index 00000000000..8c86ba791a1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_replicationprotecteditem.go @@ -0,0 +1,12 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProtectedItem struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ReplicationProtectedItemProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_replicationprotecteditemproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_replicationprotecteditemproperties.go new file mode 100644 index 00000000000..db913d4e503 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_replicationprotecteditemproperties.go @@ -0,0 +1,153 @@ +package replicationprotecteditems + +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. + +type ReplicationProtectedItemProperties struct { + ActiveLocation *string `json:"activeLocation,omitempty"` + AllowedOperations *[]string `json:"allowedOperations,omitempty"` + CurrentScenario *CurrentScenarioDetails `json:"currentScenario,omitempty"` + EventCorrelationId *string `json:"eventCorrelationId,omitempty"` + FailoverHealth *string `json:"failoverHealth,omitempty"` + FailoverRecoveryPointId *string `json:"failoverRecoveryPointId,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + LastSuccessfulFailoverTime *string `json:"lastSuccessfulFailoverTime,omitempty"` + LastSuccessfulTestFailoverTime *string `json:"lastSuccessfulTestFailoverTime,omitempty"` + PolicyFriendlyName *string `json:"policyFriendlyName,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PrimaryFabricFriendlyName *string `json:"primaryFabricFriendlyName,omitempty"` + PrimaryFabricProvider *string `json:"primaryFabricProvider,omitempty"` + PrimaryProtectionContainerFriendlyName *string `json:"primaryProtectionContainerFriendlyName,omitempty"` + ProtectableItemId *string `json:"protectableItemId,omitempty"` + ProtectedItemType *string `json:"protectedItemType,omitempty"` + ProtectionState *string `json:"protectionState,omitempty"` + ProtectionStateDescription *string `json:"protectionStateDescription,omitempty"` + ProviderSpecificDetails ReplicationProviderSpecificSettings `json:"providerSpecificDetails"` + RecoveryContainerId *string `json:"recoveryContainerId,omitempty"` + RecoveryFabricFriendlyName *string `json:"recoveryFabricFriendlyName,omitempty"` + RecoveryFabricId *string `json:"recoveryFabricId,omitempty"` + RecoveryProtectionContainerFriendlyName *string `json:"recoveryProtectionContainerFriendlyName,omitempty"` + RecoveryServicesProviderId *string `json:"recoveryServicesProviderId,omitempty"` + ReplicationHealth *string `json:"replicationHealth,omitempty"` + SwitchProviderState *string `json:"switchProviderState,omitempty"` + SwitchProviderStateDescription *string `json:"switchProviderStateDescription,omitempty"` + TestFailoverState *string `json:"testFailoverState,omitempty"` + TestFailoverStateDescription *string `json:"testFailoverStateDescription,omitempty"` +} + +func (o *ReplicationProtectedItemProperties) GetLastSuccessfulFailoverTimeAsTime() (*time.Time, error) { + if o.LastSuccessfulFailoverTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastSuccessfulFailoverTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReplicationProtectedItemProperties) SetLastSuccessfulFailoverTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastSuccessfulFailoverTime = &formatted +} + +func (o *ReplicationProtectedItemProperties) GetLastSuccessfulTestFailoverTimeAsTime() (*time.Time, error) { + if o.LastSuccessfulTestFailoverTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastSuccessfulTestFailoverTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReplicationProtectedItemProperties) SetLastSuccessfulTestFailoverTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastSuccessfulTestFailoverTime = &formatted +} + +var _ json.Unmarshaler = &ReplicationProtectedItemProperties{} + +func (s *ReplicationProtectedItemProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ActiveLocation *string `json:"activeLocation,omitempty"` + AllowedOperations *[]string `json:"allowedOperations,omitempty"` + CurrentScenario *CurrentScenarioDetails `json:"currentScenario,omitempty"` + EventCorrelationId *string `json:"eventCorrelationId,omitempty"` + FailoverHealth *string `json:"failoverHealth,omitempty"` + FailoverRecoveryPointId *string `json:"failoverRecoveryPointId,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + LastSuccessfulFailoverTime *string `json:"lastSuccessfulFailoverTime,omitempty"` + LastSuccessfulTestFailoverTime *string `json:"lastSuccessfulTestFailoverTime,omitempty"` + PolicyFriendlyName *string `json:"policyFriendlyName,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PrimaryFabricFriendlyName *string `json:"primaryFabricFriendlyName,omitempty"` + PrimaryFabricProvider *string `json:"primaryFabricProvider,omitempty"` + PrimaryProtectionContainerFriendlyName *string `json:"primaryProtectionContainerFriendlyName,omitempty"` + ProtectableItemId *string `json:"protectableItemId,omitempty"` + ProtectedItemType *string `json:"protectedItemType,omitempty"` + ProtectionState *string `json:"protectionState,omitempty"` + ProtectionStateDescription *string `json:"protectionStateDescription,omitempty"` + RecoveryContainerId *string `json:"recoveryContainerId,omitempty"` + RecoveryFabricFriendlyName *string `json:"recoveryFabricFriendlyName,omitempty"` + RecoveryFabricId *string `json:"recoveryFabricId,omitempty"` + RecoveryProtectionContainerFriendlyName *string `json:"recoveryProtectionContainerFriendlyName,omitempty"` + RecoveryServicesProviderId *string `json:"recoveryServicesProviderId,omitempty"` + ReplicationHealth *string `json:"replicationHealth,omitempty"` + SwitchProviderState *string `json:"switchProviderState,omitempty"` + SwitchProviderStateDescription *string `json:"switchProviderStateDescription,omitempty"` + TestFailoverState *string `json:"testFailoverState,omitempty"` + TestFailoverStateDescription *string `json:"testFailoverStateDescription,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ActiveLocation = decoded.ActiveLocation + s.AllowedOperations = decoded.AllowedOperations + s.CurrentScenario = decoded.CurrentScenario + s.EventCorrelationId = decoded.EventCorrelationId + s.FailoverHealth = decoded.FailoverHealth + s.FailoverRecoveryPointId = decoded.FailoverRecoveryPointId + s.FriendlyName = decoded.FriendlyName + s.HealthErrors = decoded.HealthErrors + s.LastSuccessfulFailoverTime = decoded.LastSuccessfulFailoverTime + s.LastSuccessfulTestFailoverTime = decoded.LastSuccessfulTestFailoverTime + s.PolicyFriendlyName = decoded.PolicyFriendlyName + s.PolicyId = decoded.PolicyId + s.PrimaryFabricFriendlyName = decoded.PrimaryFabricFriendlyName + s.PrimaryFabricProvider = decoded.PrimaryFabricProvider + s.PrimaryProtectionContainerFriendlyName = decoded.PrimaryProtectionContainerFriendlyName + s.ProtectableItemId = decoded.ProtectableItemId + s.ProtectedItemType = decoded.ProtectedItemType + s.ProtectionState = decoded.ProtectionState + s.ProtectionStateDescription = decoded.ProtectionStateDescription + s.RecoveryContainerId = decoded.RecoveryContainerId + s.RecoveryFabricFriendlyName = decoded.RecoveryFabricFriendlyName + s.RecoveryFabricId = decoded.RecoveryFabricId + s.RecoveryProtectionContainerFriendlyName = decoded.RecoveryProtectionContainerFriendlyName + s.RecoveryServicesProviderId = decoded.RecoveryServicesProviderId + s.ReplicationHealth = decoded.ReplicationHealth + s.SwitchProviderState = decoded.SwitchProviderState + s.SwitchProviderStateDescription = decoded.SwitchProviderStateDescription + s.TestFailoverState = decoded.TestFailoverState + s.TestFailoverStateDescription = decoded.TestFailoverStateDescription + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ReplicationProtectedItemProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalReplicationProviderSpecificSettingsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ReplicationProtectedItemProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_replicationproviderspecificsettings.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_replicationproviderspecificsettings.go new file mode 100644 index 00000000000..9c657e69eb9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_replicationproviderspecificsettings.go @@ -0,0 +1,147 @@ +package replicationprotecteditems + +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 ReplicationProviderSpecificSettings interface { + ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl +} + +var _ ReplicationProviderSpecificSettings = BaseReplicationProviderSpecificSettingsImpl{} + +type BaseReplicationProviderSpecificSettingsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseReplicationProviderSpecificSettingsImpl) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return s +} + +var _ ReplicationProviderSpecificSettings = RawReplicationProviderSpecificSettingsImpl{} + +// RawReplicationProviderSpecificSettingsImpl 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 RawReplicationProviderSpecificSettingsImpl struct { + replicationProviderSpecificSettings BaseReplicationProviderSpecificSettingsImpl + Type string + Values map[string]interface{} +} + +func (s RawReplicationProviderSpecificSettingsImpl) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return s.replicationProviderSpecificSettings +} + +func UnmarshalReplicationProviderSpecificSettingsImplementation(input []byte) (ReplicationProviderSpecificSettings, 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 ReplicationProviderSpecificSettings into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2ACrossClusterMigration") { + var out A2ACrossClusterMigrationReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ACrossClusterMigrationReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2AReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaBaseReplicationDetails") { + var out HyperVReplicaBaseReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaBaseReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplica2012R2") { + var out HyperVReplicaBlueReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaBlueReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplica2012") { + var out HyperVReplicaReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2ReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2ReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcmFailback") { + var out InMageRcmFailbackReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFailbackReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out InMageReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageReplicationDetails: %+v", err) + } + return out, nil + } + + var parent BaseReplicationProviderSpecificSettingsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseReplicationProviderSpecificSettingsImpl: %+v", err) + } + + return RawReplicationProviderSpecificSettingsImpl{ + replicationProviderSpecificSettings: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_resolvehealtherror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_resolvehealtherror.go new file mode 100644 index 00000000000..0fc7181b7ab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_resolvehealtherror.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResolveHealthError struct { + HealthErrorId *string `json:"healthErrorId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_resolvehealthinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_resolvehealthinput.go new file mode 100644 index 00000000000..57ce7884f4b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_resolvehealthinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResolveHealthInput struct { + Properties *ResolveHealthInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_resolvehealthinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_resolvehealthinputproperties.go new file mode 100644 index 00000000000..735fbf2ee53 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_resolvehealthinputproperties.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResolveHealthInputProperties struct { + HealthErrors *[]ResolveHealthError `json:"healthErrors,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_reversereplicationinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_reversereplicationinput.go new file mode 100644 index 00000000000..dcd65ebb176 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_reversereplicationinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReverseReplicationInput struct { + Properties *ReverseReplicationInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_reversereplicationinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_reversereplicationinputproperties.go new file mode 100644 index 00000000000..46e9f290241 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_reversereplicationinputproperties.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReverseReplicationInputProperties struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + ProviderSpecificDetails ReverseReplicationProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &ReverseReplicationInputProperties{} + +func (s *ReverseReplicationInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ReverseReplicationInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalReverseReplicationProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ReverseReplicationInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_reversereplicationproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_reversereplicationproviderspecificinput.go new file mode 100644 index 00000000000..99bb04d2d4a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_reversereplicationproviderspecificinput.go @@ -0,0 +1,115 @@ +package replicationprotecteditems + +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 ReverseReplicationProviderSpecificInput interface { + ReverseReplicationProviderSpecificInput() BaseReverseReplicationProviderSpecificInputImpl +} + +var _ ReverseReplicationProviderSpecificInput = BaseReverseReplicationProviderSpecificInputImpl{} + +type BaseReverseReplicationProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseReverseReplicationProviderSpecificInputImpl) ReverseReplicationProviderSpecificInput() BaseReverseReplicationProviderSpecificInputImpl { + return s +} + +var _ ReverseReplicationProviderSpecificInput = RawReverseReplicationProviderSpecificInputImpl{} + +// RawReverseReplicationProviderSpecificInputImpl 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 RawReverseReplicationProviderSpecificInputImpl struct { + reverseReplicationProviderSpecificInput BaseReverseReplicationProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawReverseReplicationProviderSpecificInputImpl) ReverseReplicationProviderSpecificInput() BaseReverseReplicationProviderSpecificInputImpl { + return s.reverseReplicationProviderSpecificInput +} + +func UnmarshalReverseReplicationProviderSpecificInputImplementation(input []byte) (ReverseReplicationProviderSpecificInput, 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 ReverseReplicationProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AReprotectInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AReprotectInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureReprotectInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureReprotectInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2ReprotectInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2ReprotectInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcmFailback") { + var out InMageRcmFailbackReprotectInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFailbackReprotectInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmReprotectInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmReprotectInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out InMageReprotectInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageReprotectInput: %+v", err) + } + return out, nil + } + + var parent BaseReverseReplicationProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseReverseReplicationProviderSpecificInputImpl: %+v", err) + } + + return RawReverseReplicationProviderSpecificInputImpl{ + reverseReplicationProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_securityprofileproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_securityprofileproperties.go new file mode 100644 index 00000000000..d51860996d8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_securityprofileproperties.go @@ -0,0 +1,12 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityProfileProperties struct { + TargetVMConfidentialEncryption *SecurityConfiguration `json:"targetVmConfidentialEncryption,omitempty"` + TargetVMMonitoring *SecurityConfiguration `json:"targetVmMonitoring,omitempty"` + TargetVMSecureBoot *SecurityConfiguration `json:"targetVmSecureBoot,omitempty"` + TargetVMSecurityType *SecurityType `json:"targetVmSecurityType,omitempty"` + TargetVMTpm *SecurityConfiguration `json:"targetVmTpm,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_switchproviderinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_switchproviderinput.go new file mode 100644 index 00000000000..701b7dcfb6f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_switchproviderinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwitchProviderInput struct { + Properties *SwitchProviderInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_switchproviderinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_switchproviderinputproperties.go new file mode 100644 index 00000000000..6189d20b837 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_switchproviderinputproperties.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwitchProviderInputProperties struct { + ProviderSpecificDetails SwitchProviderProviderSpecificInput `json:"providerSpecificDetails"` + TargetInstanceType *string `json:"targetInstanceType,omitempty"` +} + +var _ json.Unmarshaler = &SwitchProviderInputProperties{} + +func (s *SwitchProviderInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + TargetInstanceType *string `json:"targetInstanceType,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.TargetInstanceType = decoded.TargetInstanceType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SwitchProviderInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalSwitchProviderProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'SwitchProviderInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_switchproviderproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_switchproviderproviderspecificinput.go new file mode 100644 index 00000000000..a30916cc168 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_switchproviderproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 SwitchProviderProviderSpecificInput interface { + SwitchProviderProviderSpecificInput() BaseSwitchProviderProviderSpecificInputImpl +} + +var _ SwitchProviderProviderSpecificInput = BaseSwitchProviderProviderSpecificInputImpl{} + +type BaseSwitchProviderProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseSwitchProviderProviderSpecificInputImpl) SwitchProviderProviderSpecificInput() BaseSwitchProviderProviderSpecificInputImpl { + return s +} + +var _ SwitchProviderProviderSpecificInput = RawSwitchProviderProviderSpecificInputImpl{} + +// RawSwitchProviderProviderSpecificInputImpl 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 RawSwitchProviderProviderSpecificInputImpl struct { + switchProviderProviderSpecificInput BaseSwitchProviderProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawSwitchProviderProviderSpecificInputImpl) SwitchProviderProviderSpecificInput() BaseSwitchProviderProviderSpecificInputImpl { + return s.switchProviderProviderSpecificInput +} + +func UnmarshalSwitchProviderProviderSpecificInputImplementation(input []byte) (SwitchProviderProviderSpecificInput, 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 SwitchProviderProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2SwitchProviderProviderInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2SwitchProviderProviderInput: %+v", err) + } + return out, nil + } + + var parent BaseSwitchProviderProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSwitchProviderProviderSpecificInputImpl: %+v", err) + } + + return RawSwitchProviderProviderSpecificInputImpl{ + switchProviderProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_testfailovercleanupinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_testfailovercleanupinput.go new file mode 100644 index 00000000000..29c6eb3256b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_testfailovercleanupinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestFailoverCleanupInput struct { + Properties TestFailoverCleanupInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_testfailovercleanupinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_testfailovercleanupinputproperties.go new file mode 100644 index 00000000000..9699a278467 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_testfailovercleanupinputproperties.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestFailoverCleanupInputProperties struct { + Comments *string `json:"comments,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_testfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_testfailoverinput.go new file mode 100644 index 00000000000..88eb28a5898 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_testfailoverinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestFailoverInput struct { + Properties TestFailoverInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_testfailoverinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_testfailoverinputproperties.go new file mode 100644 index 00000000000..e49d86c1c45 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_testfailoverinputproperties.go @@ -0,0 +1,48 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestFailoverInputProperties struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + NetworkId *string `json:"networkId,omitempty"` + NetworkType *string `json:"networkType,omitempty"` + ProviderSpecificDetails TestFailoverProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &TestFailoverInputProperties{} + +func (s *TestFailoverInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + NetworkId *string `json:"networkId,omitempty"` + NetworkType *string `json:"networkType,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + s.NetworkId = decoded.NetworkId + s.NetworkType = decoded.NetworkType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling TestFailoverInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalTestFailoverProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'TestFailoverInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_testfailoverproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_testfailoverproviderspecificinput.go new file mode 100644 index 00000000000..3ea707b3cc2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_testfailoverproviderspecificinput.go @@ -0,0 +1,107 @@ +package replicationprotecteditems + +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 TestFailoverProviderSpecificInput interface { + TestFailoverProviderSpecificInput() BaseTestFailoverProviderSpecificInputImpl +} + +var _ TestFailoverProviderSpecificInput = BaseTestFailoverProviderSpecificInputImpl{} + +type BaseTestFailoverProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseTestFailoverProviderSpecificInputImpl) TestFailoverProviderSpecificInput() BaseTestFailoverProviderSpecificInputImpl { + return s +} + +var _ TestFailoverProviderSpecificInput = RawTestFailoverProviderSpecificInputImpl{} + +// RawTestFailoverProviderSpecificInputImpl 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 RawTestFailoverProviderSpecificInputImpl struct { + testFailoverProviderSpecificInput BaseTestFailoverProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawTestFailoverProviderSpecificInputImpl) TestFailoverProviderSpecificInput() BaseTestFailoverProviderSpecificInputImpl { + return s.testFailoverProviderSpecificInput +} + +func UnmarshalTestFailoverProviderSpecificInputImplementation(input []byte) (TestFailoverProviderSpecificInput, 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 TestFailoverProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2ATestFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ATestFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureTestFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureTestFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2TestFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2TestFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmTestFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmTestFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out InMageTestFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageTestFailoverInput: %+v", err) + } + return out, nil + } + + var parent BaseTestFailoverProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseTestFailoverProviderSpecificInputImpl: %+v", err) + } + + return RawTestFailoverProviderSpecificInputImpl{ + testFailoverProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_unplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_unplannedfailoverinput.go new file mode 100644 index 00000000000..12ae4f94f48 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_unplannedfailoverinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnplannedFailoverInput struct { + Properties UnplannedFailoverInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_unplannedfailoverinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_unplannedfailoverinputproperties.go new file mode 100644 index 00000000000..48640dc991d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_unplannedfailoverinputproperties.go @@ -0,0 +1,45 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnplannedFailoverInputProperties struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + ProviderSpecificDetails UnplannedFailoverProviderSpecificInput `json:"providerSpecificDetails"` + SourceSiteOperations *string `json:"sourceSiteOperations,omitempty"` +} + +var _ json.Unmarshaler = &UnplannedFailoverInputProperties{} + +func (s *UnplannedFailoverInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + SourceSiteOperations *string `json:"sourceSiteOperations,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + s.SourceSiteOperations = decoded.SourceSiteOperations + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling UnplannedFailoverInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalUnplannedFailoverProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'UnplannedFailoverInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_unplannedfailoverproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_unplannedfailoverproviderspecificinput.go new file mode 100644 index 00000000000..2d97495c032 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_unplannedfailoverproviderspecificinput.go @@ -0,0 +1,107 @@ +package replicationprotecteditems + +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 UnplannedFailoverProviderSpecificInput interface { + UnplannedFailoverProviderSpecificInput() BaseUnplannedFailoverProviderSpecificInputImpl +} + +var _ UnplannedFailoverProviderSpecificInput = BaseUnplannedFailoverProviderSpecificInputImpl{} + +type BaseUnplannedFailoverProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseUnplannedFailoverProviderSpecificInputImpl) UnplannedFailoverProviderSpecificInput() BaseUnplannedFailoverProviderSpecificInputImpl { + return s +} + +var _ UnplannedFailoverProviderSpecificInput = RawUnplannedFailoverProviderSpecificInputImpl{} + +// RawUnplannedFailoverProviderSpecificInputImpl 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 RawUnplannedFailoverProviderSpecificInputImpl struct { + unplannedFailoverProviderSpecificInput BaseUnplannedFailoverProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawUnplannedFailoverProviderSpecificInputImpl) UnplannedFailoverProviderSpecificInput() BaseUnplannedFailoverProviderSpecificInputImpl { + return s.unplannedFailoverProviderSpecificInput +} + +func UnmarshalUnplannedFailoverProviderSpecificInputImplementation(input []byte) (UnplannedFailoverProviderSpecificInput, 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 UnplannedFailoverProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AUnplannedFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AUnplannedFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureUnplannedFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureUnplannedFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2UnplannedFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2UnplannedFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmUnplannedFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmUnplannedFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out InMageUnplannedFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageUnplannedFailoverInput: %+v", err) + } + return out, nil + } + + var parent BaseUnplannedFailoverProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseUnplannedFailoverProviderSpecificInputImpl: %+v", err) + } + + return RawUnplannedFailoverProviderSpecificInputImpl{ + unplannedFailoverProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updateapplianceforreplicationprotectediteminput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updateapplianceforreplicationprotectediteminput.go new file mode 100644 index 00000000000..8bb8dbd243c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updateapplianceforreplicationprotectediteminput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateApplianceForReplicationProtectedItemInput struct { + Properties UpdateApplianceForReplicationProtectedItemInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updateapplianceforreplicationprotectediteminputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updateapplianceforreplicationprotectediteminputproperties.go new file mode 100644 index 00000000000..02ecc50d9ff --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updateapplianceforreplicationprotectediteminputproperties.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateApplianceForReplicationProtectedItemInputProperties struct { + ProviderSpecificDetails UpdateApplianceForReplicationProtectedItemProviderSpecificInput `json:"providerSpecificDetails"` + TargetApplianceId string `json:"targetApplianceId"` +} + +var _ json.Unmarshaler = &UpdateApplianceForReplicationProtectedItemInputProperties{} + +func (s *UpdateApplianceForReplicationProtectedItemInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + TargetApplianceId string `json:"targetApplianceId"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.TargetApplianceId = decoded.TargetApplianceId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling UpdateApplianceForReplicationProtectedItemInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalUpdateApplianceForReplicationProtectedItemProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'UpdateApplianceForReplicationProtectedItemInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updateapplianceforreplicationprotecteditemproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updateapplianceforreplicationprotecteditemproviderspecificinput.go new file mode 100644 index 00000000000..e6f03eb7aaa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updateapplianceforreplicationprotecteditemproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 UpdateApplianceForReplicationProtectedItemProviderSpecificInput interface { + UpdateApplianceForReplicationProtectedItemProviderSpecificInput() BaseUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl +} + +var _ UpdateApplianceForReplicationProtectedItemProviderSpecificInput = BaseUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl{} + +type BaseUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl) UpdateApplianceForReplicationProtectedItemProviderSpecificInput() BaseUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl { + return s +} + +var _ UpdateApplianceForReplicationProtectedItemProviderSpecificInput = RawUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl{} + +// RawUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl 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 RawUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl struct { + updateApplianceForReplicationProtectedItemProviderSpecificInput BaseUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl) UpdateApplianceForReplicationProtectedItemProviderSpecificInput() BaseUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl { + return s.updateApplianceForReplicationProtectedItemProviderSpecificInput +} + +func UnmarshalUpdateApplianceForReplicationProtectedItemProviderSpecificInputImplementation(input []byte) (UpdateApplianceForReplicationProtectedItemProviderSpecificInput, 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 UpdateApplianceForReplicationProtectedItemProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmUpdateApplianceForReplicationProtectedItemInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmUpdateApplianceForReplicationProtectedItemInput: %+v", err) + } + return out, nil + } + + var parent BaseUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl: %+v", err) + } + + return RawUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl{ + updateApplianceForReplicationProtectedItemProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updatediskinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updatediskinput.go new file mode 100644 index 00000000000..89c2747dd8b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updatediskinput.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateDiskInput struct { + DiskId string `json:"diskId"` + TargetDiskName *string `json:"targetDiskName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updatemobilityservicerequest.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updatemobilityservicerequest.go new file mode 100644 index 00000000000..88df4c561c1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updatemobilityservicerequest.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateMobilityServiceRequest struct { + Properties *UpdateMobilityServiceRequestProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updatemobilityservicerequestproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updatemobilityservicerequestproperties.go new file mode 100644 index 00000000000..bc5afdc6871 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updatemobilityservicerequestproperties.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateMobilityServiceRequestProperties struct { + RunAsAccountId *string `json:"runAsAccountId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updatereplicationprotectediteminput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updatereplicationprotectediteminput.go new file mode 100644 index 00000000000..6a33ddab87b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updatereplicationprotectediteminput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateReplicationProtectedItemInput struct { + Properties *UpdateReplicationProtectedItemInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updatereplicationprotectediteminputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updatereplicationprotectediteminputproperties.go new file mode 100644 index 00000000000..1bcbcbfe84e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updatereplicationprotectediteminputproperties.go @@ -0,0 +1,66 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateReplicationProtectedItemInputProperties struct { + EnableRdpOnTargetOption *string `json:"enableRdpOnTargetOption,omitempty"` + LicenseType *LicenseType `json:"licenseType,omitempty"` + ProviderSpecificDetails UpdateReplicationProtectedItemProviderInput `json:"providerSpecificDetails"` + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + RecoveryAzureVMName *string `json:"recoveryAzureVMName,omitempty"` + RecoveryAzureVMSize *string `json:"recoveryAzureVMSize,omitempty"` + SelectedRecoveryAzureNetworkId *string `json:"selectedRecoveryAzureNetworkId,omitempty"` + SelectedSourceNicId *string `json:"selectedSourceNicId,omitempty"` + SelectedTfoAzureNetworkId *string `json:"selectedTfoAzureNetworkId,omitempty"` + VMNics *[]VMNicInputDetails `json:"vmNics,omitempty"` +} + +var _ json.Unmarshaler = &UpdateReplicationProtectedItemInputProperties{} + +func (s *UpdateReplicationProtectedItemInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + EnableRdpOnTargetOption *string `json:"enableRdpOnTargetOption,omitempty"` + LicenseType *LicenseType `json:"licenseType,omitempty"` + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + RecoveryAzureVMName *string `json:"recoveryAzureVMName,omitempty"` + RecoveryAzureVMSize *string `json:"recoveryAzureVMSize,omitempty"` + SelectedRecoveryAzureNetworkId *string `json:"selectedRecoveryAzureNetworkId,omitempty"` + SelectedSourceNicId *string `json:"selectedSourceNicId,omitempty"` + SelectedTfoAzureNetworkId *string `json:"selectedTfoAzureNetworkId,omitempty"` + VMNics *[]VMNicInputDetails `json:"vmNics,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.EnableRdpOnTargetOption = decoded.EnableRdpOnTargetOption + s.LicenseType = decoded.LicenseType + s.RecoveryAvailabilitySetId = decoded.RecoveryAvailabilitySetId + s.RecoveryAzureVMName = decoded.RecoveryAzureVMName + s.RecoveryAzureVMSize = decoded.RecoveryAzureVMSize + s.SelectedRecoveryAzureNetworkId = decoded.SelectedRecoveryAzureNetworkId + s.SelectedSourceNicId = decoded.SelectedSourceNicId + s.SelectedTfoAzureNetworkId = decoded.SelectedTfoAzureNetworkId + s.VMNics = decoded.VMNics + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling UpdateReplicationProtectedItemInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalUpdateReplicationProtectedItemProviderInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'UpdateReplicationProtectedItemInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updatereplicationprotecteditemproviderinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updatereplicationprotecteditemproviderinput.go new file mode 100644 index 00000000000..de39df0cec7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_updatereplicationprotecteditemproviderinput.go @@ -0,0 +1,99 @@ +package replicationprotecteditems + +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 UpdateReplicationProtectedItemProviderInput interface { + UpdateReplicationProtectedItemProviderInput() BaseUpdateReplicationProtectedItemProviderInputImpl +} + +var _ UpdateReplicationProtectedItemProviderInput = BaseUpdateReplicationProtectedItemProviderInputImpl{} + +type BaseUpdateReplicationProtectedItemProviderInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseUpdateReplicationProtectedItemProviderInputImpl) UpdateReplicationProtectedItemProviderInput() BaseUpdateReplicationProtectedItemProviderInputImpl { + return s +} + +var _ UpdateReplicationProtectedItemProviderInput = RawUpdateReplicationProtectedItemProviderInputImpl{} + +// RawUpdateReplicationProtectedItemProviderInputImpl 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 RawUpdateReplicationProtectedItemProviderInputImpl struct { + updateReplicationProtectedItemProviderInput BaseUpdateReplicationProtectedItemProviderInputImpl + Type string + Values map[string]interface{} +} + +func (s RawUpdateReplicationProtectedItemProviderInputImpl) UpdateReplicationProtectedItemProviderInput() BaseUpdateReplicationProtectedItemProviderInputImpl { + return s.updateReplicationProtectedItemProviderInput +} + +func UnmarshalUpdateReplicationProtectedItemProviderInputImplementation(input []byte) (UpdateReplicationProtectedItemProviderInput, 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 UpdateReplicationProtectedItemProviderInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AUpdateReplicationProtectedItemInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AUpdateReplicationProtectedItemInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureUpdateReplicationProtectedItemInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureUpdateReplicationProtectedItemInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2UpdateReplicationProtectedItemInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2UpdateReplicationProtectedItemInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmUpdateReplicationProtectedItemInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmUpdateReplicationProtectedItemInput: %+v", err) + } + return out, nil + } + + var parent BaseUpdateReplicationProtectedItemProviderInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseUpdateReplicationProtectedItemProviderInputImpl: %+v", err) + } + + return RawUpdateReplicationProtectedItemProviderInputImpl{ + updateReplicationProtectedItemProviderInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_usercreatedresourcetag.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_usercreatedresourcetag.go new file mode 100644 index 00000000000..675f4368cc0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_usercreatedresourcetag.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserCreatedResourceTag struct { + TagName *string `json:"tagName,omitempty"` + TagValue *string `json:"tagValue,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_vmnicdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_vmnicdetails.go new file mode 100644 index 00000000000..aa704f28341 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_vmnicdetails.go @@ -0,0 +1,26 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMNicDetails struct { + EnableAcceleratedNetworkingOnRecovery *bool `json:"enableAcceleratedNetworkingOnRecovery,omitempty"` + EnableAcceleratedNetworkingOnTfo *bool `json:"enableAcceleratedNetworkingOnTfo,omitempty"` + IPConfigs *[]IPConfigDetails `json:"ipConfigs,omitempty"` + NicId *string `json:"nicId,omitempty"` + RecoveryNetworkSecurityGroupId *string `json:"recoveryNetworkSecurityGroupId,omitempty"` + RecoveryNicName *string `json:"recoveryNicName,omitempty"` + RecoveryNicResourceGroupName *string `json:"recoveryNicResourceGroupName,omitempty"` + RecoveryVMNetworkId *string `json:"recoveryVMNetworkId,omitempty"` + ReplicaNicId *string `json:"replicaNicId,omitempty"` + ReuseExistingNic *bool `json:"reuseExistingNic,omitempty"` + SelectionType *string `json:"selectionType,omitempty"` + SourceNicArmId *string `json:"sourceNicArmId,omitempty"` + TargetNicName *string `json:"targetNicName,omitempty"` + TfoNetworkSecurityGroupId *string `json:"tfoNetworkSecurityGroupId,omitempty"` + TfoRecoveryNicName *string `json:"tfoRecoveryNicName,omitempty"` + TfoRecoveryNicResourceGroupName *string `json:"tfoRecoveryNicResourceGroupName,omitempty"` + TfoReuseExistingNic *bool `json:"tfoReuseExistingNic,omitempty"` + TfoVMNetworkId *string `json:"tfoVMNetworkId,omitempty"` + VMNetworkName *string `json:"vMNetworkName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_vmnicinputdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_vmnicinputdetails.go new file mode 100644 index 00000000000..7c18c51a759 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/model_vmnicinputdetails.go @@ -0,0 +1,21 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMNicInputDetails struct { + EnableAcceleratedNetworkingOnRecovery *bool `json:"enableAcceleratedNetworkingOnRecovery,omitempty"` + EnableAcceleratedNetworkingOnTfo *bool `json:"enableAcceleratedNetworkingOnTfo,omitempty"` + IPConfigs *[]IPConfigInputDetails `json:"ipConfigs,omitempty"` + NicId *string `json:"nicId,omitempty"` + RecoveryNetworkSecurityGroupId *string `json:"recoveryNetworkSecurityGroupId,omitempty"` + RecoveryNicName *string `json:"recoveryNicName,omitempty"` + RecoveryNicResourceGroupName *string `json:"recoveryNicResourceGroupName,omitempty"` + ReuseExistingNic *bool `json:"reuseExistingNic,omitempty"` + SelectionType *string `json:"selectionType,omitempty"` + TargetNicName *string `json:"targetNicName,omitempty"` + TfoNetworkSecurityGroupId *string `json:"tfoNetworkSecurityGroupId,omitempty"` + TfoNicName *string `json:"tfoNicName,omitempty"` + TfoNicResourceGroupName *string `json:"tfoNicResourceGroupName,omitempty"` + TfoReuseExistingNic *bool `json:"tfoReuseExistingNic,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/predicates.go new file mode 100644 index 00000000000..533da5b6f5e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/predicates.go @@ -0,0 +1,32 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProtectedItemOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ReplicationProtectedItemOperationPredicate) Matches(input ReplicationProtectedItem) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/version.go new file mode 100644 index 00000000000..b188b94b5cc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotecteditems/version.go @@ -0,0 +1,10 @@ +package replicationprotecteditems + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationprotecteditems/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/README.md new file mode 100644 index 00000000000..1eade536e4c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/README.md @@ -0,0 +1,191 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters` Documentation + +The `replicationprotectionclusters` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters" +``` + + +### Client Initialization + +```go +client := replicationprotectionclusters.NewReplicationProtectionClustersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationProtectionClustersClient.ApplyRecoveryPoint` + +```go +ctx := context.TODO() +id := replicationprotectionclusters.NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + +payload := replicationprotectionclusters.ApplyClusterRecoveryPointInput{ + // ... +} + + +if err := client.ApplyRecoveryPointThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionClustersClient.Create` + +```go +ctx := context.TODO() +id := replicationprotectionclusters.NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + +payload := replicationprotectionclusters.ReplicationProtectionCluster{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionClustersClient.FailoverCommit` + +```go +ctx := context.TODO() +id := replicationprotectionclusters.NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + +if err := client.FailoverCommitThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionClustersClient.Get` + +```go +ctx := context.TODO() +id := replicationprotectionclusters.NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + +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: `ReplicationProtectionClustersClient.List` + +```go +ctx := context.TODO() +id := replicationprotectionclusters.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id, replicationprotectionclusters.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, replicationprotectionclusters.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationProtectionClustersClient.ListByReplicationProtectionContainers` + +```go +ctx := context.TODO() +id := replicationprotectionclusters.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + +// alternatively `client.ListByReplicationProtectionContainers(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationProtectionContainersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationProtectionClustersClient.Purge` + +```go +ctx := context.TODO() +id := replicationprotectionclusters.NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + +if err := client.PurgeThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionClustersClient.RepairReplication` + +```go +ctx := context.TODO() +id := replicationprotectionclusters.NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + +if err := client.RepairReplicationThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionClustersClient.TestFailover` + +```go +ctx := context.TODO() +id := replicationprotectionclusters.NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + +payload := replicationprotectionclusters.ClusterTestFailoverInput{ + // ... +} + + +if err := client.TestFailoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionClustersClient.TestFailoverCleanup` + +```go +ctx := context.TODO() +id := replicationprotectionclusters.NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + +payload := replicationprotectionclusters.ClusterTestFailoverCleanupInput{ + // ... +} + + +if err := client.TestFailoverCleanupThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionClustersClient.UnplannedFailover` + +```go +ctx := context.TODO() +id := replicationprotectionclusters.NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + +payload := replicationprotectionclusters.ClusterUnplannedFailoverInput{ + // ... +} + + +if err := client.UnplannedFailoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/client.go new file mode 100644 index 00000000000..0b827715b54 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/client.go @@ -0,0 +1,26 @@ +package replicationprotectionclusters + +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 ReplicationProtectionClustersClient struct { + Client *resourcemanager.Client +} + +func NewReplicationProtectionClustersClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationProtectionClustersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationprotectionclusters", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationProtectionClustersClient: %+v", err) + } + + return &ReplicationProtectionClustersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/constants.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/constants.go new file mode 100644 index 00000000000..118ab2f7fb9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/constants.go @@ -0,0 +1,174 @@ +package replicationprotectionclusters + +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 AutoProtectionOfDataDisk string + +const ( + AutoProtectionOfDataDiskDisabled AutoProtectionOfDataDisk = "Disabled" + AutoProtectionOfDataDiskEnabled AutoProtectionOfDataDisk = "Enabled" +) + +func PossibleValuesForAutoProtectionOfDataDisk() []string { + return []string{ + string(AutoProtectionOfDataDiskDisabled), + string(AutoProtectionOfDataDiskEnabled), + } +} + +func (s *AutoProtectionOfDataDisk) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoProtectionOfDataDisk(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoProtectionOfDataDisk(input string) (*AutoProtectionOfDataDisk, error) { + vals := map[string]AutoProtectionOfDataDisk{ + "disabled": AutoProtectionOfDataDiskDisabled, + "enabled": AutoProtectionOfDataDiskEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoProtectionOfDataDisk(input) + return &out, nil +} + +type FailoverDirection string + +const ( + FailoverDirectionPrimaryToRecovery FailoverDirection = "PrimaryToRecovery" + FailoverDirectionRecoveryToPrimary FailoverDirection = "RecoveryToPrimary" +) + +func PossibleValuesForFailoverDirection() []string { + return []string{ + string(FailoverDirectionPrimaryToRecovery), + string(FailoverDirectionRecoveryToPrimary), + } +} + +func (s *FailoverDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFailoverDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFailoverDirection(input string) (*FailoverDirection, error) { + vals := map[string]FailoverDirection{ + "primarytorecovery": FailoverDirectionPrimaryToRecovery, + "recoverytoprimary": FailoverDirectionRecoveryToPrimary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FailoverDirection(input) + return &out, nil +} + +type HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} + +type MultiVMGroupCreateOption string + +const ( + MultiVMGroupCreateOptionAutoCreated MultiVMGroupCreateOption = "AutoCreated" + MultiVMGroupCreateOptionUserSpecified MultiVMGroupCreateOption = "UserSpecified" +) + +func PossibleValuesForMultiVMGroupCreateOption() []string { + return []string{ + string(MultiVMGroupCreateOptionAutoCreated), + string(MultiVMGroupCreateOptionUserSpecified), + } +} + +func (s *MultiVMGroupCreateOption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMultiVMGroupCreateOption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMultiVMGroupCreateOption(input string) (*MultiVMGroupCreateOption, error) { + vals := map[string]MultiVMGroupCreateOption{ + "autocreated": MultiVMGroupCreateOptionAutoCreated, + "userspecified": MultiVMGroupCreateOptionUserSpecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MultiVMGroupCreateOption(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/id_replicationprotectioncluster.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/id_replicationprotectioncluster.go new file mode 100644 index 00000000000..2f390968800 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/id_replicationprotectioncluster.go @@ -0,0 +1,157 @@ +package replicationprotectionclusters + +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(&ReplicationProtectionClusterId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectionClusterId{} + +// ReplicationProtectionClusterId is a struct representing the Resource ID for a Replication Protection Cluster +type ReplicationProtectionClusterId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectionClusterName string +} + +// NewReplicationProtectionClusterID returns a new ReplicationProtectionClusterId struct +func NewReplicationProtectionClusterID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectionClusterName string) ReplicationProtectionClusterId { + return ReplicationProtectionClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectionClusterName: replicationProtectionClusterName, + } +} + +// ParseReplicationProtectionClusterID parses 'input' into a ReplicationProtectionClusterId +func ParseReplicationProtectionClusterID(input string) (*ReplicationProtectionClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionClusterIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionClusterId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionClusterIDInsensitively(input string) (*ReplicationProtectionClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionClusterId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectionClusterName, ok = input.Parsed["replicationProtectionClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionClusterName", input) + } + + return nil +} + +// ValidateReplicationProtectionClusterID checks that 'input' can be parsed as a Replication Protection Cluster ID +func ValidateReplicationProtectionClusterID(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 := ParseReplicationProtectionClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Cluster ID +func (id ReplicationProtectionClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectionClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectionClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Cluster ID +func (id ReplicationProtectionClusterId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationProtectionClusters", "replicationProtectionClusters", "replicationProtectionClusters"), + resourceids.UserSpecifiedSegment("replicationProtectionClusterName", "replicationProtectionClusterName"), + } +} + +// String returns a human-readable description of this Replication Protection Cluster ID +func (id ReplicationProtectionClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protection Cluster Name: %q", id.ReplicationProtectionClusterName), + } + return fmt.Sprintf("Replication Protection Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/id_replicationprotectioncluster_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/id_replicationprotectioncluster_test.go new file mode 100644 index 00000000000..51d21c9522d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/id_replicationprotectioncluster_test.go @@ -0,0 +1,417 @@ +package replicationprotectionclusters + +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 = &ReplicationProtectionClusterId{} + +func TestNewReplicationProtectionClusterID(t *testing.T) { + id := NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationProtectionClusterName != "replicationProtectionClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionClusterName'", id.ReplicationProtectionClusterName, "replicationProtectionClusterName") + } +} + +func TestFormatReplicationProtectionClusterID(t *testing.T) { + actual := NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName", + Expected: &ReplicationProtectionClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectionClusterName: "replicationProtectionClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionClusterID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectionClusterName != v.Expected.ReplicationProtectionClusterName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionClusterName", v.Expected.ReplicationProtectionClusterName, actual.ReplicationProtectionClusterName) + } + + } +} + +func TestParseReplicationProtectionClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnClUsTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName", + Expected: &ReplicationProtectionClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectionClusterName: "replicationProtectionClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnClUsTeRs/rEpLiCaTiOnPrOtEcTiOnClUsTeRnAmE", + Expected: &ReplicationProtectionClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationProtectionClusterName: "rEpLiCaTiOnPrOtEcTiOnClUsTeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnClUsTeRs/rEpLiCaTiOnPrOtEcTiOnClUsTeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionClusterIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectionClusterName != v.Expected.ReplicationProtectionClusterName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionClusterName", v.Expected.ReplicationProtectionClusterName, actual.ReplicationProtectionClusterName) + } + + } +} + +func TestSegmentsForReplicationProtectionClusterId(t *testing.T) { + segments := ReplicationProtectionClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionClusterId 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/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/id_replicationprotectioncontainer.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/id_replicationprotectioncontainer.go new file mode 100644 index 00000000000..e6dc5092a4b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/id_replicationprotectioncontainer.go @@ -0,0 +1,148 @@ +package replicationprotectionclusters + +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(&ReplicationProtectionContainerId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectionContainerId{} + +// ReplicationProtectionContainerId is a struct representing the Resource ID for a Replication Protection Container +type ReplicationProtectionContainerId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string +} + +// NewReplicationProtectionContainerID returns a new ReplicationProtectionContainerId struct +func NewReplicationProtectionContainerID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string) ReplicationProtectionContainerId { + return ReplicationProtectionContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + } +} + +// ParseReplicationProtectionContainerID parses 'input' into a ReplicationProtectionContainerId +func ParseReplicationProtectionContainerID(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionContainerIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionContainerId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionContainerIDInsensitively(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionContainerId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + return nil +} + +// ValidateReplicationProtectionContainerID checks that 'input' can be parsed as a Replication Protection Container ID +func ValidateReplicationProtectionContainerID(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 := ParseReplicationProtectionContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Container ID +func (id ReplicationProtectionContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Container ID +func (id ReplicationProtectionContainerId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + } +} + +// String returns a human-readable description of this Replication Protection Container ID +func (id ReplicationProtectionContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + } + return fmt.Sprintf("Replication Protection Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/id_replicationprotectioncontainer_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/id_replicationprotectioncontainer_test.go new file mode 100644 index 00000000000..0a7fb19397c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/id_replicationprotectioncontainer_test.go @@ -0,0 +1,372 @@ +package replicationprotectionclusters + +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 = &ReplicationProtectionContainerId{} + +func TestNewReplicationProtectionContainerID(t *testing.T) { + id := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } +} + +func TestFormatReplicationProtectionContainerID(t *testing.T) { + actual := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestParseReplicationProtectionContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestSegmentsForReplicationProtectionContainerId(t *testing.T) { + segments := ReplicationProtectionContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionContainerId 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/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/id_vault.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/id_vault.go new file mode 100644 index 00000000000..cc7c01caea9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/id_vault.go @@ -0,0 +1,130 @@ +package replicationprotectionclusters + +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(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(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 := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/id_vault_test.go new file mode 100644 index 00000000000..c0019a94ada --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationprotectionclusters + +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 = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId 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/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_applyrecoverypoint.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_applyrecoverypoint.go new file mode 100644 index 00000000000..09bbe7917ee --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_applyrecoverypoint.go @@ -0,0 +1,75 @@ +package replicationprotectionclusters + +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 ApplyRecoveryPointOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectionCluster +} + +// ApplyRecoveryPoint ... +func (c ReplicationProtectionClustersClient) ApplyRecoveryPoint(ctx context.Context, id ReplicationProtectionClusterId, input ApplyClusterRecoveryPointInput) (result ApplyRecoveryPointOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/applyRecoveryPoint", 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 +} + +// ApplyRecoveryPointThenPoll performs ApplyRecoveryPoint then polls until it's completed +func (c ReplicationProtectionClustersClient) ApplyRecoveryPointThenPoll(ctx context.Context, id ReplicationProtectionClusterId, input ApplyClusterRecoveryPointInput) error { + result, err := c.ApplyRecoveryPoint(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ApplyRecoveryPoint: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ApplyRecoveryPoint: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_create.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_create.go new file mode 100644 index 00000000000..457b9ec6bc1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_create.go @@ -0,0 +1,75 @@ +package replicationprotectionclusters + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectionCluster +} + +// Create ... +func (c ReplicationProtectionClustersClient) Create(ctx context.Context, id ReplicationProtectionClusterId, input ReplicationProtectionCluster) (result CreateOperationResponse, 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationProtectionClustersClient) CreateThenPoll(ctx context.Context, id ReplicationProtectionClusterId, input ReplicationProtectionCluster) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_failovercommit.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_failovercommit.go new file mode 100644 index 00000000000..0262815801a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_failovercommit.go @@ -0,0 +1,71 @@ +package replicationprotectionclusters + +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 FailoverCommitOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectionCluster +} + +// FailoverCommit ... +func (c ReplicationProtectionClustersClient) FailoverCommit(ctx context.Context, id ReplicationProtectionClusterId) (result FailoverCommitOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/failoverCommit", 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 +} + +// FailoverCommitThenPoll performs FailoverCommit then polls until it's completed +func (c ReplicationProtectionClustersClient) FailoverCommitThenPoll(ctx context.Context, id ReplicationProtectionClusterId) error { + result, err := c.FailoverCommit(ctx, id) + if err != nil { + return fmt.Errorf("performing FailoverCommit: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after FailoverCommit: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_get.go new file mode 100644 index 00000000000..21d0209de27 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_get.go @@ -0,0 +1,53 @@ +package replicationprotectionclusters + +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 *ReplicationProtectionCluster +} + +// Get ... +func (c ReplicationProtectionClustersClient) Get(ctx context.Context, id ReplicationProtectionClusterId) (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 ReplicationProtectionCluster + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_list.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_list.go new file mode 100644 index 00000000000..006c98e0ece --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_list.go @@ -0,0 +1,138 @@ +package replicationprotectionclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReplicationProtectionCluster +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ReplicationProtectionCluster +} + +type ListOperationOptions struct { + Filter *string + SkipToken *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.SkipToken != nil { + out.Append("skipToken", fmt.Sprintf("%v", *o.SkipToken)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ReplicationProtectionClustersClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/replicationProtectionClusters", 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 *[]ReplicationProtectionCluster `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationProtectionClustersClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ReplicationProtectionClusterOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectionClustersClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate ReplicationProtectionClusterOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ReplicationProtectionCluster, 0) + + resp, err := c.List(ctx, id, options) + 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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_listbyreplicationprotectioncontainers.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_listbyreplicationprotectioncontainers.go new file mode 100644 index 00000000000..ec679c4b218 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_listbyreplicationprotectioncontainers.go @@ -0,0 +1,105 @@ +package replicationprotectionclusters + +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 ListByReplicationProtectionContainersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReplicationProtectionCluster +} + +type ListByReplicationProtectionContainersCompleteResult struct { + LatestHttpResponse *http.Response + Items []ReplicationProtectionCluster +} + +type ListByReplicationProtectionContainersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationProtectionContainersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationProtectionContainers ... +func (c ReplicationProtectionClustersClient) ListByReplicationProtectionContainers(ctx context.Context, id ReplicationProtectionContainerId) (result ListByReplicationProtectionContainersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationProtectionContainersCustomPager{}, + Path: fmt.Sprintf("%s/replicationProtectionClusters", 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 *[]ReplicationProtectionCluster `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationProtectionContainersComplete retrieves all the results into a single object +func (c ReplicationProtectionClustersClient) ListByReplicationProtectionContainersComplete(ctx context.Context, id ReplicationProtectionContainerId) (ListByReplicationProtectionContainersCompleteResult, error) { + return c.ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx, id, ReplicationProtectionClusterOperationPredicate{}) +} + +// ListByReplicationProtectionContainersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectionClustersClient) ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx context.Context, id ReplicationProtectionContainerId, predicate ReplicationProtectionClusterOperationPredicate) (result ListByReplicationProtectionContainersCompleteResult, err error) { + items := make([]ReplicationProtectionCluster, 0) + + resp, err := c.ListByReplicationProtectionContainers(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 = ListByReplicationProtectionContainersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_purge.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_purge.go new file mode 100644 index 00000000000..93ef7814b77 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_purge.go @@ -0,0 +1,70 @@ +package replicationprotectionclusters + +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 PurgeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Purge ... +func (c ReplicationProtectionClustersClient) Purge(ctx context.Context, id ReplicationProtectionClusterId) (result PurgeOperationResponse, 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 +} + +// PurgeThenPoll performs Purge then polls until it's completed +func (c ReplicationProtectionClustersClient) PurgeThenPoll(ctx context.Context, id ReplicationProtectionClusterId) error { + result, err := c.Purge(ctx, id) + if err != nil { + return fmt.Errorf("performing Purge: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Purge: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_repairreplication.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_repairreplication.go new file mode 100644 index 00000000000..91457971e2a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_repairreplication.go @@ -0,0 +1,71 @@ +package replicationprotectionclusters + +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 RepairReplicationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectionCluster +} + +// RepairReplication ... +func (c ReplicationProtectionClustersClient) RepairReplication(ctx context.Context, id ReplicationProtectionClusterId) (result RepairReplicationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/repairReplication", 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 +} + +// RepairReplicationThenPoll performs RepairReplication then polls until it's completed +func (c ReplicationProtectionClustersClient) RepairReplicationThenPoll(ctx context.Context, id ReplicationProtectionClusterId) error { + result, err := c.RepairReplication(ctx, id) + if err != nil { + return fmt.Errorf("performing RepairReplication: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RepairReplication: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_testfailover.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_testfailover.go new file mode 100644 index 00000000000..e17d6e94e62 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_testfailover.go @@ -0,0 +1,75 @@ +package replicationprotectionclusters + +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 TestFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectionCluster +} + +// TestFailover ... +func (c ReplicationProtectionClustersClient) TestFailover(ctx context.Context, id ReplicationProtectionClusterId, input ClusterTestFailoverInput) (result TestFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testFailover", 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 +} + +// TestFailoverThenPoll performs TestFailover then polls until it's completed +func (c ReplicationProtectionClustersClient) TestFailoverThenPoll(ctx context.Context, id ReplicationProtectionClusterId, input ClusterTestFailoverInput) error { + result, err := c.TestFailover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TestFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TestFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_testfailovercleanup.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_testfailovercleanup.go new file mode 100644 index 00000000000..cb6b2b2036d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_testfailovercleanup.go @@ -0,0 +1,75 @@ +package replicationprotectionclusters + +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 TestFailoverCleanupOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectionCluster +} + +// TestFailoverCleanup ... +func (c ReplicationProtectionClustersClient) TestFailoverCleanup(ctx context.Context, id ReplicationProtectionClusterId, input ClusterTestFailoverCleanupInput) (result TestFailoverCleanupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testFailoverCleanup", 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 +} + +// TestFailoverCleanupThenPoll performs TestFailoverCleanup then polls until it's completed +func (c ReplicationProtectionClustersClient) TestFailoverCleanupThenPoll(ctx context.Context, id ReplicationProtectionClusterId, input ClusterTestFailoverCleanupInput) error { + result, err := c.TestFailoverCleanup(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TestFailoverCleanup: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TestFailoverCleanup: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_unplannedfailover.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_unplannedfailover.go new file mode 100644 index 00000000000..291c3933255 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/method_unplannedfailover.go @@ -0,0 +1,75 @@ +package replicationprotectionclusters + +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 UnplannedFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectionCluster +} + +// UnplannedFailover ... +func (c ReplicationProtectionClustersClient) UnplannedFailover(ctx context.Context, id ReplicationProtectionClusterId, input ClusterUnplannedFailoverInput) (result UnplannedFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/unplannedFailover", 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 +} + +// UnplannedFailoverThenPoll performs UnplannedFailover then polls until it's completed +func (c ReplicationProtectionClustersClient) UnplannedFailoverThenPoll(ctx context.Context, id ReplicationProtectionClusterId, input ClusterUnplannedFailoverInput) error { + result, err := c.UnplannedFailover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UnplannedFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UnplannedFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2aapplyclusterrecoverypointinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2aapplyclusterrecoverypointinput.go new file mode 100644 index 00000000000..d6cdb3e3030 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2aapplyclusterrecoverypointinput.go @@ -0,0 +1,49 @@ +package replicationprotectionclusters + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ApplyClusterRecoveryPointProviderSpecificInput = A2AApplyClusterRecoveryPointInput{} + +type A2AApplyClusterRecoveryPointInput struct { + + // Fields inherited from ApplyClusterRecoveryPointProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AApplyClusterRecoveryPointInput) ApplyClusterRecoveryPointProviderSpecificInput() BaseApplyClusterRecoveryPointProviderSpecificInputImpl { + return BaseApplyClusterRecoveryPointProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AApplyClusterRecoveryPointInput{} + +func (s A2AApplyClusterRecoveryPointInput) MarshalJSON() ([]byte, error) { + type wrapper A2AApplyClusterRecoveryPointInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AApplyClusterRecoveryPointInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AApplyClusterRecoveryPointInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AApplyClusterRecoveryPointInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2aclustertestfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2aclustertestfailoverinput.go new file mode 100644 index 00000000000..dc11ca955f1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2aclustertestfailoverinput.go @@ -0,0 +1,51 @@ +package replicationprotectionclusters + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ClusterTestFailoverProviderSpecificInput = A2AClusterTestFailoverInput{} + +type A2AClusterTestFailoverInput struct { + ClusterRecoveryPointId *string `json:"clusterRecoveryPointId,omitempty"` + IndividualNodeRecoveryPoints *[]string `json:"individualNodeRecoveryPoints,omitempty"` + + // Fields inherited from ClusterTestFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AClusterTestFailoverInput) ClusterTestFailoverProviderSpecificInput() BaseClusterTestFailoverProviderSpecificInputImpl { + return BaseClusterTestFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AClusterTestFailoverInput{} + +func (s A2AClusterTestFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper A2AClusterTestFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AClusterTestFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AClusterTestFailoverInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AClusterTestFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2aclusterunplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2aclusterunplannedfailoverinput.go new file mode 100644 index 00000000000..193f06824e4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2aclusterunplannedfailoverinput.go @@ -0,0 +1,51 @@ +package replicationprotectionclusters + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ClusterUnplannedFailoverProviderSpecificInput = A2AClusterUnplannedFailoverInput{} + +type A2AClusterUnplannedFailoverInput struct { + ClusterRecoveryPointId *string `json:"clusterRecoveryPointId,omitempty"` + IndividualNodeRecoveryPoints *[]string `json:"individualNodeRecoveryPoints,omitempty"` + + // Fields inherited from ClusterUnplannedFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AClusterUnplannedFailoverInput) ClusterUnplannedFailoverProviderSpecificInput() BaseClusterUnplannedFailoverProviderSpecificInputImpl { + return BaseClusterUnplannedFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AClusterUnplannedFailoverInput{} + +func (s A2AClusterUnplannedFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper A2AClusterUnplannedFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AClusterUnplannedFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AClusterUnplannedFailoverInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AClusterUnplannedFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2aprotectedmanageddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2aprotectedmanageddiskdetails.go new file mode 100644 index 00000000000..c419fd49ad2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2aprotectedmanageddiskdetails.go @@ -0,0 +1,35 @@ +package replicationprotectionclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AProtectedManagedDiskDetails struct { + AllowedDiskLevelOperation *[]string `json:"allowedDiskLevelOperation,omitempty"` + DataPendingAtSourceAgentInMB *float64 `json:"dataPendingAtSourceAgentInMB,omitempty"` + DataPendingInStagingStorageAccountInMB *float64 `json:"dataPendingInStagingStorageAccountInMB,omitempty"` + DekKeyVaultArmId *string `json:"dekKeyVaultArmId,omitempty"` + DiskCapacityInBytes *int64 `json:"diskCapacityInBytes,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskState *string `json:"diskState,omitempty"` + DiskType *string `json:"diskType,omitempty"` + FailoverDiskName *string `json:"failoverDiskName,omitempty"` + IsDiskEncrypted *bool `json:"isDiskEncrypted,omitempty"` + IsDiskKeyEncrypted *bool `json:"isDiskKeyEncrypted,omitempty"` + KekKeyVaultArmId *string `json:"kekKeyVaultArmId,omitempty"` + KeyIdentifier *string `json:"keyIdentifier,omitempty"` + MonitoringJobType *string `json:"monitoringJobType,omitempty"` + MonitoringPercentageCompletion *int64 `json:"monitoringPercentageCompletion,omitempty"` + PrimaryDiskEncryptionSetId *string `json:"primaryDiskEncryptionSetId,omitempty"` + PrimaryStagingAzureStorageAccountId *string `json:"primaryStagingAzureStorageAccountId,omitempty"` + RecoveryDiskEncryptionSetId *string `json:"recoveryDiskEncryptionSetId,omitempty"` + RecoveryOrignalTargetDiskId *string `json:"recoveryOrignalTargetDiskId,omitempty"` + RecoveryReplicaDiskAccountType *string `json:"recoveryReplicaDiskAccountType,omitempty"` + RecoveryReplicaDiskId *string `json:"recoveryReplicaDiskId,omitempty"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + RecoveryTargetDiskAccountType *string `json:"recoveryTargetDiskAccountType,omitempty"` + RecoveryTargetDiskId *string `json:"recoveryTargetDiskId,omitempty"` + ResyncRequired *bool `json:"resyncRequired,omitempty"` + SecretIdentifier *string `json:"secretIdentifier,omitempty"` + TfoDiskName *string `json:"tfoDiskName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2areplicationprotectionclusterdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2areplicationprotectionclusterdetails.go new file mode 100644 index 00000000000..2a04b366aca --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2areplicationprotectionclusterdetails.go @@ -0,0 +1,71 @@ +package replicationprotectionclusters + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationClusterProviderSpecificSettings = A2AReplicationProtectionClusterDetails{} + +type A2AReplicationProtectionClusterDetails struct { + ClusterManagementId *string `json:"clusterManagementId,omitempty"` + FailoverRecoveryPointId *string `json:"failoverRecoveryPointId,omitempty"` + InitialPrimaryExtendedLocation *edgezones.Model `json:"initialPrimaryExtendedLocation,omitempty"` + InitialPrimaryFabricLocation *string `json:"initialPrimaryFabricLocation,omitempty"` + InitialPrimaryZone *string `json:"initialPrimaryZone,omitempty"` + InitialRecoveryExtendedLocation *edgezones.Model `json:"initialRecoveryExtendedLocation,omitempty"` + InitialRecoveryFabricLocation *string `json:"initialRecoveryFabricLocation,omitempty"` + InitialRecoveryZone *string `json:"initialRecoveryZone,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + LifecycleId *string `json:"lifecycleId,omitempty"` + MultiVMGroupCreateOption *MultiVMGroupCreateOption `json:"multiVmGroupCreateOption,omitempty"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + PrimaryAvailabilityZone *string `json:"primaryAvailabilityZone,omitempty"` + PrimaryExtendedLocation *edgezones.Model `json:"primaryExtendedLocation,omitempty"` + PrimaryFabricLocation *string `json:"primaryFabricLocation,omitempty"` + RecoveryAvailabilityZone *string `json:"recoveryAvailabilityZone,omitempty"` + RecoveryExtendedLocation *edgezones.Model `json:"recoveryExtendedLocation,omitempty"` + RecoveryFabricLocation *string `json:"recoveryFabricLocation,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + + // Fields inherited from ReplicationClusterProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s A2AReplicationProtectionClusterDetails) ReplicationClusterProviderSpecificSettings() BaseReplicationClusterProviderSpecificSettingsImpl { + return BaseReplicationClusterProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AReplicationProtectionClusterDetails{} + +func (s A2AReplicationProtectionClusterDetails) MarshalJSON() ([]byte, error) { + type wrapper A2AReplicationProtectionClusterDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AReplicationProtectionClusterDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AReplicationProtectionClusterDetails: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AReplicationProtectionClusterDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2ashareddiskirerrordetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2ashareddiskirerrordetails.go new file mode 100644 index 00000000000..b48c423892c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2ashareddiskirerrordetails.go @@ -0,0 +1,12 @@ +package replicationprotectionclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2ASharedDiskIRErrorDetails struct { + ErrorCode *string `json:"errorCode,omitempty"` + ErrorCodeEnum *string `json:"errorCodeEnum,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2ashareddiskreplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2ashareddiskreplicationdetails.go new file mode 100644 index 00000000000..8532960ff6a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2ashareddiskreplicationdetails.go @@ -0,0 +1,60 @@ +package replicationprotectionclusters + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SharedDiskReplicationProviderSpecificSettings = A2ASharedDiskReplicationDetails{} + +type A2ASharedDiskReplicationDetails struct { + FailoverRecoveryPointId *string `json:"failoverRecoveryPointId,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + ManagementId *string `json:"managementId,omitempty"` + MonitoringJobType *string `json:"monitoringJobType,omitempty"` + MonitoringPercentageCompletion *int64 `json:"monitoringPercentageCompletion,omitempty"` + PrimaryFabricLocation *string `json:"primaryFabricLocation,omitempty"` + ProtectedManagedDisks *[]A2AProtectedManagedDiskDetails `json:"protectedManagedDisks,omitempty"` + RecoveryFabricLocation *string `json:"recoveryFabricLocation,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + SharedDiskIRErrors *[]A2ASharedDiskIRErrorDetails `json:"sharedDiskIRErrors,omitempty"` + UnprotectedDisks *[]A2AUnprotectedDiskDetails `json:"unprotectedDisks,omitempty"` + + // Fields inherited from SharedDiskReplicationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s A2ASharedDiskReplicationDetails) SharedDiskReplicationProviderSpecificSettings() BaseSharedDiskReplicationProviderSpecificSettingsImpl { + return BaseSharedDiskReplicationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ASharedDiskReplicationDetails{} + +func (s A2ASharedDiskReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper A2ASharedDiskReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ASharedDiskReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ASharedDiskReplicationDetails: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ASharedDiskReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2aunprotecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2aunprotecteddiskdetails.go new file mode 100644 index 00000000000..1a470d445cf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_a2aunprotecteddiskdetails.go @@ -0,0 +1,9 @@ +package replicationprotectionclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AUnprotectedDiskDetails struct { + DiskAutoProtectionStatus *AutoProtectionOfDataDisk `json:"diskAutoProtectionStatus,omitempty"` + DiskLunId *int64 `json:"diskLunId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_applyclusterrecoverypointinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_applyclusterrecoverypointinput.go new file mode 100644 index 00000000000..c281b09c9bf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_applyclusterrecoverypointinput.go @@ -0,0 +1,8 @@ +package replicationprotectionclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplyClusterRecoveryPointInput struct { + Properties ApplyClusterRecoveryPointInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_applyclusterrecoverypointinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_applyclusterrecoverypointinputproperties.go new file mode 100644 index 00000000000..6f4e17b8a4b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_applyclusterrecoverypointinputproperties.go @@ -0,0 +1,45 @@ +package replicationprotectionclusters + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplyClusterRecoveryPointInputProperties struct { + ClusterRecoveryPointId *string `json:"clusterRecoveryPointId,omitempty"` + IndividualNodeRecoveryPoints *[]string `json:"individualNodeRecoveryPoints,omitempty"` + ProviderSpecificDetails ApplyClusterRecoveryPointProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &ApplyClusterRecoveryPointInputProperties{} + +func (s *ApplyClusterRecoveryPointInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ClusterRecoveryPointId *string `json:"clusterRecoveryPointId,omitempty"` + IndividualNodeRecoveryPoints *[]string `json:"individualNodeRecoveryPoints,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ClusterRecoveryPointId = decoded.ClusterRecoveryPointId + s.IndividualNodeRecoveryPoints = decoded.IndividualNodeRecoveryPoints + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ApplyClusterRecoveryPointInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalApplyClusterRecoveryPointProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ApplyClusterRecoveryPointInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_applyclusterrecoverypointproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_applyclusterrecoverypointproviderspecificinput.go new file mode 100644 index 00000000000..a8bf8d19ab9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_applyclusterrecoverypointproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationprotectionclusters + +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 ApplyClusterRecoveryPointProviderSpecificInput interface { + ApplyClusterRecoveryPointProviderSpecificInput() BaseApplyClusterRecoveryPointProviderSpecificInputImpl +} + +var _ ApplyClusterRecoveryPointProviderSpecificInput = BaseApplyClusterRecoveryPointProviderSpecificInputImpl{} + +type BaseApplyClusterRecoveryPointProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseApplyClusterRecoveryPointProviderSpecificInputImpl) ApplyClusterRecoveryPointProviderSpecificInput() BaseApplyClusterRecoveryPointProviderSpecificInputImpl { + return s +} + +var _ ApplyClusterRecoveryPointProviderSpecificInput = RawApplyClusterRecoveryPointProviderSpecificInputImpl{} + +// RawApplyClusterRecoveryPointProviderSpecificInputImpl 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 RawApplyClusterRecoveryPointProviderSpecificInputImpl struct { + applyClusterRecoveryPointProviderSpecificInput BaseApplyClusterRecoveryPointProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawApplyClusterRecoveryPointProviderSpecificInputImpl) ApplyClusterRecoveryPointProviderSpecificInput() BaseApplyClusterRecoveryPointProviderSpecificInputImpl { + return s.applyClusterRecoveryPointProviderSpecificInput +} + +func UnmarshalApplyClusterRecoveryPointProviderSpecificInputImplementation(input []byte) (ApplyClusterRecoveryPointProviderSpecificInput, 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 ApplyClusterRecoveryPointProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AApplyClusterRecoveryPointInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AApplyClusterRecoveryPointInput: %+v", err) + } + return out, nil + } + + var parent BaseApplyClusterRecoveryPointProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseApplyClusterRecoveryPointProviderSpecificInputImpl: %+v", err) + } + + return RawApplyClusterRecoveryPointProviderSpecificInputImpl{ + applyClusterRecoveryPointProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clustertestfailovercleanupinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clustertestfailovercleanupinput.go new file mode 100644 index 00000000000..93ae8de96ec --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clustertestfailovercleanupinput.go @@ -0,0 +1,8 @@ +package replicationprotectionclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterTestFailoverCleanupInput struct { + Properties ClusterTestFailoverCleanupInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clustertestfailovercleanupinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clustertestfailovercleanupinputproperties.go new file mode 100644 index 00000000000..70381c1c3c8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clustertestfailovercleanupinputproperties.go @@ -0,0 +1,8 @@ +package replicationprotectionclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterTestFailoverCleanupInputProperties struct { + Comments *string `json:"comments,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clustertestfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clustertestfailoverinput.go new file mode 100644 index 00000000000..7599d6a69c3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clustertestfailoverinput.go @@ -0,0 +1,8 @@ +package replicationprotectionclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterTestFailoverInput struct { + Properties ClusterTestFailoverInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clustertestfailoverinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clustertestfailoverinputproperties.go new file mode 100644 index 00000000000..978eaa42cf2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clustertestfailoverinputproperties.go @@ -0,0 +1,48 @@ +package replicationprotectionclusters + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterTestFailoverInputProperties struct { + FailoverDirection *FailoverDirection `json:"failoverDirection,omitempty"` + NetworkId *string `json:"networkId,omitempty"` + NetworkType *string `json:"networkType,omitempty"` + ProviderSpecificDetails ClusterTestFailoverProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &ClusterTestFailoverInputProperties{} + +func (s *ClusterTestFailoverInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FailoverDirection *FailoverDirection `json:"failoverDirection,omitempty"` + NetworkId *string `json:"networkId,omitempty"` + NetworkType *string `json:"networkType,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + s.NetworkId = decoded.NetworkId + s.NetworkType = decoded.NetworkType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ClusterTestFailoverInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalClusterTestFailoverProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ClusterTestFailoverInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clustertestfailoverproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clustertestfailoverproviderspecificinput.go new file mode 100644 index 00000000000..e3a38850917 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clustertestfailoverproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationprotectionclusters + +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 ClusterTestFailoverProviderSpecificInput interface { + ClusterTestFailoverProviderSpecificInput() BaseClusterTestFailoverProviderSpecificInputImpl +} + +var _ ClusterTestFailoverProviderSpecificInput = BaseClusterTestFailoverProviderSpecificInputImpl{} + +type BaseClusterTestFailoverProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseClusterTestFailoverProviderSpecificInputImpl) ClusterTestFailoverProviderSpecificInput() BaseClusterTestFailoverProviderSpecificInputImpl { + return s +} + +var _ ClusterTestFailoverProviderSpecificInput = RawClusterTestFailoverProviderSpecificInputImpl{} + +// RawClusterTestFailoverProviderSpecificInputImpl 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 RawClusterTestFailoverProviderSpecificInputImpl struct { + clusterTestFailoverProviderSpecificInput BaseClusterTestFailoverProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawClusterTestFailoverProviderSpecificInputImpl) ClusterTestFailoverProviderSpecificInput() BaseClusterTestFailoverProviderSpecificInputImpl { + return s.clusterTestFailoverProviderSpecificInput +} + +func UnmarshalClusterTestFailoverProviderSpecificInputImplementation(input []byte) (ClusterTestFailoverProviderSpecificInput, 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 ClusterTestFailoverProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AClusterTestFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AClusterTestFailoverInput: %+v", err) + } + return out, nil + } + + var parent BaseClusterTestFailoverProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseClusterTestFailoverProviderSpecificInputImpl: %+v", err) + } + + return RawClusterTestFailoverProviderSpecificInputImpl{ + clusterTestFailoverProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clusterunplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clusterunplannedfailoverinput.go new file mode 100644 index 00000000000..b44b21c5478 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clusterunplannedfailoverinput.go @@ -0,0 +1,8 @@ +package replicationprotectionclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterUnplannedFailoverInput struct { + Properties ClusterUnplannedFailoverInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clusterunplannedfailoverinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clusterunplannedfailoverinputproperties.go new file mode 100644 index 00000000000..0760209d43e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clusterunplannedfailoverinputproperties.go @@ -0,0 +1,45 @@ +package replicationprotectionclusters + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterUnplannedFailoverInputProperties struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + ProviderSpecificDetails ClusterUnplannedFailoverProviderSpecificInput `json:"providerSpecificDetails"` + SourceSiteOperations *string `json:"sourceSiteOperations,omitempty"` +} + +var _ json.Unmarshaler = &ClusterUnplannedFailoverInputProperties{} + +func (s *ClusterUnplannedFailoverInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + SourceSiteOperations *string `json:"sourceSiteOperations,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + s.SourceSiteOperations = decoded.SourceSiteOperations + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ClusterUnplannedFailoverInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalClusterUnplannedFailoverProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ClusterUnplannedFailoverInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clusterunplannedfailoverproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clusterunplannedfailoverproviderspecificinput.go new file mode 100644 index 00000000000..e1a10248f08 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_clusterunplannedfailoverproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationprotectionclusters + +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 ClusterUnplannedFailoverProviderSpecificInput interface { + ClusterUnplannedFailoverProviderSpecificInput() BaseClusterUnplannedFailoverProviderSpecificInputImpl +} + +var _ ClusterUnplannedFailoverProviderSpecificInput = BaseClusterUnplannedFailoverProviderSpecificInputImpl{} + +type BaseClusterUnplannedFailoverProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseClusterUnplannedFailoverProviderSpecificInputImpl) ClusterUnplannedFailoverProviderSpecificInput() BaseClusterUnplannedFailoverProviderSpecificInputImpl { + return s +} + +var _ ClusterUnplannedFailoverProviderSpecificInput = RawClusterUnplannedFailoverProviderSpecificInputImpl{} + +// RawClusterUnplannedFailoverProviderSpecificInputImpl 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 RawClusterUnplannedFailoverProviderSpecificInputImpl struct { + clusterUnplannedFailoverProviderSpecificInput BaseClusterUnplannedFailoverProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawClusterUnplannedFailoverProviderSpecificInputImpl) ClusterUnplannedFailoverProviderSpecificInput() BaseClusterUnplannedFailoverProviderSpecificInputImpl { + return s.clusterUnplannedFailoverProviderSpecificInput +} + +func UnmarshalClusterUnplannedFailoverProviderSpecificInputImplementation(input []byte) (ClusterUnplannedFailoverProviderSpecificInput, 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 ClusterUnplannedFailoverProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AClusterUnplannedFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AClusterUnplannedFailoverInput: %+v", err) + } + return out, nil + } + + var parent BaseClusterUnplannedFailoverProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseClusterUnplannedFailoverProviderSpecificInputImpl: %+v", err) + } + + return RawClusterUnplannedFailoverProviderSpecificInputImpl{ + clusterUnplannedFailoverProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_currentscenariodetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_currentscenariodetails.go new file mode 100644 index 00000000000..a4ec2bfa40b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_currentscenariodetails.go @@ -0,0 +1,28 @@ +package replicationprotectionclusters + +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 CurrentScenarioDetails struct { + JobId *string `json:"jobId,omitempty"` + ScenarioName *string `json:"scenarioName,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *CurrentScenarioDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CurrentScenarioDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_healtherror.go new file mode 100644 index 00000000000..77565f1e7dd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationprotectionclusters + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_innerhealtherror.go new file mode 100644 index 00000000000..08deeff4fc4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationprotectionclusters + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_registeredclusternodes.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_registeredclusternodes.go new file mode 100644 index 00000000000..2a72fdf3bbd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_registeredclusternodes.go @@ -0,0 +1,11 @@ +package replicationprotectionclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegisteredClusterNodes struct { + BiosId *string `json:"biosId,omitempty"` + ClusterNodeFqdn *string `json:"clusterNodeFqdn,omitempty"` + IsSharedDiskVirtualNode *bool `json:"isSharedDiskVirtualNode,omitempty"` + MachineId *string `json:"machineId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_replicationclusterproviderspecificsettings.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_replicationclusterproviderspecificsettings.go new file mode 100644 index 00000000000..4da11d823da --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_replicationclusterproviderspecificsettings.go @@ -0,0 +1,75 @@ +package replicationprotectionclusters + +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 ReplicationClusterProviderSpecificSettings interface { + ReplicationClusterProviderSpecificSettings() BaseReplicationClusterProviderSpecificSettingsImpl +} + +var _ ReplicationClusterProviderSpecificSettings = BaseReplicationClusterProviderSpecificSettingsImpl{} + +type BaseReplicationClusterProviderSpecificSettingsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseReplicationClusterProviderSpecificSettingsImpl) ReplicationClusterProviderSpecificSettings() BaseReplicationClusterProviderSpecificSettingsImpl { + return s +} + +var _ ReplicationClusterProviderSpecificSettings = RawReplicationClusterProviderSpecificSettingsImpl{} + +// RawReplicationClusterProviderSpecificSettingsImpl 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 RawReplicationClusterProviderSpecificSettingsImpl struct { + replicationClusterProviderSpecificSettings BaseReplicationClusterProviderSpecificSettingsImpl + Type string + Values map[string]interface{} +} + +func (s RawReplicationClusterProviderSpecificSettingsImpl) ReplicationClusterProviderSpecificSettings() BaseReplicationClusterProviderSpecificSettingsImpl { + return s.replicationClusterProviderSpecificSettings +} + +func UnmarshalReplicationClusterProviderSpecificSettingsImplementation(input []byte) (ReplicationClusterProviderSpecificSettings, 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 ReplicationClusterProviderSpecificSettings into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AReplicationProtectionClusterDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AReplicationProtectionClusterDetails: %+v", err) + } + return out, nil + } + + var parent BaseReplicationClusterProviderSpecificSettingsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseReplicationClusterProviderSpecificSettingsImpl: %+v", err) + } + + return RawReplicationClusterProviderSpecificSettingsImpl{ + replicationClusterProviderSpecificSettings: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_replicationprotectioncluster.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_replicationprotectioncluster.go new file mode 100644 index 00000000000..1590713495a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_replicationprotectioncluster.go @@ -0,0 +1,11 @@ +package replicationprotectionclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProtectionCluster struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ReplicationProtectionClusterProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_replicationprotectionclusterproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_replicationprotectionclusterproperties.go new file mode 100644 index 00000000000..527933170f3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_replicationprotectionclusterproperties.go @@ -0,0 +1,153 @@ +package replicationprotectionclusters + +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. + +type ReplicationProtectionClusterProperties struct { + ActiveLocation *string `json:"activeLocation,omitempty"` + AgentClusterId *string `json:"agentClusterId,omitempty"` + AllowedOperations *[]string `json:"allowedOperations,omitempty"` + AreAllClusterNodesRegistered *bool `json:"areAllClusterNodesRegistered,omitempty"` + ClusterFqdn *string `json:"clusterFqdn,omitempty"` + ClusterNodeFqdns *[]string `json:"clusterNodeFqdns,omitempty"` + ClusterProtectedItemIds *[]string `json:"clusterProtectedItemIds,omitempty"` + ClusterRegisteredNodes *[]RegisteredClusterNodes `json:"clusterRegisteredNodes,omitempty"` + CurrentScenario *CurrentScenarioDetails `json:"currentScenario,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + LastSuccessfulFailoverTime *string `json:"lastSuccessfulFailoverTime,omitempty"` + LastSuccessfulTestFailoverTime *string `json:"lastSuccessfulTestFailoverTime,omitempty"` + PolicyFriendlyName *string `json:"policyFriendlyName,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PrimaryFabricFriendlyName *string `json:"primaryFabricFriendlyName,omitempty"` + PrimaryFabricProvider *string `json:"primaryFabricProvider,omitempty"` + PrimaryProtectionContainerFriendlyName *string `json:"primaryProtectionContainerFriendlyName,omitempty"` + ProtectionClusterType *string `json:"protectionClusterType,omitempty"` + ProtectionState *string `json:"protectionState,omitempty"` + ProtectionStateDescription *string `json:"protectionStateDescription,omitempty"` + ProviderSpecificDetails ReplicationClusterProviderSpecificSettings `json:"providerSpecificDetails"` + ProvisioningState *string `json:"provisioningState,omitempty"` + RecoveryContainerId *string `json:"recoveryContainerId,omitempty"` + RecoveryFabricFriendlyName *string `json:"recoveryFabricFriendlyName,omitempty"` + RecoveryFabricId *string `json:"recoveryFabricId,omitempty"` + RecoveryProtectionContainerFriendlyName *string `json:"recoveryProtectionContainerFriendlyName,omitempty"` + ReplicationHealth *string `json:"replicationHealth,omitempty"` + SharedDiskProperties *SharedDiskReplicationItemProperties `json:"sharedDiskProperties,omitempty"` + TestFailoverState *string `json:"testFailoverState,omitempty"` + TestFailoverStateDescription *string `json:"testFailoverStateDescription,omitempty"` +} + +func (o *ReplicationProtectionClusterProperties) GetLastSuccessfulFailoverTimeAsTime() (*time.Time, error) { + if o.LastSuccessfulFailoverTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastSuccessfulFailoverTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReplicationProtectionClusterProperties) SetLastSuccessfulFailoverTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastSuccessfulFailoverTime = &formatted +} + +func (o *ReplicationProtectionClusterProperties) GetLastSuccessfulTestFailoverTimeAsTime() (*time.Time, error) { + if o.LastSuccessfulTestFailoverTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastSuccessfulTestFailoverTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReplicationProtectionClusterProperties) SetLastSuccessfulTestFailoverTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastSuccessfulTestFailoverTime = &formatted +} + +var _ json.Unmarshaler = &ReplicationProtectionClusterProperties{} + +func (s *ReplicationProtectionClusterProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ActiveLocation *string `json:"activeLocation,omitempty"` + AgentClusterId *string `json:"agentClusterId,omitempty"` + AllowedOperations *[]string `json:"allowedOperations,omitempty"` + AreAllClusterNodesRegistered *bool `json:"areAllClusterNodesRegistered,omitempty"` + ClusterFqdn *string `json:"clusterFqdn,omitempty"` + ClusterNodeFqdns *[]string `json:"clusterNodeFqdns,omitempty"` + ClusterProtectedItemIds *[]string `json:"clusterProtectedItemIds,omitempty"` + ClusterRegisteredNodes *[]RegisteredClusterNodes `json:"clusterRegisteredNodes,omitempty"` + CurrentScenario *CurrentScenarioDetails `json:"currentScenario,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + LastSuccessfulFailoverTime *string `json:"lastSuccessfulFailoverTime,omitempty"` + LastSuccessfulTestFailoverTime *string `json:"lastSuccessfulTestFailoverTime,omitempty"` + PolicyFriendlyName *string `json:"policyFriendlyName,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PrimaryFabricFriendlyName *string `json:"primaryFabricFriendlyName,omitempty"` + PrimaryFabricProvider *string `json:"primaryFabricProvider,omitempty"` + PrimaryProtectionContainerFriendlyName *string `json:"primaryProtectionContainerFriendlyName,omitempty"` + ProtectionClusterType *string `json:"protectionClusterType,omitempty"` + ProtectionState *string `json:"protectionState,omitempty"` + ProtectionStateDescription *string `json:"protectionStateDescription,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + RecoveryContainerId *string `json:"recoveryContainerId,omitempty"` + RecoveryFabricFriendlyName *string `json:"recoveryFabricFriendlyName,omitempty"` + RecoveryFabricId *string `json:"recoveryFabricId,omitempty"` + RecoveryProtectionContainerFriendlyName *string `json:"recoveryProtectionContainerFriendlyName,omitempty"` + ReplicationHealth *string `json:"replicationHealth,omitempty"` + SharedDiskProperties *SharedDiskReplicationItemProperties `json:"sharedDiskProperties,omitempty"` + TestFailoverState *string `json:"testFailoverState,omitempty"` + TestFailoverStateDescription *string `json:"testFailoverStateDescription,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ActiveLocation = decoded.ActiveLocation + s.AgentClusterId = decoded.AgentClusterId + s.AllowedOperations = decoded.AllowedOperations + s.AreAllClusterNodesRegistered = decoded.AreAllClusterNodesRegistered + s.ClusterFqdn = decoded.ClusterFqdn + s.ClusterNodeFqdns = decoded.ClusterNodeFqdns + s.ClusterProtectedItemIds = decoded.ClusterProtectedItemIds + s.ClusterRegisteredNodes = decoded.ClusterRegisteredNodes + s.CurrentScenario = decoded.CurrentScenario + s.HealthErrors = decoded.HealthErrors + s.LastSuccessfulFailoverTime = decoded.LastSuccessfulFailoverTime + s.LastSuccessfulTestFailoverTime = decoded.LastSuccessfulTestFailoverTime + s.PolicyFriendlyName = decoded.PolicyFriendlyName + s.PolicyId = decoded.PolicyId + s.PrimaryFabricFriendlyName = decoded.PrimaryFabricFriendlyName + s.PrimaryFabricProvider = decoded.PrimaryFabricProvider + s.PrimaryProtectionContainerFriendlyName = decoded.PrimaryProtectionContainerFriendlyName + s.ProtectionClusterType = decoded.ProtectionClusterType + s.ProtectionState = decoded.ProtectionState + s.ProtectionStateDescription = decoded.ProtectionStateDescription + s.ProvisioningState = decoded.ProvisioningState + s.RecoveryContainerId = decoded.RecoveryContainerId + s.RecoveryFabricFriendlyName = decoded.RecoveryFabricFriendlyName + s.RecoveryFabricId = decoded.RecoveryFabricId + s.RecoveryProtectionContainerFriendlyName = decoded.RecoveryProtectionContainerFriendlyName + s.ReplicationHealth = decoded.ReplicationHealth + s.SharedDiskProperties = decoded.SharedDiskProperties + s.TestFailoverState = decoded.TestFailoverState + s.TestFailoverStateDescription = decoded.TestFailoverStateDescription + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ReplicationProtectionClusterProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalReplicationClusterProviderSpecificSettingsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ReplicationProtectionClusterProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_shareddiskreplicationitemproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_shareddiskreplicationitemproperties.go new file mode 100644 index 00000000000..60fbba1a93e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_shareddiskreplicationitemproperties.go @@ -0,0 +1,60 @@ +package replicationprotectionclusters + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedDiskReplicationItemProperties struct { + ActiveLocation *string `json:"activeLocation,omitempty"` + AllowedOperations *[]string `json:"allowedOperations,omitempty"` + CurrentScenario *CurrentScenarioDetails `json:"currentScenario,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + ProtectionState *string `json:"protectionState,omitempty"` + ReplicationHealth *string `json:"replicationHealth,omitempty"` + SharedDiskProviderSpecificDetails SharedDiskReplicationProviderSpecificSettings `json:"sharedDiskProviderSpecificDetails"` + TestFailoverState *string `json:"testFailoverState,omitempty"` +} + +var _ json.Unmarshaler = &SharedDiskReplicationItemProperties{} + +func (s *SharedDiskReplicationItemProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ActiveLocation *string `json:"activeLocation,omitempty"` + AllowedOperations *[]string `json:"allowedOperations,omitempty"` + CurrentScenario *CurrentScenarioDetails `json:"currentScenario,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + ProtectionState *string `json:"protectionState,omitempty"` + ReplicationHealth *string `json:"replicationHealth,omitempty"` + TestFailoverState *string `json:"testFailoverState,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ActiveLocation = decoded.ActiveLocation + s.AllowedOperations = decoded.AllowedOperations + s.CurrentScenario = decoded.CurrentScenario + s.HealthErrors = decoded.HealthErrors + s.ProtectionState = decoded.ProtectionState + s.ReplicationHealth = decoded.ReplicationHealth + s.TestFailoverState = decoded.TestFailoverState + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SharedDiskReplicationItemProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["sharedDiskProviderSpecificDetails"]; ok { + impl, err := UnmarshalSharedDiskReplicationProviderSpecificSettingsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SharedDiskProviderSpecificDetails' for 'SharedDiskReplicationItemProperties': %+v", err) + } + s.SharedDiskProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_shareddiskreplicationproviderspecificsettings.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_shareddiskreplicationproviderspecificsettings.go new file mode 100644 index 00000000000..ba7d1ed5746 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/model_shareddiskreplicationproviderspecificsettings.go @@ -0,0 +1,75 @@ +package replicationprotectionclusters + +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 SharedDiskReplicationProviderSpecificSettings interface { + SharedDiskReplicationProviderSpecificSettings() BaseSharedDiskReplicationProviderSpecificSettingsImpl +} + +var _ SharedDiskReplicationProviderSpecificSettings = BaseSharedDiskReplicationProviderSpecificSettingsImpl{} + +type BaseSharedDiskReplicationProviderSpecificSettingsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseSharedDiskReplicationProviderSpecificSettingsImpl) SharedDiskReplicationProviderSpecificSettings() BaseSharedDiskReplicationProviderSpecificSettingsImpl { + return s +} + +var _ SharedDiskReplicationProviderSpecificSettings = RawSharedDiskReplicationProviderSpecificSettingsImpl{} + +// RawSharedDiskReplicationProviderSpecificSettingsImpl 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 RawSharedDiskReplicationProviderSpecificSettingsImpl struct { + sharedDiskReplicationProviderSpecificSettings BaseSharedDiskReplicationProviderSpecificSettingsImpl + Type string + Values map[string]interface{} +} + +func (s RawSharedDiskReplicationProviderSpecificSettingsImpl) SharedDiskReplicationProviderSpecificSettings() BaseSharedDiskReplicationProviderSpecificSettingsImpl { + return s.sharedDiskReplicationProviderSpecificSettings +} + +func UnmarshalSharedDiskReplicationProviderSpecificSettingsImplementation(input []byte) (SharedDiskReplicationProviderSpecificSettings, 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 SharedDiskReplicationProviderSpecificSettings into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2ASharedDiskReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ASharedDiskReplicationDetails: %+v", err) + } + return out, nil + } + + var parent BaseSharedDiskReplicationProviderSpecificSettingsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSharedDiskReplicationProviderSpecificSettingsImpl: %+v", err) + } + + return RawSharedDiskReplicationProviderSpecificSettingsImpl{ + sharedDiskReplicationProviderSpecificSettings: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/predicates.go new file mode 100644 index 00000000000..3a3afdd7e35 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/predicates.go @@ -0,0 +1,27 @@ +package replicationprotectionclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProtectionClusterOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ReplicationProtectionClusterOperationPredicate) Matches(input ReplicationProtectionCluster) 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/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/version.go new file mode 100644 index 00000000000..01ae36b8a17 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionclusters/version.go @@ -0,0 +1,10 @@ +package replicationprotectionclusters + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationprotectionclusters/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/README.md new file mode 100644 index 00000000000..36cbf136c58 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/README.md @@ -0,0 +1,133 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings` Documentation + +The `replicationprotectioncontainermappings` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings" +``` + + +### Client Initialization + +```go +client := replicationprotectioncontainermappings.NewReplicationProtectionContainerMappingsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationProtectionContainerMappingsClient.Create` + +```go +ctx := context.TODO() +id := replicationprotectioncontainermappings.NewReplicationProtectionContainerMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionContainerMappingName") + +payload := replicationprotectioncontainermappings.CreateProtectionContainerMappingInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionContainerMappingsClient.Delete` + +```go +ctx := context.TODO() +id := replicationprotectioncontainermappings.NewReplicationProtectionContainerMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionContainerMappingName") + +payload := replicationprotectioncontainermappings.RemoveProtectionContainerMappingInput{ + // ... +} + + +if err := client.DeleteThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionContainerMappingsClient.Get` + +```go +ctx := context.TODO() +id := replicationprotectioncontainermappings.NewReplicationProtectionContainerMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionContainerMappingName") + +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: `ReplicationProtectionContainerMappingsClient.List` + +```go +ctx := context.TODO() +id := replicationprotectioncontainermappings.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationProtectionContainerMappingsClient.ListByReplicationProtectionContainers` + +```go +ctx := context.TODO() +id := replicationprotectioncontainermappings.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + +// alternatively `client.ListByReplicationProtectionContainers(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationProtectionContainersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationProtectionContainerMappingsClient.Purge` + +```go +ctx := context.TODO() +id := replicationprotectioncontainermappings.NewReplicationProtectionContainerMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionContainerMappingName") + +if err := client.PurgeThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionContainerMappingsClient.Update` + +```go +ctx := context.TODO() +id := replicationprotectioncontainermappings.NewReplicationProtectionContainerMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionContainerMappingName") + +payload := replicationprotectioncontainermappings.UpdateProtectionContainerMappingInput{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/client.go new file mode 100644 index 00000000000..4fe661f7f6f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/client.go @@ -0,0 +1,26 @@ +package replicationprotectioncontainermappings + +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 ReplicationProtectionContainerMappingsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationProtectionContainerMappingsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationProtectionContainerMappingsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationprotectioncontainermappings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationProtectionContainerMappingsClient: %+v", err) + } + + return &ReplicationProtectionContainerMappingsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/constants.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/constants.go new file mode 100644 index 00000000000..59286568ec1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/constants.go @@ -0,0 +1,133 @@ +package replicationprotectioncontainermappings + +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 AgentAutoUpdateStatus string + +const ( + AgentAutoUpdateStatusDisabled AgentAutoUpdateStatus = "Disabled" + AgentAutoUpdateStatusEnabled AgentAutoUpdateStatus = "Enabled" +) + +func PossibleValuesForAgentAutoUpdateStatus() []string { + return []string{ + string(AgentAutoUpdateStatusDisabled), + string(AgentAutoUpdateStatusEnabled), + } +} + +func (s *AgentAutoUpdateStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentAutoUpdateStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentAutoUpdateStatus(input string) (*AgentAutoUpdateStatus, error) { + vals := map[string]AgentAutoUpdateStatus{ + "disabled": AgentAutoUpdateStatusDisabled, + "enabled": AgentAutoUpdateStatusEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentAutoUpdateStatus(input) + return &out, nil +} + +type AutomationAccountAuthenticationType string + +const ( + AutomationAccountAuthenticationTypeRunAsAccount AutomationAccountAuthenticationType = "RunAsAccount" + AutomationAccountAuthenticationTypeSystemAssignedIdentity AutomationAccountAuthenticationType = "SystemAssignedIdentity" +) + +func PossibleValuesForAutomationAccountAuthenticationType() []string { + return []string{ + string(AutomationAccountAuthenticationTypeRunAsAccount), + string(AutomationAccountAuthenticationTypeSystemAssignedIdentity), + } +} + +func (s *AutomationAccountAuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutomationAccountAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutomationAccountAuthenticationType(input string) (*AutomationAccountAuthenticationType, error) { + vals := map[string]AutomationAccountAuthenticationType{ + "runasaccount": AutomationAccountAuthenticationTypeRunAsAccount, + "systemassignedidentity": AutomationAccountAuthenticationTypeSystemAssignedIdentity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutomationAccountAuthenticationType(input) + return &out, nil +} + +type HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/id_replicationprotectioncontainer.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/id_replicationprotectioncontainer.go new file mode 100644 index 00000000000..61b19e9b5bb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/id_replicationprotectioncontainer.go @@ -0,0 +1,148 @@ +package replicationprotectioncontainermappings + +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(&ReplicationProtectionContainerId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectionContainerId{} + +// ReplicationProtectionContainerId is a struct representing the Resource ID for a Replication Protection Container +type ReplicationProtectionContainerId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string +} + +// NewReplicationProtectionContainerID returns a new ReplicationProtectionContainerId struct +func NewReplicationProtectionContainerID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string) ReplicationProtectionContainerId { + return ReplicationProtectionContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + } +} + +// ParseReplicationProtectionContainerID parses 'input' into a ReplicationProtectionContainerId +func ParseReplicationProtectionContainerID(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionContainerIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionContainerId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionContainerIDInsensitively(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionContainerId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + return nil +} + +// ValidateReplicationProtectionContainerID checks that 'input' can be parsed as a Replication Protection Container ID +func ValidateReplicationProtectionContainerID(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 := ParseReplicationProtectionContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Container ID +func (id ReplicationProtectionContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Container ID +func (id ReplicationProtectionContainerId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + } +} + +// String returns a human-readable description of this Replication Protection Container ID +func (id ReplicationProtectionContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + } + return fmt.Sprintf("Replication Protection Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/id_replicationprotectioncontainer_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/id_replicationprotectioncontainer_test.go new file mode 100644 index 00000000000..054eecca438 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/id_replicationprotectioncontainer_test.go @@ -0,0 +1,372 @@ +package replicationprotectioncontainermappings + +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 = &ReplicationProtectionContainerId{} + +func TestNewReplicationProtectionContainerID(t *testing.T) { + id := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } +} + +func TestFormatReplicationProtectionContainerID(t *testing.T) { + actual := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestParseReplicationProtectionContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestSegmentsForReplicationProtectionContainerId(t *testing.T) { + segments := ReplicationProtectionContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionContainerId 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/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/id_replicationprotectioncontainermapping.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/id_replicationprotectioncontainermapping.go new file mode 100644 index 00000000000..2b2e19aec67 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/id_replicationprotectioncontainermapping.go @@ -0,0 +1,157 @@ +package replicationprotectioncontainermappings + +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(&ReplicationProtectionContainerMappingId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectionContainerMappingId{} + +// ReplicationProtectionContainerMappingId is a struct representing the Resource ID for a Replication Protection Container Mapping +type ReplicationProtectionContainerMappingId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectionContainerMappingName string +} + +// NewReplicationProtectionContainerMappingID returns a new ReplicationProtectionContainerMappingId struct +func NewReplicationProtectionContainerMappingID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectionContainerMappingName string) ReplicationProtectionContainerMappingId { + return ReplicationProtectionContainerMappingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectionContainerMappingName: replicationProtectionContainerMappingName, + } +} + +// ParseReplicationProtectionContainerMappingID parses 'input' into a ReplicationProtectionContainerMappingId +func ParseReplicationProtectionContainerMappingID(input string) (*ReplicationProtectionContainerMappingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerMappingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerMappingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionContainerMappingIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionContainerMappingId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionContainerMappingIDInsensitively(input string) (*ReplicationProtectionContainerMappingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerMappingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerMappingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionContainerMappingId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectionContainerMappingName, ok = input.Parsed["replicationProtectionContainerMappingName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerMappingName", input) + } + + return nil +} + +// ValidateReplicationProtectionContainerMappingID checks that 'input' can be parsed as a Replication Protection Container Mapping ID +func ValidateReplicationProtectionContainerMappingID(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 := ParseReplicationProtectionContainerMappingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Container Mapping ID +func (id ReplicationProtectionContainerMappingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectionContainerMappings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectionContainerMappingName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Container Mapping ID +func (id ReplicationProtectionContainerMappingId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationProtectionContainerMappings", "replicationProtectionContainerMappings", "replicationProtectionContainerMappings"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerMappingName", "replicationProtectionContainerMappingName"), + } +} + +// String returns a human-readable description of this Replication Protection Container Mapping ID +func (id ReplicationProtectionContainerMappingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protection Container Mapping Name: %q", id.ReplicationProtectionContainerMappingName), + } + return fmt.Sprintf("Replication Protection Container Mapping (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/id_replicationprotectioncontainermapping_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/id_replicationprotectioncontainermapping_test.go new file mode 100644 index 00000000000..3da16c9dc30 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/id_replicationprotectioncontainermapping_test.go @@ -0,0 +1,417 @@ +package replicationprotectioncontainermappings + +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 = &ReplicationProtectionContainerMappingId{} + +func TestNewReplicationProtectionContainerMappingID(t *testing.T) { + id := NewReplicationProtectionContainerMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionContainerMappingName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationProtectionContainerMappingName != "replicationProtectionContainerMappingName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerMappingName'", id.ReplicationProtectionContainerMappingName, "replicationProtectionContainerMappingName") + } +} + +func TestFormatReplicationProtectionContainerMappingID(t *testing.T) { + actual := NewReplicationProtectionContainerMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionContainerMappingName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionContainerMappings/replicationProtectionContainerMappingName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionContainerMappingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerMappingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionContainerMappings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionContainerMappings/replicationProtectionContainerMappingName", + Expected: &ReplicationProtectionContainerMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectionContainerMappingName: "replicationProtectionContainerMappingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionContainerMappings/replicationProtectionContainerMappingName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerMappingID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectionContainerMappingName != v.Expected.ReplicationProtectionContainerMappingName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerMappingName", v.Expected.ReplicationProtectionContainerMappingName, actual.ReplicationProtectionContainerMappingName) + } + + } +} + +func TestParseReplicationProtectionContainerMappingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerMappingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionContainerMappings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRmApPiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionContainerMappings/replicationProtectionContainerMappingName", + Expected: &ReplicationProtectionContainerMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectionContainerMappingName: "replicationProtectionContainerMappingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionContainerMappings/replicationProtectionContainerMappingName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRmApPiNgS/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRmApPiNgNaMe", + Expected: &ReplicationProtectionContainerMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationProtectionContainerMappingName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRmApPiNgNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRmApPiNgS/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRmApPiNgNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerMappingIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectionContainerMappingName != v.Expected.ReplicationProtectionContainerMappingName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerMappingName", v.Expected.ReplicationProtectionContainerMappingName, actual.ReplicationProtectionContainerMappingName) + } + + } +} + +func TestSegmentsForReplicationProtectionContainerMappingId(t *testing.T) { + segments := ReplicationProtectionContainerMappingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionContainerMappingId 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/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/id_vault.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/id_vault.go new file mode 100644 index 00000000000..732e128c07b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/id_vault.go @@ -0,0 +1,130 @@ +package replicationprotectioncontainermappings + +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(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(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 := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/id_vault_test.go new file mode 100644 index 00000000000..5d5304ccb76 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationprotectioncontainermappings + +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 = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId 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/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/method_create.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/method_create.go new file mode 100644 index 00000000000..48f9d495b34 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/method_create.go @@ -0,0 +1,75 @@ +package replicationprotectioncontainermappings + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ProtectionContainerMapping +} + +// Create ... +func (c ReplicationProtectionContainerMappingsClient) Create(ctx context.Context, id ReplicationProtectionContainerMappingId, input CreateProtectionContainerMappingInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationProtectionContainerMappingsClient) CreateThenPoll(ctx context.Context, id ReplicationProtectionContainerMappingId, input CreateProtectionContainerMappingInput) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/method_delete.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/method_delete.go new file mode 100644 index 00000000000..a7da6f7e3e3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/method_delete.go @@ -0,0 +1,74 @@ +package replicationprotectioncontainermappings + +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 ReplicationProtectionContainerMappingsClient) Delete(ctx context.Context, id ReplicationProtectionContainerMappingId, input RemoveProtectionContainerMappingInput) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/remove", 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 +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ReplicationProtectionContainerMappingsClient) DeleteThenPoll(ctx context.Context, id ReplicationProtectionContainerMappingId, input RemoveProtectionContainerMappingInput) error { + result, err := c.Delete(ctx, id, input) + 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/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/method_get.go new file mode 100644 index 00000000000..31623992dab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/method_get.go @@ -0,0 +1,53 @@ +package replicationprotectioncontainermappings + +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 *ProtectionContainerMapping +} + +// Get ... +func (c ReplicationProtectionContainerMappingsClient) Get(ctx context.Context, id ReplicationProtectionContainerMappingId) (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 ProtectionContainerMapping + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/method_list.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/method_list.go new file mode 100644 index 00000000000..95cb2a96220 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/method_list.go @@ -0,0 +1,105 @@ +package replicationprotectioncontainermappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProtectionContainerMapping +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProtectionContainerMapping +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ReplicationProtectionContainerMappingsClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/replicationProtectionContainerMappings", 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 *[]ProtectionContainerMapping `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationProtectionContainerMappingsClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ProtectionContainerMappingOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectionContainerMappingsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate ProtectionContainerMappingOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ProtectionContainerMapping, 0) + + resp, err := c.List(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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/method_listbyreplicationprotectioncontainers.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/method_listbyreplicationprotectioncontainers.go new file mode 100644 index 00000000000..1e171e16a67 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/method_listbyreplicationprotectioncontainers.go @@ -0,0 +1,105 @@ +package replicationprotectioncontainermappings + +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 ListByReplicationProtectionContainersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProtectionContainerMapping +} + +type ListByReplicationProtectionContainersCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProtectionContainerMapping +} + +type ListByReplicationProtectionContainersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationProtectionContainersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationProtectionContainers ... +func (c ReplicationProtectionContainerMappingsClient) ListByReplicationProtectionContainers(ctx context.Context, id ReplicationProtectionContainerId) (result ListByReplicationProtectionContainersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationProtectionContainersCustomPager{}, + Path: fmt.Sprintf("%s/replicationProtectionContainerMappings", 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 *[]ProtectionContainerMapping `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationProtectionContainersComplete retrieves all the results into a single object +func (c ReplicationProtectionContainerMappingsClient) ListByReplicationProtectionContainersComplete(ctx context.Context, id ReplicationProtectionContainerId) (ListByReplicationProtectionContainersCompleteResult, error) { + return c.ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx, id, ProtectionContainerMappingOperationPredicate{}) +} + +// ListByReplicationProtectionContainersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectionContainerMappingsClient) ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx context.Context, id ReplicationProtectionContainerId, predicate ProtectionContainerMappingOperationPredicate) (result ListByReplicationProtectionContainersCompleteResult, err error) { + items := make([]ProtectionContainerMapping, 0) + + resp, err := c.ListByReplicationProtectionContainers(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 = ListByReplicationProtectionContainersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/method_purge.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/method_purge.go new file mode 100644 index 00000000000..fecbca3b41b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/method_purge.go @@ -0,0 +1,70 @@ +package replicationprotectioncontainermappings + +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 PurgeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Purge ... +func (c ReplicationProtectionContainerMappingsClient) Purge(ctx context.Context, id ReplicationProtectionContainerMappingId) (result PurgeOperationResponse, 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 +} + +// PurgeThenPoll performs Purge then polls until it's completed +func (c ReplicationProtectionContainerMappingsClient) PurgeThenPoll(ctx context.Context, id ReplicationProtectionContainerMappingId) error { + result, err := c.Purge(ctx, id) + if err != nil { + return fmt.Errorf("performing Purge: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Purge: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/method_update.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/method_update.go new file mode 100644 index 00000000000..6a2852dda40 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/method_update.go @@ -0,0 +1,75 @@ +package replicationprotectioncontainermappings + +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 *ProtectionContainerMapping +} + +// Update ... +func (c ReplicationProtectionContainerMappingsClient) Update(ctx context.Context, id ReplicationProtectionContainerMappingId, input UpdateProtectionContainerMappingInput) (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 ReplicationProtectionContainerMappingsClient) UpdateThenPoll(ctx context.Context, id ReplicationProtectionContainerMappingId, input UpdateProtectionContainerMappingInput) 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/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_a2acontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_a2acontainermappinginput.go new file mode 100644 index 00000000000..520decdc12b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_a2acontainermappinginput.go @@ -0,0 +1,52 @@ +package replicationprotectioncontainermappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificContainerMappingInput = A2AContainerMappingInput{} + +type A2AContainerMappingInput struct { + AgentAutoUpdateStatus *AgentAutoUpdateStatus `json:"agentAutoUpdateStatus,omitempty"` + AutomationAccountArmId *string `json:"automationAccountArmId,omitempty"` + AutomationAccountAuthenticationType *AutomationAccountAuthenticationType `json:"automationAccountAuthenticationType,omitempty"` + + // Fields inherited from ReplicationProviderSpecificContainerMappingInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AContainerMappingInput) ReplicationProviderSpecificContainerMappingInput() BaseReplicationProviderSpecificContainerMappingInputImpl { + return BaseReplicationProviderSpecificContainerMappingInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AContainerMappingInput{} + +func (s A2AContainerMappingInput) MarshalJSON() ([]byte, error) { + type wrapper A2AContainerMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AContainerMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AContainerMappingInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AContainerMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_a2aprotectioncontainermappingdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_a2aprotectioncontainermappingdetails.go new file mode 100644 index 00000000000..f8d56c9abca --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_a2aprotectioncontainermappingdetails.go @@ -0,0 +1,54 @@ +package replicationprotectioncontainermappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainerMappingProviderSpecificDetails = A2AProtectionContainerMappingDetails{} + +type A2AProtectionContainerMappingDetails struct { + AgentAutoUpdateStatus *AgentAutoUpdateStatus `json:"agentAutoUpdateStatus,omitempty"` + AutomationAccountArmId *string `json:"automationAccountArmId,omitempty"` + AutomationAccountAuthenticationType *AutomationAccountAuthenticationType `json:"automationAccountAuthenticationType,omitempty"` + JobScheduleName *string `json:"jobScheduleName,omitempty"` + ScheduleName *string `json:"scheduleName,omitempty"` + + // Fields inherited from ProtectionContainerMappingProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s A2AProtectionContainerMappingDetails) ProtectionContainerMappingProviderSpecificDetails() BaseProtectionContainerMappingProviderSpecificDetailsImpl { + return BaseProtectionContainerMappingProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AProtectionContainerMappingDetails{} + +func (s A2AProtectionContainerMappingDetails) MarshalJSON() ([]byte, error) { + type wrapper A2AProtectionContainerMappingDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AProtectionContainerMappingDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AProtectionContainerMappingDetails: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AProtectionContainerMappingDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_a2aupdatecontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_a2aupdatecontainermappinginput.go new file mode 100644 index 00000000000..7eca6e5966e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_a2aupdatecontainermappinginput.go @@ -0,0 +1,52 @@ +package replicationprotectioncontainermappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificUpdateContainerMappingInput = A2AUpdateContainerMappingInput{} + +type A2AUpdateContainerMappingInput struct { + AgentAutoUpdateStatus *AgentAutoUpdateStatus `json:"agentAutoUpdateStatus,omitempty"` + AutomationAccountArmId *string `json:"automationAccountArmId,omitempty"` + AutomationAccountAuthenticationType *AutomationAccountAuthenticationType `json:"automationAccountAuthenticationType,omitempty"` + + // Fields inherited from ReplicationProviderSpecificUpdateContainerMappingInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AUpdateContainerMappingInput) ReplicationProviderSpecificUpdateContainerMappingInput() BaseReplicationProviderSpecificUpdateContainerMappingInputImpl { + return BaseReplicationProviderSpecificUpdateContainerMappingInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AUpdateContainerMappingInput{} + +func (s A2AUpdateContainerMappingInput) MarshalJSON() ([]byte, error) { + type wrapper A2AUpdateContainerMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AUpdateContainerMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AUpdateContainerMappingInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AUpdateContainerMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_createprotectioncontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_createprotectioncontainermappinginput.go new file mode 100644 index 00000000000..49e1a32d873 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_createprotectioncontainermappinginput.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainermappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateProtectionContainerMappingInput struct { + Properties *CreateProtectionContainerMappingInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_createprotectioncontainermappinginputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_createprotectioncontainermappinginputproperties.go new file mode 100644 index 00000000000..ad0529d2f58 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_createprotectioncontainermappinginputproperties.go @@ -0,0 +1,45 @@ +package replicationprotectioncontainermappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateProtectionContainerMappingInputProperties struct { + PolicyId *string `json:"policyId,omitempty"` + ProviderSpecificInput ReplicationProviderSpecificContainerMappingInput `json:"providerSpecificInput"` + TargetProtectionContainerId *string `json:"targetProtectionContainerId,omitempty"` +} + +var _ json.Unmarshaler = &CreateProtectionContainerMappingInputProperties{} + +func (s *CreateProtectionContainerMappingInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + PolicyId *string `json:"policyId,omitempty"` + TargetProtectionContainerId *string `json:"targetProtectionContainerId,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.PolicyId = decoded.PolicyId + s.TargetProtectionContainerId = decoded.TargetProtectionContainerId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CreateProtectionContainerMappingInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificInput"]; ok { + impl, err := UnmarshalReplicationProviderSpecificContainerMappingInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificInput' for 'CreateProtectionContainerMappingInputProperties': %+v", err) + } + s.ProviderSpecificInput = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_healtherror.go new file mode 100644 index 00000000000..a4c7339daba --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationprotectioncontainermappings + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_inmagercmprotectioncontainermappingdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_inmagercmprotectioncontainermappingdetails.go new file mode 100644 index 00000000000..1b6791491b6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_inmagercmprotectioncontainermappingdetails.go @@ -0,0 +1,50 @@ +package replicationprotectioncontainermappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainerMappingProviderSpecificDetails = InMageRcmProtectionContainerMappingDetails{} + +type InMageRcmProtectionContainerMappingDetails struct { + EnableAgentAutoUpgrade *string `json:"enableAgentAutoUpgrade,omitempty"` + + // Fields inherited from ProtectionContainerMappingProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmProtectionContainerMappingDetails) ProtectionContainerMappingProviderSpecificDetails() BaseProtectionContainerMappingProviderSpecificDetailsImpl { + return BaseProtectionContainerMappingProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmProtectionContainerMappingDetails{} + +func (s InMageRcmProtectionContainerMappingDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmProtectionContainerMappingDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmProtectionContainerMappingDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmProtectionContainerMappingDetails: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmProtectionContainerMappingDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_inmagercmupdatecontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_inmagercmupdatecontainermappinginput.go new file mode 100644 index 00000000000..39728993aec --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_inmagercmupdatecontainermappinginput.go @@ -0,0 +1,50 @@ +package replicationprotectioncontainermappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificUpdateContainerMappingInput = InMageRcmUpdateContainerMappingInput{} + +type InMageRcmUpdateContainerMappingInput struct { + EnableAgentAutoUpgrade string `json:"enableAgentAutoUpgrade"` + + // Fields inherited from ReplicationProviderSpecificUpdateContainerMappingInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmUpdateContainerMappingInput) ReplicationProviderSpecificUpdateContainerMappingInput() BaseReplicationProviderSpecificUpdateContainerMappingInputImpl { + return BaseReplicationProviderSpecificUpdateContainerMappingInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmUpdateContainerMappingInput{} + +func (s InMageRcmUpdateContainerMappingInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmUpdateContainerMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmUpdateContainerMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmUpdateContainerMappingInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmUpdateContainerMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_innerhealtherror.go new file mode 100644 index 00000000000..20d411ae371 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationprotectioncontainermappings + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_protectioncontainermapping.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_protectioncontainermapping.go new file mode 100644 index 00000000000..6fcec0153e7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_protectioncontainermapping.go @@ -0,0 +1,12 @@ +package replicationprotectioncontainermappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerMapping struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ProtectionContainerMappingProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_protectioncontainermappingproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_protectioncontainermappingproperties.go new file mode 100644 index 00000000000..04fd7e9d4b9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_protectioncontainermappingproperties.go @@ -0,0 +1,69 @@ +package replicationprotectioncontainermappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerMappingProperties struct { + Health *string `json:"health,omitempty"` + HealthErrorDetails *[]HealthError `json:"healthErrorDetails,omitempty"` + PolicyFriendlyName *string `json:"policyFriendlyName,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProviderSpecificDetails ProtectionContainerMappingProviderSpecificDetails `json:"providerSpecificDetails"` + SourceFabricFriendlyName *string `json:"sourceFabricFriendlyName,omitempty"` + SourceProtectionContainerFriendlyName *string `json:"sourceProtectionContainerFriendlyName,omitempty"` + State *string `json:"state,omitempty"` + TargetFabricFriendlyName *string `json:"targetFabricFriendlyName,omitempty"` + TargetProtectionContainerFriendlyName *string `json:"targetProtectionContainerFriendlyName,omitempty"` + TargetProtectionContainerId *string `json:"targetProtectionContainerId,omitempty"` +} + +var _ json.Unmarshaler = &ProtectionContainerMappingProperties{} + +func (s *ProtectionContainerMappingProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Health *string `json:"health,omitempty"` + HealthErrorDetails *[]HealthError `json:"healthErrorDetails,omitempty"` + PolicyFriendlyName *string `json:"policyFriendlyName,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + SourceFabricFriendlyName *string `json:"sourceFabricFriendlyName,omitempty"` + SourceProtectionContainerFriendlyName *string `json:"sourceProtectionContainerFriendlyName,omitempty"` + State *string `json:"state,omitempty"` + TargetFabricFriendlyName *string `json:"targetFabricFriendlyName,omitempty"` + TargetProtectionContainerFriendlyName *string `json:"targetProtectionContainerFriendlyName,omitempty"` + TargetProtectionContainerId *string `json:"targetProtectionContainerId,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Health = decoded.Health + s.HealthErrorDetails = decoded.HealthErrorDetails + s.PolicyFriendlyName = decoded.PolicyFriendlyName + s.PolicyId = decoded.PolicyId + s.SourceFabricFriendlyName = decoded.SourceFabricFriendlyName + s.SourceProtectionContainerFriendlyName = decoded.SourceProtectionContainerFriendlyName + s.State = decoded.State + s.TargetFabricFriendlyName = decoded.TargetFabricFriendlyName + s.TargetProtectionContainerFriendlyName = decoded.TargetProtectionContainerFriendlyName + s.TargetProtectionContainerId = decoded.TargetProtectionContainerId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectionContainerMappingProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalProtectionContainerMappingProviderSpecificDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ProtectionContainerMappingProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_protectioncontainermappingproviderspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_protectioncontainermappingproviderspecificdetails.go new file mode 100644 index 00000000000..219606477d7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_protectioncontainermappingproviderspecificdetails.go @@ -0,0 +1,91 @@ +package replicationprotectioncontainermappings + +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 ProtectionContainerMappingProviderSpecificDetails interface { + ProtectionContainerMappingProviderSpecificDetails() BaseProtectionContainerMappingProviderSpecificDetailsImpl +} + +var _ ProtectionContainerMappingProviderSpecificDetails = BaseProtectionContainerMappingProviderSpecificDetailsImpl{} + +type BaseProtectionContainerMappingProviderSpecificDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseProtectionContainerMappingProviderSpecificDetailsImpl) ProtectionContainerMappingProviderSpecificDetails() BaseProtectionContainerMappingProviderSpecificDetailsImpl { + return s +} + +var _ ProtectionContainerMappingProviderSpecificDetails = RawProtectionContainerMappingProviderSpecificDetailsImpl{} + +// RawProtectionContainerMappingProviderSpecificDetailsImpl 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 RawProtectionContainerMappingProviderSpecificDetailsImpl struct { + protectionContainerMappingProviderSpecificDetails BaseProtectionContainerMappingProviderSpecificDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawProtectionContainerMappingProviderSpecificDetailsImpl) ProtectionContainerMappingProviderSpecificDetails() BaseProtectionContainerMappingProviderSpecificDetailsImpl { + return s.protectionContainerMappingProviderSpecificDetails +} + +func UnmarshalProtectionContainerMappingProviderSpecificDetailsImplementation(input []byte) (ProtectionContainerMappingProviderSpecificDetails, 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 ProtectionContainerMappingProviderSpecificDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AProtectionContainerMappingDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AProtectionContainerMappingDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmProtectionContainerMappingDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmProtectionContainerMappingDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtProtectionContainerMappingDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtProtectionContainerMappingDetails: %+v", err) + } + return out, nil + } + + var parent BaseProtectionContainerMappingProviderSpecificDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseProtectionContainerMappingProviderSpecificDetailsImpl: %+v", err) + } + + return RawProtectionContainerMappingProviderSpecificDetailsImpl{ + protectionContainerMappingProviderSpecificDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_removeprotectioncontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_removeprotectioncontainermappinginput.go new file mode 100644 index 00000000000..ac6d64ca0d6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_removeprotectioncontainermappinginput.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainermappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemoveProtectionContainerMappingInput struct { + Properties *RemoveProtectionContainerMappingInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_removeprotectioncontainermappinginputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_removeprotectioncontainermappinginputproperties.go new file mode 100644 index 00000000000..cda0927d8cd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_removeprotectioncontainermappinginputproperties.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainermappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemoveProtectionContainerMappingInputProperties struct { + ProviderSpecificInput *ReplicationProviderContainerUnmappingInput `json:"providerSpecificInput,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_replicationprovidercontainerunmappinginput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_replicationprovidercontainerunmappinginput.go new file mode 100644 index 00000000000..862047c52a1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_replicationprovidercontainerunmappinginput.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainermappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProviderContainerUnmappingInput struct { + InstanceType *string `json:"instanceType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_replicationproviderspecificcontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_replicationproviderspecificcontainermappinginput.go new file mode 100644 index 00000000000..dfce897f5d0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_replicationproviderspecificcontainermappinginput.go @@ -0,0 +1,83 @@ +package replicationprotectioncontainermappings + +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 ReplicationProviderSpecificContainerMappingInput interface { + ReplicationProviderSpecificContainerMappingInput() BaseReplicationProviderSpecificContainerMappingInputImpl +} + +var _ ReplicationProviderSpecificContainerMappingInput = BaseReplicationProviderSpecificContainerMappingInputImpl{} + +type BaseReplicationProviderSpecificContainerMappingInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseReplicationProviderSpecificContainerMappingInputImpl) ReplicationProviderSpecificContainerMappingInput() BaseReplicationProviderSpecificContainerMappingInputImpl { + return s +} + +var _ ReplicationProviderSpecificContainerMappingInput = RawReplicationProviderSpecificContainerMappingInputImpl{} + +// RawReplicationProviderSpecificContainerMappingInputImpl 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 RawReplicationProviderSpecificContainerMappingInputImpl struct { + replicationProviderSpecificContainerMappingInput BaseReplicationProviderSpecificContainerMappingInputImpl + Type string + Values map[string]interface{} +} + +func (s RawReplicationProviderSpecificContainerMappingInputImpl) ReplicationProviderSpecificContainerMappingInput() BaseReplicationProviderSpecificContainerMappingInputImpl { + return s.replicationProviderSpecificContainerMappingInput +} + +func UnmarshalReplicationProviderSpecificContainerMappingInputImplementation(input []byte) (ReplicationProviderSpecificContainerMappingInput, 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 ReplicationProviderSpecificContainerMappingInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AContainerMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AContainerMappingInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtContainerMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtContainerMappingInput: %+v", err) + } + return out, nil + } + + var parent BaseReplicationProviderSpecificContainerMappingInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseReplicationProviderSpecificContainerMappingInputImpl: %+v", err) + } + + return RawReplicationProviderSpecificContainerMappingInputImpl{ + replicationProviderSpecificContainerMappingInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_replicationproviderspecificupdatecontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_replicationproviderspecificupdatecontainermappinginput.go new file mode 100644 index 00000000000..b32cc5dc7c0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_replicationproviderspecificupdatecontainermappinginput.go @@ -0,0 +1,83 @@ +package replicationprotectioncontainermappings + +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 ReplicationProviderSpecificUpdateContainerMappingInput interface { + ReplicationProviderSpecificUpdateContainerMappingInput() BaseReplicationProviderSpecificUpdateContainerMappingInputImpl +} + +var _ ReplicationProviderSpecificUpdateContainerMappingInput = BaseReplicationProviderSpecificUpdateContainerMappingInputImpl{} + +type BaseReplicationProviderSpecificUpdateContainerMappingInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseReplicationProviderSpecificUpdateContainerMappingInputImpl) ReplicationProviderSpecificUpdateContainerMappingInput() BaseReplicationProviderSpecificUpdateContainerMappingInputImpl { + return s +} + +var _ ReplicationProviderSpecificUpdateContainerMappingInput = RawReplicationProviderSpecificUpdateContainerMappingInputImpl{} + +// RawReplicationProviderSpecificUpdateContainerMappingInputImpl 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 RawReplicationProviderSpecificUpdateContainerMappingInputImpl struct { + replicationProviderSpecificUpdateContainerMappingInput BaseReplicationProviderSpecificUpdateContainerMappingInputImpl + Type string + Values map[string]interface{} +} + +func (s RawReplicationProviderSpecificUpdateContainerMappingInputImpl) ReplicationProviderSpecificUpdateContainerMappingInput() BaseReplicationProviderSpecificUpdateContainerMappingInputImpl { + return s.replicationProviderSpecificUpdateContainerMappingInput +} + +func UnmarshalReplicationProviderSpecificUpdateContainerMappingInputImplementation(input []byte) (ReplicationProviderSpecificUpdateContainerMappingInput, 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 ReplicationProviderSpecificUpdateContainerMappingInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AUpdateContainerMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AUpdateContainerMappingInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmUpdateContainerMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmUpdateContainerMappingInput: %+v", err) + } + return out, nil + } + + var parent BaseReplicationProviderSpecificUpdateContainerMappingInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseReplicationProviderSpecificUpdateContainerMappingInputImpl: %+v", err) + } + + return RawReplicationProviderSpecificUpdateContainerMappingInputImpl{ + replicationProviderSpecificUpdateContainerMappingInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_updateprotectioncontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_updateprotectioncontainermappinginput.go new file mode 100644 index 00000000000..9c2d7bf172c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_updateprotectioncontainermappinginput.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainermappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateProtectionContainerMappingInput struct { + Properties *UpdateProtectionContainerMappingInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_updateprotectioncontainermappinginputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_updateprotectioncontainermappinginputproperties.go new file mode 100644 index 00000000000..f68cab5cb26 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_updateprotectioncontainermappinginputproperties.go @@ -0,0 +1,33 @@ +package replicationprotectioncontainermappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateProtectionContainerMappingInputProperties struct { + ProviderSpecificInput ReplicationProviderSpecificUpdateContainerMappingInput `json:"providerSpecificInput"` +} + +var _ json.Unmarshaler = &UpdateProtectionContainerMappingInputProperties{} + +func (s *UpdateProtectionContainerMappingInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling UpdateProtectionContainerMappingInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificInput"]; ok { + impl, err := UnmarshalReplicationProviderSpecificUpdateContainerMappingInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificInput' for 'UpdateProtectionContainerMappingInputProperties': %+v", err) + } + s.ProviderSpecificInput = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_vmwarecbtcontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_vmwarecbtcontainermappinginput.go new file mode 100644 index 00000000000..a7b44d461aa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_vmwarecbtcontainermappinginput.go @@ -0,0 +1,55 @@ +package replicationprotectioncontainermappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificContainerMappingInput = VMwareCbtContainerMappingInput{} + +type VMwareCbtContainerMappingInput struct { + KeyVaultId *string `json:"keyVaultId,omitempty"` + KeyVaultUri *string `json:"keyVaultUri,omitempty"` + ServiceBusConnectionStringSecretName *string `json:"serviceBusConnectionStringSecretName,omitempty"` + StorageAccountId string `json:"storageAccountId"` + StorageAccountSasSecretName *string `json:"storageAccountSasSecretName,omitempty"` + TargetLocation string `json:"targetLocation"` + + // Fields inherited from ReplicationProviderSpecificContainerMappingInput + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtContainerMappingInput) ReplicationProviderSpecificContainerMappingInput() BaseReplicationProviderSpecificContainerMappingInputImpl { + return BaseReplicationProviderSpecificContainerMappingInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtContainerMappingInput{} + +func (s VMwareCbtContainerMappingInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtContainerMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtContainerMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtContainerMappingInput: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtContainerMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_vmwarecbtprotectioncontainermappingdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_vmwarecbtprotectioncontainermappingdetails.go new file mode 100644 index 00000000000..0e4716ee72b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/model_vmwarecbtprotectioncontainermappingdetails.go @@ -0,0 +1,57 @@ +package replicationprotectioncontainermappings + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainerMappingProviderSpecificDetails = VMwareCbtProtectionContainerMappingDetails{} + +type VMwareCbtProtectionContainerMappingDetails struct { + ExcludedSkus *[]string `json:"excludedSkus,omitempty"` + KeyVaultId *string `json:"keyVaultId,omitempty"` + KeyVaultUri *string `json:"keyVaultUri,omitempty"` + RoleSizeToNicCountMap *map[string]int64 `json:"roleSizeToNicCountMap,omitempty"` + ServiceBusConnectionStringSecretName *string `json:"serviceBusConnectionStringSecretName,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + StorageAccountSasSecretName *string `json:"storageAccountSasSecretName,omitempty"` + TargetLocation *string `json:"targetLocation,omitempty"` + + // Fields inherited from ProtectionContainerMappingProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtProtectionContainerMappingDetails) ProtectionContainerMappingProviderSpecificDetails() BaseProtectionContainerMappingProviderSpecificDetailsImpl { + return BaseProtectionContainerMappingProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtProtectionContainerMappingDetails{} + +func (s VMwareCbtProtectionContainerMappingDetails) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtProtectionContainerMappingDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtProtectionContainerMappingDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtProtectionContainerMappingDetails: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtProtectionContainerMappingDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/predicates.go new file mode 100644 index 00000000000..c60ddcb4a31 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/predicates.go @@ -0,0 +1,32 @@ +package replicationprotectioncontainermappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerMappingOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ProtectionContainerMappingOperationPredicate) Matches(input ProtectionContainerMapping) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/version.go new file mode 100644 index 00000000000..df3c0eb979b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainermappings/version.go @@ -0,0 +1,10 @@ +package replicationprotectioncontainermappings + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationprotectioncontainermappings/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/README.md new file mode 100644 index 00000000000..828900e48c2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/README.md @@ -0,0 +1,150 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers` Documentation + +The `replicationprotectioncontainers` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers" +``` + + +### Client Initialization + +```go +client := replicationprotectioncontainers.NewReplicationProtectionContainersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationProtectionContainersClient.Create` + +```go +ctx := context.TODO() +id := replicationprotectioncontainers.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + +payload := replicationprotectioncontainers.CreateProtectionContainerInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionContainersClient.Delete` + +```go +ctx := context.TODO() +id := replicationprotectioncontainers.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionContainersClient.DiscoverProtectableItem` + +```go +ctx := context.TODO() +id := replicationprotectioncontainers.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + +payload := replicationprotectioncontainers.DiscoverProtectableItemRequest{ + // ... +} + + +if err := client.DiscoverProtectableItemThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionContainersClient.Get` + +```go +ctx := context.TODO() +id := replicationprotectioncontainers.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + +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: `ReplicationProtectionContainersClient.List` + +```go +ctx := context.TODO() +id := replicationprotectioncontainers.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationProtectionContainersClient.ListByReplicationFabrics` + +```go +ctx := context.TODO() +id := replicationprotectioncontainers.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +// alternatively `client.ListByReplicationFabrics(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationFabricsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationProtectionContainersClient.SwitchClusterProtection` + +```go +ctx := context.TODO() +id := replicationprotectioncontainers.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + +payload := replicationprotectioncontainers.SwitchClusterProtectionInput{ + // ... +} + + +if err := client.SwitchClusterProtectionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionContainersClient.SwitchProtection` + +```go +ctx := context.TODO() +id := replicationprotectioncontainers.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + +payload := replicationprotectioncontainers.SwitchProtectionInput{ + // ... +} + + +if err := client.SwitchProtectionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/client.go new file mode 100644 index 00000000000..29eec428f7f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/client.go @@ -0,0 +1,26 @@ +package replicationprotectioncontainers + +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 ReplicationProtectionContainersClient struct { + Client *resourcemanager.Client +} + +func NewReplicationProtectionContainersClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationProtectionContainersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationprotectioncontainers", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationProtectionContainersClient: %+v", err) + } + + return &ReplicationProtectionContainersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/id_replicationfabric.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/id_replicationfabric.go new file mode 100644 index 00000000000..3bd079512ad --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/id_replicationfabric.go @@ -0,0 +1,139 @@ +package replicationprotectioncontainers + +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(&ReplicationFabricId{}) +} + +var _ resourceids.ResourceId = &ReplicationFabricId{} + +// ReplicationFabricId is a struct representing the Resource ID for a Replication Fabric +type ReplicationFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string +} + +// NewReplicationFabricID returns a new ReplicationFabricId struct +func NewReplicationFabricID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string) ReplicationFabricId { + return ReplicationFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + } +} + +// ParseReplicationFabricID parses 'input' into a ReplicationFabricId +func ParseReplicationFabricID(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationFabricIDInsensitively parses 'input' case-insensitively into a ReplicationFabricId +// note: this method should only be used for API response data and not user input +func ParseReplicationFabricIDInsensitively(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationFabricId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + return nil +} + +// ValidateReplicationFabricID checks that 'input' can be parsed as a Replication Fabric ID +func ValidateReplicationFabricID(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 := ParseReplicationFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Fabric ID +func (id ReplicationFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Fabric ID +func (id ReplicationFabricId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + } +} + +// String returns a human-readable description of this Replication Fabric ID +func (id ReplicationFabricId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + } + return fmt.Sprintf("Replication Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/id_replicationfabric_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/id_replicationfabric_test.go new file mode 100644 index 00000000000..4bf4be40c8e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/id_replicationfabric_test.go @@ -0,0 +1,327 @@ +package replicationprotectioncontainers + +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 = &ReplicationFabricId{} + +func TestNewReplicationFabricID(t *testing.T) { + id := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } +} + +func TestFormatReplicationFabricID(t *testing.T) { + actual := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestParseReplicationFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestSegmentsForReplicationFabricId(t *testing.T) { + segments := ReplicationFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationFabricId 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/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/id_replicationprotectioncontainer.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/id_replicationprotectioncontainer.go new file mode 100644 index 00000000000..e5592319c54 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/id_replicationprotectioncontainer.go @@ -0,0 +1,148 @@ +package replicationprotectioncontainers + +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(&ReplicationProtectionContainerId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectionContainerId{} + +// ReplicationProtectionContainerId is a struct representing the Resource ID for a Replication Protection Container +type ReplicationProtectionContainerId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string +} + +// NewReplicationProtectionContainerID returns a new ReplicationProtectionContainerId struct +func NewReplicationProtectionContainerID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string) ReplicationProtectionContainerId { + return ReplicationProtectionContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + } +} + +// ParseReplicationProtectionContainerID parses 'input' into a ReplicationProtectionContainerId +func ParseReplicationProtectionContainerID(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionContainerIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionContainerId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionContainerIDInsensitively(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionContainerId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + return nil +} + +// ValidateReplicationProtectionContainerID checks that 'input' can be parsed as a Replication Protection Container ID +func ValidateReplicationProtectionContainerID(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 := ParseReplicationProtectionContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Container ID +func (id ReplicationProtectionContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Container ID +func (id ReplicationProtectionContainerId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + } +} + +// String returns a human-readable description of this Replication Protection Container ID +func (id ReplicationProtectionContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + } + return fmt.Sprintf("Replication Protection Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/id_replicationprotectioncontainer_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/id_replicationprotectioncontainer_test.go new file mode 100644 index 00000000000..a91ca97cb10 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/id_replicationprotectioncontainer_test.go @@ -0,0 +1,372 @@ +package replicationprotectioncontainers + +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 = &ReplicationProtectionContainerId{} + +func TestNewReplicationProtectionContainerID(t *testing.T) { + id := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } +} + +func TestFormatReplicationProtectionContainerID(t *testing.T) { + actual := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestParseReplicationProtectionContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestSegmentsForReplicationProtectionContainerId(t *testing.T) { + segments := ReplicationProtectionContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionContainerId 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/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/id_vault.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/id_vault.go new file mode 100644 index 00000000000..8bf89545d20 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/id_vault.go @@ -0,0 +1,130 @@ +package replicationprotectioncontainers + +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(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(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 := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/id_vault_test.go new file mode 100644 index 00000000000..4d480e32c58 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationprotectioncontainers + +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 = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId 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/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_create.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_create.go new file mode 100644 index 00000000000..ceb6aa4ab31 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_create.go @@ -0,0 +1,75 @@ +package replicationprotectioncontainers + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ProtectionContainer +} + +// Create ... +func (c ReplicationProtectionContainersClient) Create(ctx context.Context, id ReplicationProtectionContainerId, input CreateProtectionContainerInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationProtectionContainersClient) CreateThenPoll(ctx context.Context, id ReplicationProtectionContainerId, input CreateProtectionContainerInput) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_delete.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_delete.go new file mode 100644 index 00000000000..63ac30675e0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_delete.go @@ -0,0 +1,70 @@ +package replicationprotectioncontainers + +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 ReplicationProtectionContainersClient) Delete(ctx context.Context, id ReplicationProtectionContainerId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/remove", 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 ReplicationProtectionContainersClient) DeleteThenPoll(ctx context.Context, id ReplicationProtectionContainerId) 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/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_discoverprotectableitem.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_discoverprotectableitem.go new file mode 100644 index 00000000000..6a65eda5d16 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_discoverprotectableitem.go @@ -0,0 +1,75 @@ +package replicationprotectioncontainers + +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 DiscoverProtectableItemOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ProtectionContainer +} + +// DiscoverProtectableItem ... +func (c ReplicationProtectionContainersClient) DiscoverProtectableItem(ctx context.Context, id ReplicationProtectionContainerId, input DiscoverProtectableItemRequest) (result DiscoverProtectableItemOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/discoverProtectableItem", 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 +} + +// DiscoverProtectableItemThenPoll performs DiscoverProtectableItem then polls until it's completed +func (c ReplicationProtectionContainersClient) DiscoverProtectableItemThenPoll(ctx context.Context, id ReplicationProtectionContainerId, input DiscoverProtectableItemRequest) error { + result, err := c.DiscoverProtectableItem(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DiscoverProtectableItem: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DiscoverProtectableItem: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_get.go new file mode 100644 index 00000000000..76f18d1e4d0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_get.go @@ -0,0 +1,53 @@ +package replicationprotectioncontainers + +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 *ProtectionContainer +} + +// Get ... +func (c ReplicationProtectionContainersClient) Get(ctx context.Context, id ReplicationProtectionContainerId) (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 ProtectionContainer + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_list.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_list.go new file mode 100644 index 00000000000..d678bf5102a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_list.go @@ -0,0 +1,105 @@ +package replicationprotectioncontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProtectionContainer +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProtectionContainer +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ReplicationProtectionContainersClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/replicationProtectionContainers", 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 *[]ProtectionContainer `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationProtectionContainersClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ProtectionContainerOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectionContainersClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate ProtectionContainerOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ProtectionContainer, 0) + + resp, err := c.List(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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_listbyreplicationfabrics.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_listbyreplicationfabrics.go new file mode 100644 index 00000000000..d870a7c81fd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_listbyreplicationfabrics.go @@ -0,0 +1,105 @@ +package replicationprotectioncontainers + +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 ListByReplicationFabricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProtectionContainer +} + +type ListByReplicationFabricsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProtectionContainer +} + +type ListByReplicationFabricsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationFabricsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationFabrics ... +func (c ReplicationProtectionContainersClient) ListByReplicationFabrics(ctx context.Context, id ReplicationFabricId) (result ListByReplicationFabricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationFabricsCustomPager{}, + Path: fmt.Sprintf("%s/replicationProtectionContainers", 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 *[]ProtectionContainer `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationFabricsComplete retrieves all the results into a single object +func (c ReplicationProtectionContainersClient) ListByReplicationFabricsComplete(ctx context.Context, id ReplicationFabricId) (ListByReplicationFabricsCompleteResult, error) { + return c.ListByReplicationFabricsCompleteMatchingPredicate(ctx, id, ProtectionContainerOperationPredicate{}) +} + +// ListByReplicationFabricsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectionContainersClient) ListByReplicationFabricsCompleteMatchingPredicate(ctx context.Context, id ReplicationFabricId, predicate ProtectionContainerOperationPredicate) (result ListByReplicationFabricsCompleteResult, err error) { + items := make([]ProtectionContainer, 0) + + resp, err := c.ListByReplicationFabrics(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 = ListByReplicationFabricsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_switchclusterprotection.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_switchclusterprotection.go new file mode 100644 index 00000000000..f8e1e9bde75 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_switchclusterprotection.go @@ -0,0 +1,75 @@ +package replicationprotectioncontainers + +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 SwitchClusterProtectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ProtectionContainer +} + +// SwitchClusterProtection ... +func (c ReplicationProtectionContainersClient) SwitchClusterProtection(ctx context.Context, id ReplicationProtectionContainerId, input SwitchClusterProtectionInput) (result SwitchClusterProtectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/switchClusterProtection", 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 +} + +// SwitchClusterProtectionThenPoll performs SwitchClusterProtection then polls until it's completed +func (c ReplicationProtectionContainersClient) SwitchClusterProtectionThenPoll(ctx context.Context, id ReplicationProtectionContainerId, input SwitchClusterProtectionInput) error { + result, err := c.SwitchClusterProtection(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SwitchClusterProtection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SwitchClusterProtection: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_switchprotection.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_switchprotection.go new file mode 100644 index 00000000000..a9b935c76c1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/method_switchprotection.go @@ -0,0 +1,75 @@ +package replicationprotectioncontainers + +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 SwitchProtectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ProtectionContainer +} + +// SwitchProtection ... +func (c ReplicationProtectionContainersClient) SwitchProtection(ctx context.Context, id ReplicationProtectionContainerId, input SwitchProtectionInput) (result SwitchProtectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/switchprotection", 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 +} + +// SwitchProtectionThenPoll performs SwitchProtection then polls until it's completed +func (c ReplicationProtectionContainersClient) SwitchProtectionThenPoll(ctx context.Context, id ReplicationProtectionContainerId, input SwitchProtectionInput) error { + result, err := c.SwitchProtection(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SwitchProtection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SwitchProtection: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_a2acontainercreationinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_a2acontainercreationinput.go new file mode 100644 index 00000000000..f119b15f58d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_a2acontainercreationinput.go @@ -0,0 +1,49 @@ +package replicationprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificContainerCreationInput = A2AContainerCreationInput{} + +type A2AContainerCreationInput struct { + + // Fields inherited from ReplicationProviderSpecificContainerCreationInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AContainerCreationInput) ReplicationProviderSpecificContainerCreationInput() BaseReplicationProviderSpecificContainerCreationInputImpl { + return BaseReplicationProviderSpecificContainerCreationInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AContainerCreationInput{} + +func (s A2AContainerCreationInput) MarshalJSON() ([]byte, error) { + type wrapper A2AContainerCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AContainerCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AContainerCreationInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AContainerCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_a2acrossclustermigrationcontainercreationinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_a2acrossclustermigrationcontainercreationinput.go new file mode 100644 index 00000000000..8f67cf738e5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_a2acrossclustermigrationcontainercreationinput.go @@ -0,0 +1,49 @@ +package replicationprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificContainerCreationInput = A2ACrossClusterMigrationContainerCreationInput{} + +type A2ACrossClusterMigrationContainerCreationInput struct { + + // Fields inherited from ReplicationProviderSpecificContainerCreationInput + + InstanceType string `json:"instanceType"` +} + +func (s A2ACrossClusterMigrationContainerCreationInput) ReplicationProviderSpecificContainerCreationInput() BaseReplicationProviderSpecificContainerCreationInputImpl { + return BaseReplicationProviderSpecificContainerCreationInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ACrossClusterMigrationContainerCreationInput{} + +func (s A2ACrossClusterMigrationContainerCreationInput) MarshalJSON() ([]byte, error) { + type wrapper A2ACrossClusterMigrationContainerCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ACrossClusterMigrationContainerCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ACrossClusterMigrationContainerCreationInput: %+v", err) + } + + decoded["instanceType"] = "A2ACrossClusterMigration" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ACrossClusterMigrationContainerCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_a2aprotecteditemdetail.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_a2aprotecteditemdetail.go new file mode 100644 index 00000000000..0bd00cf3819 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_a2aprotecteditemdetail.go @@ -0,0 +1,17 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AProtectedItemDetail struct { + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + RecoveryAvailabilityZone *string `json:"recoveryAvailabilityZone,omitempty"` + RecoveryBootDiagStorageAccountId *string `json:"recoveryBootDiagStorageAccountId,omitempty"` + RecoveryCapacityReservationGroupId *string `json:"recoveryCapacityReservationGroupId,omitempty"` + RecoveryProximityPlacementGroupId *string `json:"recoveryProximityPlacementGroupId,omitempty"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + RecoveryVirtualMachineScaleSetId *string `json:"recoveryVirtualMachineScaleSetId,omitempty"` + ReplicationProtectedItemName *string `json:"replicationProtectedItemName,omitempty"` + VMManagedDisks *[]A2AVMManagedDiskInputDetails `json:"vmManagedDisks,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_a2aswitchclusterprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_a2aswitchclusterprotectioninput.go new file mode 100644 index 00000000000..162f36c45b2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_a2aswitchclusterprotectioninput.go @@ -0,0 +1,52 @@ +package replicationprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SwitchClusterProtectionProviderSpecificInput = A2ASwitchClusterProtectionInput{} + +type A2ASwitchClusterProtectionInput struct { + PolicyId *string `json:"policyId,omitempty"` + ProtectedItemsDetail *[]A2AProtectedItemDetail `json:"protectedItemsDetail,omitempty"` + RecoveryContainerId *string `json:"recoveryContainerId,omitempty"` + + // Fields inherited from SwitchClusterProtectionProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2ASwitchClusterProtectionInput) SwitchClusterProtectionProviderSpecificInput() BaseSwitchClusterProtectionProviderSpecificInputImpl { + return BaseSwitchClusterProtectionProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ASwitchClusterProtectionInput{} + +func (s A2ASwitchClusterProtectionInput) MarshalJSON() ([]byte, error) { + type wrapper A2ASwitchClusterProtectionInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ASwitchClusterProtectionInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ASwitchClusterProtectionInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ASwitchClusterProtectionInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_a2aswitchprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_a2aswitchprotectioninput.go new file mode 100644 index 00000000000..fc86ae07dcd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_a2aswitchprotectioninput.go @@ -0,0 +1,62 @@ +package replicationprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SwitchProtectionProviderSpecificInput = A2ASwitchProtectionInput{} + +type A2ASwitchProtectionInput struct { + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + RecoveryAvailabilityZone *string `json:"recoveryAvailabilityZone,omitempty"` + RecoveryBootDiagStorageAccountId *string `json:"recoveryBootDiagStorageAccountId,omitempty"` + RecoveryCapacityReservationGroupId *string `json:"recoveryCapacityReservationGroupId,omitempty"` + RecoveryCloudServiceId *string `json:"recoveryCloudServiceId,omitempty"` + RecoveryContainerId *string `json:"recoveryContainerId,omitempty"` + RecoveryProximityPlacementGroupId *string `json:"recoveryProximityPlacementGroupId,omitempty"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + RecoveryVirtualMachineScaleSetId *string `json:"recoveryVirtualMachineScaleSetId,omitempty"` + VMDisks *[]A2AVMDiskInputDetails `json:"vmDisks,omitempty"` + VMManagedDisks *[]A2AVMManagedDiskInputDetails `json:"vmManagedDisks,omitempty"` + + // Fields inherited from SwitchProtectionProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2ASwitchProtectionInput) SwitchProtectionProviderSpecificInput() BaseSwitchProtectionProviderSpecificInputImpl { + return BaseSwitchProtectionProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ASwitchProtectionInput{} + +func (s A2ASwitchProtectionInput) MarshalJSON() ([]byte, error) { + type wrapper A2ASwitchProtectionInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ASwitchProtectionInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ASwitchProtectionInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ASwitchProtectionInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_a2avmdiskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_a2avmdiskinputdetails.go new file mode 100644 index 00000000000..1e0784c90fc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_a2avmdiskinputdetails.go @@ -0,0 +1,10 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AVMDiskInputDetails struct { + DiskUri string `json:"diskUri"` + PrimaryStagingAzureStorageAccountId string `json:"primaryStagingAzureStorageAccountId"` + RecoveryAzureStorageAccountId string `json:"recoveryAzureStorageAccountId"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_a2avmmanageddiskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_a2avmmanageddiskinputdetails.go new file mode 100644 index 00000000000..6c0c988393d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_a2avmmanageddiskinputdetails.go @@ -0,0 +1,14 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AVMManagedDiskInputDetails struct { + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + DiskId string `json:"diskId"` + PrimaryStagingAzureStorageAccountId string `json:"primaryStagingAzureStorageAccountId"` + RecoveryDiskEncryptionSetId *string `json:"recoveryDiskEncryptionSetId,omitempty"` + RecoveryReplicaDiskAccountType *string `json:"recoveryReplicaDiskAccountType,omitempty"` + RecoveryResourceGroupId string `json:"recoveryResourceGroupId"` + RecoveryTargetDiskAccountType *string `json:"recoveryTargetDiskAccountType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_createprotectioncontainerinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_createprotectioncontainerinput.go new file mode 100644 index 00000000000..55175403c81 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_createprotectioncontainerinput.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateProtectionContainerInput struct { + Properties *CreateProtectionContainerInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_createprotectioncontainerinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_createprotectioncontainerinputproperties.go new file mode 100644 index 00000000000..48d608a76f0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_createprotectioncontainerinputproperties.go @@ -0,0 +1,42 @@ +package replicationprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateProtectionContainerInputProperties struct { + ProviderSpecificInput *[]ReplicationProviderSpecificContainerCreationInput `json:"providerSpecificInput,omitempty"` +} + +var _ json.Unmarshaler = &CreateProtectionContainerInputProperties{} + +func (s *CreateProtectionContainerInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CreateProtectionContainerInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificInput"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling ProviderSpecificInput into list []json.RawMessage: %+v", err) + } + + output := make([]ReplicationProviderSpecificContainerCreationInput, 0) + for i, val := range listTemp { + impl, err := UnmarshalReplicationProviderSpecificContainerCreationInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'ProviderSpecificInput' for 'CreateProtectionContainerInputProperties': %+v", i, err) + } + output = append(output, impl) + } + s.ProviderSpecificInput = &output + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_discoverprotectableitemrequest.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_discoverprotectableitemrequest.go new file mode 100644 index 00000000000..ceca9005e59 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_discoverprotectableitemrequest.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoverProtectableItemRequest struct { + Properties *DiscoverProtectableItemRequestProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_discoverprotectableitemrequestproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_discoverprotectableitemrequestproperties.go new file mode 100644 index 00000000000..fee5502a3c7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_discoverprotectableitemrequestproperties.go @@ -0,0 +1,10 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoverProtectableItemRequestProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + OsType *string `json:"osType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_diskencryptioninfo.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_diskencryptioninfo.go new file mode 100644 index 00000000000..997e7018bf6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_diskencryptioninfo.go @@ -0,0 +1,9 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskEncryptionInfo struct { + DiskEncryptionKeyInfo *DiskEncryptionKeyInfo `json:"diskEncryptionKeyInfo,omitempty"` + KeyEncryptionKeyInfo *KeyEncryptionKeyInfo `json:"keyEncryptionKeyInfo,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_diskencryptionkeyinfo.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_diskencryptionkeyinfo.go new file mode 100644 index 00000000000..e67e3239790 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_diskencryptionkeyinfo.go @@ -0,0 +1,9 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskEncryptionKeyInfo struct { + KeyVaultResourceArmId *string `json:"keyVaultResourceArmId,omitempty"` + SecretIdentifier *string `json:"secretIdentifier,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_keyencryptionkeyinfo.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_keyencryptionkeyinfo.go new file mode 100644 index 00000000000..e5eb025e741 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_keyencryptionkeyinfo.go @@ -0,0 +1,9 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyEncryptionKeyInfo struct { + KeyIdentifier *string `json:"keyIdentifier,omitempty"` + KeyVaultResourceArmId *string `json:"keyVaultResourceArmId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_protectioncontainer.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_protectioncontainer.go new file mode 100644 index 00000000000..0236469ade2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_protectioncontainer.go @@ -0,0 +1,12 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainer struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ProtectionContainerProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_protectioncontainerfabricspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_protectioncontainerfabricspecificdetails.go new file mode 100644 index 00000000000..ccda06f411a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_protectioncontainerfabricspecificdetails.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerFabricSpecificDetails struct { + InstanceType *string `json:"instanceType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_protectioncontainerproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_protectioncontainerproperties.go new file mode 100644 index 00000000000..baa48fb4dcd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_protectioncontainerproperties.go @@ -0,0 +1,14 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerProperties struct { + FabricFriendlyName *string `json:"fabricFriendlyName,omitempty"` + FabricSpecificDetails *ProtectionContainerFabricSpecificDetails `json:"fabricSpecificDetails,omitempty"` + FabricType *string `json:"fabricType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + PairingStatus *string `json:"pairingStatus,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + Role *string `json:"role,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_replicationproviderspecificcontainercreationinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_replicationproviderspecificcontainercreationinput.go new file mode 100644 index 00000000000..584ed7078c6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_replicationproviderspecificcontainercreationinput.go @@ -0,0 +1,91 @@ +package replicationprotectioncontainers + +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 ReplicationProviderSpecificContainerCreationInput interface { + ReplicationProviderSpecificContainerCreationInput() BaseReplicationProviderSpecificContainerCreationInputImpl +} + +var _ ReplicationProviderSpecificContainerCreationInput = BaseReplicationProviderSpecificContainerCreationInputImpl{} + +type BaseReplicationProviderSpecificContainerCreationInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseReplicationProviderSpecificContainerCreationInputImpl) ReplicationProviderSpecificContainerCreationInput() BaseReplicationProviderSpecificContainerCreationInputImpl { + return s +} + +var _ ReplicationProviderSpecificContainerCreationInput = RawReplicationProviderSpecificContainerCreationInputImpl{} + +// RawReplicationProviderSpecificContainerCreationInputImpl 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 RawReplicationProviderSpecificContainerCreationInputImpl struct { + replicationProviderSpecificContainerCreationInput BaseReplicationProviderSpecificContainerCreationInputImpl + Type string + Values map[string]interface{} +} + +func (s RawReplicationProviderSpecificContainerCreationInputImpl) ReplicationProviderSpecificContainerCreationInput() BaseReplicationProviderSpecificContainerCreationInputImpl { + return s.replicationProviderSpecificContainerCreationInput +} + +func UnmarshalReplicationProviderSpecificContainerCreationInputImplementation(input []byte) (ReplicationProviderSpecificContainerCreationInput, 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 ReplicationProviderSpecificContainerCreationInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AContainerCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AContainerCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "A2ACrossClusterMigration") { + var out A2ACrossClusterMigrationContainerCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ACrossClusterMigrationContainerCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtContainerCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtContainerCreationInput: %+v", err) + } + return out, nil + } + + var parent BaseReplicationProviderSpecificContainerCreationInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseReplicationProviderSpecificContainerCreationInputImpl: %+v", err) + } + + return RawReplicationProviderSpecificContainerCreationInputImpl{ + replicationProviderSpecificContainerCreationInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_switchclusterprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_switchclusterprotectioninput.go new file mode 100644 index 00000000000..7e8c500b452 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_switchclusterprotectioninput.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwitchClusterProtectionInput struct { + Properties *SwitchClusterProtectionInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_switchclusterprotectioninputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_switchclusterprotectioninputproperties.go new file mode 100644 index 00000000000..4a8c6eb5b38 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_switchclusterprotectioninputproperties.go @@ -0,0 +1,42 @@ +package replicationprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwitchClusterProtectionInputProperties struct { + ProviderSpecificDetails SwitchClusterProtectionProviderSpecificInput `json:"providerSpecificDetails"` + ReplicationProtectionClusterName *string `json:"replicationProtectionClusterName,omitempty"` +} + +var _ json.Unmarshaler = &SwitchClusterProtectionInputProperties{} + +func (s *SwitchClusterProtectionInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ReplicationProtectionClusterName *string `json:"replicationProtectionClusterName,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ReplicationProtectionClusterName = decoded.ReplicationProtectionClusterName + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SwitchClusterProtectionInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalSwitchClusterProtectionProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'SwitchClusterProtectionInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_switchclusterprotectionproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_switchclusterprotectionproviderspecificinput.go new file mode 100644 index 00000000000..acc419f50ba --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_switchclusterprotectionproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationprotectioncontainers + +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 SwitchClusterProtectionProviderSpecificInput interface { + SwitchClusterProtectionProviderSpecificInput() BaseSwitchClusterProtectionProviderSpecificInputImpl +} + +var _ SwitchClusterProtectionProviderSpecificInput = BaseSwitchClusterProtectionProviderSpecificInputImpl{} + +type BaseSwitchClusterProtectionProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseSwitchClusterProtectionProviderSpecificInputImpl) SwitchClusterProtectionProviderSpecificInput() BaseSwitchClusterProtectionProviderSpecificInputImpl { + return s +} + +var _ SwitchClusterProtectionProviderSpecificInput = RawSwitchClusterProtectionProviderSpecificInputImpl{} + +// RawSwitchClusterProtectionProviderSpecificInputImpl 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 RawSwitchClusterProtectionProviderSpecificInputImpl struct { + switchClusterProtectionProviderSpecificInput BaseSwitchClusterProtectionProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawSwitchClusterProtectionProviderSpecificInputImpl) SwitchClusterProtectionProviderSpecificInput() BaseSwitchClusterProtectionProviderSpecificInputImpl { + return s.switchClusterProtectionProviderSpecificInput +} + +func UnmarshalSwitchClusterProtectionProviderSpecificInputImplementation(input []byte) (SwitchClusterProtectionProviderSpecificInput, 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 SwitchClusterProtectionProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2ASwitchClusterProtectionInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ASwitchClusterProtectionInput: %+v", err) + } + return out, nil + } + + var parent BaseSwitchClusterProtectionProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSwitchClusterProtectionProviderSpecificInputImpl: %+v", err) + } + + return RawSwitchClusterProtectionProviderSpecificInputImpl{ + switchClusterProtectionProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_switchprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_switchprotectioninput.go new file mode 100644 index 00000000000..ebb469d6c10 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_switchprotectioninput.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwitchProtectionInput struct { + Properties *SwitchProtectionInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_switchprotectioninputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_switchprotectioninputproperties.go new file mode 100644 index 00000000000..1beb52fc599 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_switchprotectioninputproperties.go @@ -0,0 +1,42 @@ +package replicationprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwitchProtectionInputProperties struct { + ProviderSpecificDetails SwitchProtectionProviderSpecificInput `json:"providerSpecificDetails"` + ReplicationProtectedItemName *string `json:"replicationProtectedItemName,omitempty"` +} + +var _ json.Unmarshaler = &SwitchProtectionInputProperties{} + +func (s *SwitchProtectionInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ReplicationProtectedItemName *string `json:"replicationProtectedItemName,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ReplicationProtectedItemName = decoded.ReplicationProtectedItemName + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SwitchProtectionInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalSwitchProtectionProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'SwitchProtectionInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_switchprotectionproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_switchprotectionproviderspecificinput.go new file mode 100644 index 00000000000..1a50b26958a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_switchprotectionproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationprotectioncontainers + +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 SwitchProtectionProviderSpecificInput interface { + SwitchProtectionProviderSpecificInput() BaseSwitchProtectionProviderSpecificInputImpl +} + +var _ SwitchProtectionProviderSpecificInput = BaseSwitchProtectionProviderSpecificInputImpl{} + +type BaseSwitchProtectionProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseSwitchProtectionProviderSpecificInputImpl) SwitchProtectionProviderSpecificInput() BaseSwitchProtectionProviderSpecificInputImpl { + return s +} + +var _ SwitchProtectionProviderSpecificInput = RawSwitchProtectionProviderSpecificInputImpl{} + +// RawSwitchProtectionProviderSpecificInputImpl 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 RawSwitchProtectionProviderSpecificInputImpl struct { + switchProtectionProviderSpecificInput BaseSwitchProtectionProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawSwitchProtectionProviderSpecificInputImpl) SwitchProtectionProviderSpecificInput() BaseSwitchProtectionProviderSpecificInputImpl { + return s.switchProtectionProviderSpecificInput +} + +func UnmarshalSwitchProtectionProviderSpecificInputImplementation(input []byte) (SwitchProtectionProviderSpecificInput, 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 SwitchProtectionProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2ASwitchProtectionInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ASwitchProtectionInput: %+v", err) + } + return out, nil + } + + var parent BaseSwitchProtectionProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSwitchProtectionProviderSpecificInputImpl: %+v", err) + } + + return RawSwitchProtectionProviderSpecificInputImpl{ + switchProtectionProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_vmwarecbtcontainercreationinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_vmwarecbtcontainercreationinput.go new file mode 100644 index 00000000000..bea3e3c4f93 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/model_vmwarecbtcontainercreationinput.go @@ -0,0 +1,49 @@ +package replicationprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificContainerCreationInput = VMwareCbtContainerCreationInput{} + +type VMwareCbtContainerCreationInput struct { + + // Fields inherited from ReplicationProviderSpecificContainerCreationInput + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtContainerCreationInput) ReplicationProviderSpecificContainerCreationInput() BaseReplicationProviderSpecificContainerCreationInputImpl { + return BaseReplicationProviderSpecificContainerCreationInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtContainerCreationInput{} + +func (s VMwareCbtContainerCreationInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtContainerCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtContainerCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtContainerCreationInput: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtContainerCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/predicates.go new file mode 100644 index 00000000000..842a1e7ff08 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/predicates.go @@ -0,0 +1,32 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ProtectionContainerOperationPredicate) Matches(input ProtectionContainer) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/version.go new file mode 100644 index 00000000000..c5fb81263bc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectioncontainers/version.go @@ -0,0 +1,10 @@ +package replicationprotectioncontainers + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationprotectioncontainers/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/README.md new file mode 100644 index 00000000000..9c4b801ef8a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/README.md @@ -0,0 +1,74 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents` Documentation + +The `replicationprotectionintents` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents" +``` + + +### Client Initialization + +```go +client := replicationprotectionintents.NewReplicationProtectionIntentsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationProtectionIntentsClient.Create` + +```go +ctx := context.TODO() +id := replicationprotectionintents.NewReplicationProtectionIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationProtectionIntentName") + +payload := replicationprotectionintents.CreateProtectionIntentInput{ + // ... +} + + +read, err := client.Create(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ReplicationProtectionIntentsClient.Get` + +```go +ctx := context.TODO() +id := replicationprotectionintents.NewReplicationProtectionIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationProtectionIntentName") + +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: `ReplicationProtectionIntentsClient.List` + +```go +ctx := context.TODO() +id := replicationprotectionintents.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id, replicationprotectionintents.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, replicationprotectionintents.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/client.go new file mode 100644 index 00000000000..188347bfd7e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/client.go @@ -0,0 +1,26 @@ +package replicationprotectionintents + +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 ReplicationProtectionIntentsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationProtectionIntentsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationProtectionIntentsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationprotectionintents", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationProtectionIntentsClient: %+v", err) + } + + return &ReplicationProtectionIntentsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/constants.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/constants.go new file mode 100644 index 00000000000..359018e5915 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/constants.go @@ -0,0 +1,218 @@ +package replicationprotectionintents + +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 A2ARecoveryAvailabilityType string + +const ( + A2ARecoveryAvailabilityTypeAvailabilitySet A2ARecoveryAvailabilityType = "AvailabilitySet" + A2ARecoveryAvailabilityTypeAvailabilityZone A2ARecoveryAvailabilityType = "AvailabilityZone" + A2ARecoveryAvailabilityTypeSingle A2ARecoveryAvailabilityType = "Single" +) + +func PossibleValuesForA2ARecoveryAvailabilityType() []string { + return []string{ + string(A2ARecoveryAvailabilityTypeAvailabilitySet), + string(A2ARecoveryAvailabilityTypeAvailabilityZone), + string(A2ARecoveryAvailabilityTypeSingle), + } +} + +func (s *A2ARecoveryAvailabilityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseA2ARecoveryAvailabilityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseA2ARecoveryAvailabilityType(input string) (*A2ARecoveryAvailabilityType, error) { + vals := map[string]A2ARecoveryAvailabilityType{ + "availabilityset": A2ARecoveryAvailabilityTypeAvailabilitySet, + "availabilityzone": A2ARecoveryAvailabilityTypeAvailabilityZone, + "single": A2ARecoveryAvailabilityTypeSingle, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := A2ARecoveryAvailabilityType(input) + return &out, nil +} + +type AgentAutoUpdateStatus string + +const ( + AgentAutoUpdateStatusDisabled AgentAutoUpdateStatus = "Disabled" + AgentAutoUpdateStatusEnabled AgentAutoUpdateStatus = "Enabled" +) + +func PossibleValuesForAgentAutoUpdateStatus() []string { + return []string{ + string(AgentAutoUpdateStatusDisabled), + string(AgentAutoUpdateStatusEnabled), + } +} + +func (s *AgentAutoUpdateStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentAutoUpdateStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentAutoUpdateStatus(input string) (*AgentAutoUpdateStatus, error) { + vals := map[string]AgentAutoUpdateStatus{ + "disabled": AgentAutoUpdateStatusDisabled, + "enabled": AgentAutoUpdateStatusEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentAutoUpdateStatus(input) + return &out, nil +} + +type AutoProtectionOfDataDisk string + +const ( + AutoProtectionOfDataDiskDisabled AutoProtectionOfDataDisk = "Disabled" + AutoProtectionOfDataDiskEnabled AutoProtectionOfDataDisk = "Enabled" +) + +func PossibleValuesForAutoProtectionOfDataDisk() []string { + return []string{ + string(AutoProtectionOfDataDiskDisabled), + string(AutoProtectionOfDataDiskEnabled), + } +} + +func (s *AutoProtectionOfDataDisk) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoProtectionOfDataDisk(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoProtectionOfDataDisk(input string) (*AutoProtectionOfDataDisk, error) { + vals := map[string]AutoProtectionOfDataDisk{ + "disabled": AutoProtectionOfDataDiskDisabled, + "enabled": AutoProtectionOfDataDiskEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoProtectionOfDataDisk(input) + return &out, nil +} + +type AutomationAccountAuthenticationType string + +const ( + AutomationAccountAuthenticationTypeRunAsAccount AutomationAccountAuthenticationType = "RunAsAccount" + AutomationAccountAuthenticationTypeSystemAssignedIdentity AutomationAccountAuthenticationType = "SystemAssignedIdentity" +) + +func PossibleValuesForAutomationAccountAuthenticationType() []string { + return []string{ + string(AutomationAccountAuthenticationTypeRunAsAccount), + string(AutomationAccountAuthenticationTypeSystemAssignedIdentity), + } +} + +func (s *AutomationAccountAuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutomationAccountAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutomationAccountAuthenticationType(input string) (*AutomationAccountAuthenticationType, error) { + vals := map[string]AutomationAccountAuthenticationType{ + "runasaccount": AutomationAccountAuthenticationTypeRunAsAccount, + "systemassignedidentity": AutomationAccountAuthenticationTypeSystemAssignedIdentity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutomationAccountAuthenticationType(input) + return &out, nil +} + +type SetMultiVMSyncStatus string + +const ( + SetMultiVMSyncStatusDisable SetMultiVMSyncStatus = "Disable" + SetMultiVMSyncStatusEnable SetMultiVMSyncStatus = "Enable" +) + +func PossibleValuesForSetMultiVMSyncStatus() []string { + return []string{ + string(SetMultiVMSyncStatusDisable), + string(SetMultiVMSyncStatusEnable), + } +} + +func (s *SetMultiVMSyncStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSetMultiVMSyncStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSetMultiVMSyncStatus(input string) (*SetMultiVMSyncStatus, error) { + vals := map[string]SetMultiVMSyncStatus{ + "disable": SetMultiVMSyncStatusDisable, + "enable": SetMultiVMSyncStatusEnable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SetMultiVMSyncStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/id_replicationprotectionintent.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/id_replicationprotectionintent.go new file mode 100644 index 00000000000..78e9627f11f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/id_replicationprotectionintent.go @@ -0,0 +1,139 @@ +package replicationprotectionintents + +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(&ReplicationProtectionIntentId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectionIntentId{} + +// ReplicationProtectionIntentId is a struct representing the Resource ID for a Replication Protection Intent +type ReplicationProtectionIntentId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationProtectionIntentName string +} + +// NewReplicationProtectionIntentID returns a new ReplicationProtectionIntentId struct +func NewReplicationProtectionIntentID(subscriptionId string, resourceGroupName string, vaultName string, replicationProtectionIntentName string) ReplicationProtectionIntentId { + return ReplicationProtectionIntentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationProtectionIntentName: replicationProtectionIntentName, + } +} + +// ParseReplicationProtectionIntentID parses 'input' into a ReplicationProtectionIntentId +func ParseReplicationProtectionIntentID(input string) (*ReplicationProtectionIntentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionIntentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionIntentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionIntentIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionIntentId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionIntentIDInsensitively(input string) (*ReplicationProtectionIntentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionIntentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionIntentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionIntentId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationProtectionIntentName, ok = input.Parsed["replicationProtectionIntentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionIntentName", input) + } + + return nil +} + +// ValidateReplicationProtectionIntentID checks that 'input' can be parsed as a Replication Protection Intent ID +func ValidateReplicationProtectionIntentID(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 := ParseReplicationProtectionIntentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Intent ID +func (id ReplicationProtectionIntentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationProtectionIntents/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationProtectionIntentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Intent ID +func (id ReplicationProtectionIntentId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationProtectionIntents", "replicationProtectionIntents", "replicationProtectionIntents"), + resourceids.UserSpecifiedSegment("replicationProtectionIntentName", "replicationProtectionIntentName"), + } +} + +// String returns a human-readable description of this Replication Protection Intent ID +func (id ReplicationProtectionIntentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Protection Intent Name: %q", id.ReplicationProtectionIntentName), + } + return fmt.Sprintf("Replication Protection Intent (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/id_replicationprotectionintent_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/id_replicationprotectionintent_test.go new file mode 100644 index 00000000000..b3dedc733d4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/id_replicationprotectionintent_test.go @@ -0,0 +1,327 @@ +package replicationprotectionintents + +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 = &ReplicationProtectionIntentId{} + +func TestNewReplicationProtectionIntentID(t *testing.T) { + id := NewReplicationProtectionIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationProtectionIntentName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationProtectionIntentName != "replicationProtectionIntentName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionIntentName'", id.ReplicationProtectionIntentName, "replicationProtectionIntentName") + } +} + +func TestFormatReplicationProtectionIntentID(t *testing.T) { + actual := NewReplicationProtectionIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationProtectionIntentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationProtectionIntents/replicationProtectionIntentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionIntentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionIntentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationProtectionIntents", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationProtectionIntents/replicationProtectionIntentName", + Expected: &ReplicationProtectionIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationProtectionIntentName: "replicationProtectionIntentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationProtectionIntents/replicationProtectionIntentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionIntentID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationProtectionIntentName != v.Expected.ReplicationProtectionIntentName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionIntentName", v.Expected.ReplicationProtectionIntentName, actual.ReplicationProtectionIntentName) + } + + } +} + +func TestParseReplicationProtectionIntentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionIntentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationProtectionIntents", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnPrOtEcTiOnInTeNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationProtectionIntents/replicationProtectionIntentName", + Expected: &ReplicationProtectionIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationProtectionIntentName: "replicationProtectionIntentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationProtectionIntents/replicationProtectionIntentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnPrOtEcTiOnInTeNtS/rEpLiCaTiOnPrOtEcTiOnInTeNtNaMe", + Expected: &ReplicationProtectionIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationProtectionIntentName: "rEpLiCaTiOnPrOtEcTiOnInTeNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnPrOtEcTiOnInTeNtS/rEpLiCaTiOnPrOtEcTiOnInTeNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionIntentIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationProtectionIntentName != v.Expected.ReplicationProtectionIntentName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionIntentName", v.Expected.ReplicationProtectionIntentName, actual.ReplicationProtectionIntentName) + } + + } +} + +func TestSegmentsForReplicationProtectionIntentId(t *testing.T) { + segments := ReplicationProtectionIntentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionIntentId 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/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/id_vault.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/id_vault.go new file mode 100644 index 00000000000..4df44daf2b0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/id_vault.go @@ -0,0 +1,130 @@ +package replicationprotectionintents + +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(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(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 := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/id_vault_test.go new file mode 100644 index 00000000000..deb409a106d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationprotectionintents + +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 = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId 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/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/method_create.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/method_create.go new file mode 100644 index 00000000000..82af2c6bbb0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/method_create.go @@ -0,0 +1,57 @@ +package replicationprotectionintents + +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 CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectionIntent +} + +// Create ... +func (c ReplicationProtectionIntentsClient) Create(ctx context.Context, id ReplicationProtectionIntentId, input CreateProtectionIntentInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model ReplicationProtectionIntent + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/method_get.go new file mode 100644 index 00000000000..0352aeb3e5c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/method_get.go @@ -0,0 +1,53 @@ +package replicationprotectionintents + +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 *ReplicationProtectionIntent +} + +// Get ... +func (c ReplicationProtectionIntentsClient) Get(ctx context.Context, id ReplicationProtectionIntentId) (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 ReplicationProtectionIntent + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/method_list.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/method_list.go new file mode 100644 index 00000000000..6948c72b429 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/method_list.go @@ -0,0 +1,138 @@ +package replicationprotectionintents + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReplicationProtectionIntent +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ReplicationProtectionIntent +} + +type ListOperationOptions struct { + SkipToken *string + TakeToken *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.SkipToken != nil { + out.Append("skipToken", fmt.Sprintf("%v", *o.SkipToken)) + } + if o.TakeToken != nil { + out.Append("takeToken", fmt.Sprintf("%v", *o.TakeToken)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ReplicationProtectionIntentsClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/replicationProtectionIntents", 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 *[]ReplicationProtectionIntent `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationProtectionIntentsClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ReplicationProtectionIntentOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectionIntentsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate ReplicationProtectionIntentOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ReplicationProtectionIntent, 0) + + resp, err := c.List(ctx, id, options) + 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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_a2acreateprotectionintentinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_a2acreateprotectionintentinput.go new file mode 100644 index 00000000000..36cf09c2d97 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_a2acreateprotectionintentinput.go @@ -0,0 +1,171 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ CreateProtectionIntentProviderSpecificDetails = A2ACreateProtectionIntentInput{} + +type A2ACreateProtectionIntentInput struct { + AgentAutoUpdateStatus *AgentAutoUpdateStatus `json:"agentAutoUpdateStatus,omitempty"` + AutoProtectionOfDataDisk *AutoProtectionOfDataDisk `json:"autoProtectionOfDataDisk,omitempty"` + AutomationAccountArmId *string `json:"automationAccountArmId,omitempty"` + AutomationAccountAuthenticationType *AutomationAccountAuthenticationType `json:"automationAccountAuthenticationType,omitempty"` + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + FabricObjectId string `json:"fabricObjectId"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + PrimaryLocation string `json:"primaryLocation"` + PrimaryStagingStorageAccountCustomInput StorageAccountCustomDetails `json:"primaryStagingStorageAccountCustomInput"` + ProtectionProfileCustomInput ProtectionProfileCustomDetails `json:"protectionProfileCustomInput"` + RecoveryAvailabilitySetCustomInput RecoveryAvailabilitySetCustomDetails `json:"recoveryAvailabilitySetCustomInput"` + RecoveryAvailabilityType A2ARecoveryAvailabilityType `json:"recoveryAvailabilityType"` + RecoveryAvailabilityZone *string `json:"recoveryAvailabilityZone,omitempty"` + RecoveryBootDiagStorageAccount StorageAccountCustomDetails `json:"recoveryBootDiagStorageAccount"` + RecoveryLocation string `json:"recoveryLocation"` + RecoveryProximityPlacementGroupCustomInput RecoveryProximityPlacementGroupCustomDetails `json:"recoveryProximityPlacementGroupCustomInput"` + RecoveryResourceGroupId string `json:"recoveryResourceGroupId"` + RecoverySubscriptionId string `json:"recoverySubscriptionId"` + RecoveryVirtualNetworkCustomInput RecoveryVirtualNetworkCustomDetails `json:"recoveryVirtualNetworkCustomInput"` + VMDisks *[]A2AProtectionIntentDiskInputDetails `json:"vmDisks,omitempty"` + VMManagedDisks *[]A2AProtectionIntentManagedDiskInputDetails `json:"vmManagedDisks,omitempty"` + + // Fields inherited from CreateProtectionIntentProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s A2ACreateProtectionIntentInput) CreateProtectionIntentProviderSpecificDetails() BaseCreateProtectionIntentProviderSpecificDetailsImpl { + return BaseCreateProtectionIntentProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ACreateProtectionIntentInput{} + +func (s A2ACreateProtectionIntentInput) MarshalJSON() ([]byte, error) { + type wrapper A2ACreateProtectionIntentInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ACreateProtectionIntentInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ACreateProtectionIntentInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ACreateProtectionIntentInput: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &A2ACreateProtectionIntentInput{} + +func (s *A2ACreateProtectionIntentInput) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AgentAutoUpdateStatus *AgentAutoUpdateStatus `json:"agentAutoUpdateStatus,omitempty"` + AutoProtectionOfDataDisk *AutoProtectionOfDataDisk `json:"autoProtectionOfDataDisk,omitempty"` + AutomationAccountArmId *string `json:"automationAccountArmId,omitempty"` + AutomationAccountAuthenticationType *AutomationAccountAuthenticationType `json:"automationAccountAuthenticationType,omitempty"` + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + FabricObjectId string `json:"fabricObjectId"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + PrimaryLocation string `json:"primaryLocation"` + RecoveryAvailabilityType A2ARecoveryAvailabilityType `json:"recoveryAvailabilityType"` + RecoveryAvailabilityZone *string `json:"recoveryAvailabilityZone,omitempty"` + RecoveryLocation string `json:"recoveryLocation"` + RecoveryResourceGroupId string `json:"recoveryResourceGroupId"` + RecoverySubscriptionId string `json:"recoverySubscriptionId"` + VMDisks *[]A2AProtectionIntentDiskInputDetails `json:"vmDisks,omitempty"` + VMManagedDisks *[]A2AProtectionIntentManagedDiskInputDetails `json:"vmManagedDisks,omitempty"` + InstanceType string `json:"instanceType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AgentAutoUpdateStatus = decoded.AgentAutoUpdateStatus + s.AutoProtectionOfDataDisk = decoded.AutoProtectionOfDataDisk + s.AutomationAccountArmId = decoded.AutomationAccountArmId + s.AutomationAccountAuthenticationType = decoded.AutomationAccountAuthenticationType + s.DiskEncryptionInfo = decoded.DiskEncryptionInfo + s.FabricObjectId = decoded.FabricObjectId + s.MultiVMGroupId = decoded.MultiVMGroupId + s.MultiVMGroupName = decoded.MultiVMGroupName + s.PrimaryLocation = decoded.PrimaryLocation + s.RecoveryAvailabilityType = decoded.RecoveryAvailabilityType + s.RecoveryAvailabilityZone = decoded.RecoveryAvailabilityZone + s.RecoveryLocation = decoded.RecoveryLocation + s.RecoveryResourceGroupId = decoded.RecoveryResourceGroupId + s.RecoverySubscriptionId = decoded.RecoverySubscriptionId + s.VMDisks = decoded.VMDisks + s.VMManagedDisks = decoded.VMManagedDisks + s.InstanceType = decoded.InstanceType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling A2ACreateProtectionIntentInput into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["primaryStagingStorageAccountCustomInput"]; ok { + impl, err := UnmarshalStorageAccountCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'PrimaryStagingStorageAccountCustomInput' for 'A2ACreateProtectionIntentInput': %+v", err) + } + s.PrimaryStagingStorageAccountCustomInput = impl + } + + if v, ok := temp["protectionProfileCustomInput"]; ok { + impl, err := UnmarshalProtectionProfileCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProtectionProfileCustomInput' for 'A2ACreateProtectionIntentInput': %+v", err) + } + s.ProtectionProfileCustomInput = impl + } + + if v, ok := temp["recoveryAvailabilitySetCustomInput"]; ok { + impl, err := UnmarshalRecoveryAvailabilitySetCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryAvailabilitySetCustomInput' for 'A2ACreateProtectionIntentInput': %+v", err) + } + s.RecoveryAvailabilitySetCustomInput = impl + } + + if v, ok := temp["recoveryBootDiagStorageAccount"]; ok { + impl, err := UnmarshalStorageAccountCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryBootDiagStorageAccount' for 'A2ACreateProtectionIntentInput': %+v", err) + } + s.RecoveryBootDiagStorageAccount = impl + } + + if v, ok := temp["recoveryProximityPlacementGroupCustomInput"]; ok { + impl, err := UnmarshalRecoveryProximityPlacementGroupCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryProximityPlacementGroupCustomInput' for 'A2ACreateProtectionIntentInput': %+v", err) + } + s.RecoveryProximityPlacementGroupCustomInput = impl + } + + if v, ok := temp["recoveryVirtualNetworkCustomInput"]; ok { + impl, err := UnmarshalRecoveryVirtualNetworkCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryVirtualNetworkCustomInput' for 'A2ACreateProtectionIntentInput': %+v", err) + } + s.RecoveryVirtualNetworkCustomInput = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_a2aprotectionintentdiskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_a2aprotectionintentdiskinputdetails.go new file mode 100644 index 00000000000..6d8ccd708cd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_a2aprotectionintentdiskinputdetails.go @@ -0,0 +1,51 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AProtectionIntentDiskInputDetails struct { + DiskUri string `json:"diskUri"` + PrimaryStagingStorageAccountCustomInput StorageAccountCustomDetails `json:"primaryStagingStorageAccountCustomInput"` + RecoveryAzureStorageAccountCustomInput StorageAccountCustomDetails `json:"recoveryAzureStorageAccountCustomInput"` +} + +var _ json.Unmarshaler = &A2AProtectionIntentDiskInputDetails{} + +func (s *A2AProtectionIntentDiskInputDetails) UnmarshalJSON(bytes []byte) error { + var decoded struct { + DiskUri string `json:"diskUri"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.DiskUri = decoded.DiskUri + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling A2AProtectionIntentDiskInputDetails into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["primaryStagingStorageAccountCustomInput"]; ok { + impl, err := UnmarshalStorageAccountCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'PrimaryStagingStorageAccountCustomInput' for 'A2AProtectionIntentDiskInputDetails': %+v", err) + } + s.PrimaryStagingStorageAccountCustomInput = impl + } + + if v, ok := temp["recoveryAzureStorageAccountCustomInput"]; ok { + impl, err := UnmarshalStorageAccountCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryAzureStorageAccountCustomInput' for 'A2AProtectionIntentDiskInputDetails': %+v", err) + } + s.RecoveryAzureStorageAccountCustomInput = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_a2aprotectionintentmanageddiskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_a2aprotectionintentmanageddiskinputdetails.go new file mode 100644 index 00000000000..29dcc90679e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_a2aprotectionintentmanageddiskinputdetails.go @@ -0,0 +1,63 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AProtectionIntentManagedDiskInputDetails struct { + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + DiskId string `json:"diskId"` + PrimaryStagingStorageAccountCustomInput StorageAccountCustomDetails `json:"primaryStagingStorageAccountCustomInput"` + RecoveryDiskEncryptionSetId *string `json:"recoveryDiskEncryptionSetId,omitempty"` + RecoveryReplicaDiskAccountType *string `json:"recoveryReplicaDiskAccountType,omitempty"` + RecoveryResourceGroupCustomInput RecoveryResourceGroupCustomDetails `json:"recoveryResourceGroupCustomInput"` + RecoveryTargetDiskAccountType *string `json:"recoveryTargetDiskAccountType,omitempty"` +} + +var _ json.Unmarshaler = &A2AProtectionIntentManagedDiskInputDetails{} + +func (s *A2AProtectionIntentManagedDiskInputDetails) UnmarshalJSON(bytes []byte) error { + var decoded struct { + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + DiskId string `json:"diskId"` + RecoveryDiskEncryptionSetId *string `json:"recoveryDiskEncryptionSetId,omitempty"` + RecoveryReplicaDiskAccountType *string `json:"recoveryReplicaDiskAccountType,omitempty"` + RecoveryTargetDiskAccountType *string `json:"recoveryTargetDiskAccountType,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.DiskEncryptionInfo = decoded.DiskEncryptionInfo + s.DiskId = decoded.DiskId + s.RecoveryDiskEncryptionSetId = decoded.RecoveryDiskEncryptionSetId + s.RecoveryReplicaDiskAccountType = decoded.RecoveryReplicaDiskAccountType + s.RecoveryTargetDiskAccountType = decoded.RecoveryTargetDiskAccountType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling A2AProtectionIntentManagedDiskInputDetails into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["primaryStagingStorageAccountCustomInput"]; ok { + impl, err := UnmarshalStorageAccountCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'PrimaryStagingStorageAccountCustomInput' for 'A2AProtectionIntentManagedDiskInputDetails': %+v", err) + } + s.PrimaryStagingStorageAccountCustomInput = impl + } + + if v, ok := temp["recoveryResourceGroupCustomInput"]; ok { + impl, err := UnmarshalRecoveryResourceGroupCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryResourceGroupCustomInput' for 'A2AProtectionIntentManagedDiskInputDetails': %+v", err) + } + s.RecoveryResourceGroupCustomInput = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_a2areplicationintentdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_a2areplicationintentdetails.go new file mode 100644 index 00000000000..1285ba3a5c4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_a2areplicationintentdetails.go @@ -0,0 +1,171 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProtectionIntentProviderSpecificSettings = A2AReplicationIntentDetails{} + +type A2AReplicationIntentDetails struct { + AgentAutoUpdateStatus *AgentAutoUpdateStatus `json:"agentAutoUpdateStatus,omitempty"` + AutoProtectionOfDataDisk *AutoProtectionOfDataDisk `json:"autoProtectionOfDataDisk,omitempty"` + AutomationAccountArmId *string `json:"automationAccountArmId,omitempty"` + AutomationAccountAuthenticationType *AutomationAccountAuthenticationType `json:"automationAccountAuthenticationType,omitempty"` + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + PrimaryLocation *string `json:"primaryLocation,omitempty"` + PrimaryStagingStorageAccount StorageAccountCustomDetails `json:"primaryStagingStorageAccount"` + ProtectionProfile ProtectionProfileCustomDetails `json:"protectionProfile"` + RecoveryAvailabilitySet RecoveryAvailabilitySetCustomDetails `json:"recoveryAvailabilitySet"` + RecoveryAvailabilityType string `json:"recoveryAvailabilityType"` + RecoveryAvailabilityZone *string `json:"recoveryAvailabilityZone,omitempty"` + RecoveryBootDiagStorageAccount StorageAccountCustomDetails `json:"recoveryBootDiagStorageAccount"` + RecoveryLocation *string `json:"recoveryLocation,omitempty"` + RecoveryProximityPlacementGroup RecoveryProximityPlacementGroupCustomDetails `json:"recoveryProximityPlacementGroup"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + RecoverySubscriptionId *string `json:"recoverySubscriptionId,omitempty"` + RecoveryVirtualNetwork RecoveryVirtualNetworkCustomDetails `json:"recoveryVirtualNetwork"` + VMDisks *[]A2AProtectionIntentDiskInputDetails `json:"vmDisks,omitempty"` + VMManagedDisks *[]A2AProtectionIntentManagedDiskInputDetails `json:"vmManagedDisks,omitempty"` + + // Fields inherited from ReplicationProtectionIntentProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s A2AReplicationIntentDetails) ReplicationProtectionIntentProviderSpecificSettings() BaseReplicationProtectionIntentProviderSpecificSettingsImpl { + return BaseReplicationProtectionIntentProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AReplicationIntentDetails{} + +func (s A2AReplicationIntentDetails) MarshalJSON() ([]byte, error) { + type wrapper A2AReplicationIntentDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AReplicationIntentDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AReplicationIntentDetails: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AReplicationIntentDetails: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &A2AReplicationIntentDetails{} + +func (s *A2AReplicationIntentDetails) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AgentAutoUpdateStatus *AgentAutoUpdateStatus `json:"agentAutoUpdateStatus,omitempty"` + AutoProtectionOfDataDisk *AutoProtectionOfDataDisk `json:"autoProtectionOfDataDisk,omitempty"` + AutomationAccountArmId *string `json:"automationAccountArmId,omitempty"` + AutomationAccountAuthenticationType *AutomationAccountAuthenticationType `json:"automationAccountAuthenticationType,omitempty"` + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + PrimaryLocation *string `json:"primaryLocation,omitempty"` + RecoveryAvailabilityType string `json:"recoveryAvailabilityType"` + RecoveryAvailabilityZone *string `json:"recoveryAvailabilityZone,omitempty"` + RecoveryLocation *string `json:"recoveryLocation,omitempty"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + RecoverySubscriptionId *string `json:"recoverySubscriptionId,omitempty"` + VMDisks *[]A2AProtectionIntentDiskInputDetails `json:"vmDisks,omitempty"` + VMManagedDisks *[]A2AProtectionIntentManagedDiskInputDetails `json:"vmManagedDisks,omitempty"` + InstanceType string `json:"instanceType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AgentAutoUpdateStatus = decoded.AgentAutoUpdateStatus + s.AutoProtectionOfDataDisk = decoded.AutoProtectionOfDataDisk + s.AutomationAccountArmId = decoded.AutomationAccountArmId + s.AutomationAccountAuthenticationType = decoded.AutomationAccountAuthenticationType + s.DiskEncryptionInfo = decoded.DiskEncryptionInfo + s.FabricObjectId = decoded.FabricObjectId + s.MultiVMGroupId = decoded.MultiVMGroupId + s.MultiVMGroupName = decoded.MultiVMGroupName + s.PrimaryLocation = decoded.PrimaryLocation + s.RecoveryAvailabilityType = decoded.RecoveryAvailabilityType + s.RecoveryAvailabilityZone = decoded.RecoveryAvailabilityZone + s.RecoveryLocation = decoded.RecoveryLocation + s.RecoveryResourceGroupId = decoded.RecoveryResourceGroupId + s.RecoverySubscriptionId = decoded.RecoverySubscriptionId + s.VMDisks = decoded.VMDisks + s.VMManagedDisks = decoded.VMManagedDisks + s.InstanceType = decoded.InstanceType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling A2AReplicationIntentDetails into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["primaryStagingStorageAccount"]; ok { + impl, err := UnmarshalStorageAccountCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'PrimaryStagingStorageAccount' for 'A2AReplicationIntentDetails': %+v", err) + } + s.PrimaryStagingStorageAccount = impl + } + + if v, ok := temp["protectionProfile"]; ok { + impl, err := UnmarshalProtectionProfileCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProtectionProfile' for 'A2AReplicationIntentDetails': %+v", err) + } + s.ProtectionProfile = impl + } + + if v, ok := temp["recoveryAvailabilitySet"]; ok { + impl, err := UnmarshalRecoveryAvailabilitySetCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryAvailabilitySet' for 'A2AReplicationIntentDetails': %+v", err) + } + s.RecoveryAvailabilitySet = impl + } + + if v, ok := temp["recoveryBootDiagStorageAccount"]; ok { + impl, err := UnmarshalStorageAccountCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryBootDiagStorageAccount' for 'A2AReplicationIntentDetails': %+v", err) + } + s.RecoveryBootDiagStorageAccount = impl + } + + if v, ok := temp["recoveryProximityPlacementGroup"]; ok { + impl, err := UnmarshalRecoveryProximityPlacementGroupCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryProximityPlacementGroup' for 'A2AReplicationIntentDetails': %+v", err) + } + s.RecoveryProximityPlacementGroup = impl + } + + if v, ok := temp["recoveryVirtualNetwork"]; ok { + impl, err := UnmarshalRecoveryVirtualNetworkCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryVirtualNetwork' for 'A2AReplicationIntentDetails': %+v", err) + } + s.RecoveryVirtualNetwork = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_createprotectionintentinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_createprotectionintentinput.go new file mode 100644 index 00000000000..043880b900a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_createprotectionintentinput.go @@ -0,0 +1,8 @@ +package replicationprotectionintents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateProtectionIntentInput struct { + Properties *CreateProtectionIntentProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_createprotectionintentproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_createprotectionintentproperties.go new file mode 100644 index 00000000000..cf70e55deb4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_createprotectionintentproperties.go @@ -0,0 +1,33 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateProtectionIntentProperties struct { + ProviderSpecificDetails CreateProtectionIntentProviderSpecificDetails `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &CreateProtectionIntentProperties{} + +func (s *CreateProtectionIntentProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CreateProtectionIntentProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalCreateProtectionIntentProviderSpecificDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'CreateProtectionIntentProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_createprotectionintentproviderspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_createprotectionintentproviderspecificdetails.go new file mode 100644 index 00000000000..ab7fd077002 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_createprotectionintentproviderspecificdetails.go @@ -0,0 +1,75 @@ +package replicationprotectionintents + +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 CreateProtectionIntentProviderSpecificDetails interface { + CreateProtectionIntentProviderSpecificDetails() BaseCreateProtectionIntentProviderSpecificDetailsImpl +} + +var _ CreateProtectionIntentProviderSpecificDetails = BaseCreateProtectionIntentProviderSpecificDetailsImpl{} + +type BaseCreateProtectionIntentProviderSpecificDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseCreateProtectionIntentProviderSpecificDetailsImpl) CreateProtectionIntentProviderSpecificDetails() BaseCreateProtectionIntentProviderSpecificDetailsImpl { + return s +} + +var _ CreateProtectionIntentProviderSpecificDetails = RawCreateProtectionIntentProviderSpecificDetailsImpl{} + +// RawCreateProtectionIntentProviderSpecificDetailsImpl 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 RawCreateProtectionIntentProviderSpecificDetailsImpl struct { + createProtectionIntentProviderSpecificDetails BaseCreateProtectionIntentProviderSpecificDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawCreateProtectionIntentProviderSpecificDetailsImpl) CreateProtectionIntentProviderSpecificDetails() BaseCreateProtectionIntentProviderSpecificDetailsImpl { + return s.createProtectionIntentProviderSpecificDetails +} + +func UnmarshalCreateProtectionIntentProviderSpecificDetailsImplementation(input []byte) (CreateProtectionIntentProviderSpecificDetails, 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 CreateProtectionIntentProviderSpecificDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2ACreateProtectionIntentInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ACreateProtectionIntentInput: %+v", err) + } + return out, nil + } + + var parent BaseCreateProtectionIntentProviderSpecificDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseCreateProtectionIntentProviderSpecificDetailsImpl: %+v", err) + } + + return RawCreateProtectionIntentProviderSpecificDetailsImpl{ + createProtectionIntentProviderSpecificDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_diskencryptioninfo.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_diskencryptioninfo.go new file mode 100644 index 00000000000..bbe499d7f6b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_diskencryptioninfo.go @@ -0,0 +1,9 @@ +package replicationprotectionintents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskEncryptionInfo struct { + DiskEncryptionKeyInfo *DiskEncryptionKeyInfo `json:"diskEncryptionKeyInfo,omitempty"` + KeyEncryptionKeyInfo *KeyEncryptionKeyInfo `json:"keyEncryptionKeyInfo,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_diskencryptionkeyinfo.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_diskencryptionkeyinfo.go new file mode 100644 index 00000000000..1043673141e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_diskencryptionkeyinfo.go @@ -0,0 +1,9 @@ +package replicationprotectionintents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskEncryptionKeyInfo struct { + KeyVaultResourceArmId *string `json:"keyVaultResourceArmId,omitempty"` + SecretIdentifier *string `json:"secretIdentifier,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_existingprotectionprofile.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_existingprotectionprofile.go new file mode 100644 index 00000000000..0b216ef5a81 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_existingprotectionprofile.go @@ -0,0 +1,50 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionProfileCustomDetails = ExistingProtectionProfile{} + +type ExistingProtectionProfile struct { + ProtectionProfileId string `json:"protectionProfileId"` + + // Fields inherited from ProtectionProfileCustomDetails + + ResourceType string `json:"resourceType"` +} + +func (s ExistingProtectionProfile) ProtectionProfileCustomDetails() BaseProtectionProfileCustomDetailsImpl { + return BaseProtectionProfileCustomDetailsImpl{ + ResourceType: s.ResourceType, + } +} + +var _ json.Marshaler = ExistingProtectionProfile{} + +func (s ExistingProtectionProfile) MarshalJSON() ([]byte, error) { + type wrapper ExistingProtectionProfile + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ExistingProtectionProfile: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ExistingProtectionProfile: %+v", err) + } + + decoded["resourceType"] = "Existing" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ExistingProtectionProfile: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_existingrecoveryavailabilityset.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_existingrecoveryavailabilityset.go new file mode 100644 index 00000000000..843ef1f8cb7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_existingrecoveryavailabilityset.go @@ -0,0 +1,50 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryAvailabilitySetCustomDetails = ExistingRecoveryAvailabilitySet{} + +type ExistingRecoveryAvailabilitySet struct { + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + + // Fields inherited from RecoveryAvailabilitySetCustomDetails + + ResourceType string `json:"resourceType"` +} + +func (s ExistingRecoveryAvailabilitySet) RecoveryAvailabilitySetCustomDetails() BaseRecoveryAvailabilitySetCustomDetailsImpl { + return BaseRecoveryAvailabilitySetCustomDetailsImpl{ + ResourceType: s.ResourceType, + } +} + +var _ json.Marshaler = ExistingRecoveryAvailabilitySet{} + +func (s ExistingRecoveryAvailabilitySet) MarshalJSON() ([]byte, error) { + type wrapper ExistingRecoveryAvailabilitySet + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ExistingRecoveryAvailabilitySet: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ExistingRecoveryAvailabilitySet: %+v", err) + } + + decoded["resourceType"] = "Existing" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ExistingRecoveryAvailabilitySet: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_existingrecoveryproximityplacementgroup.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_existingrecoveryproximityplacementgroup.go new file mode 100644 index 00000000000..9ce68dbc0c1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_existingrecoveryproximityplacementgroup.go @@ -0,0 +1,50 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryProximityPlacementGroupCustomDetails = ExistingRecoveryProximityPlacementGroup{} + +type ExistingRecoveryProximityPlacementGroup struct { + RecoveryProximityPlacementGroupId *string `json:"recoveryProximityPlacementGroupId,omitempty"` + + // Fields inherited from RecoveryProximityPlacementGroupCustomDetails + + ResourceType string `json:"resourceType"` +} + +func (s ExistingRecoveryProximityPlacementGroup) RecoveryProximityPlacementGroupCustomDetails() BaseRecoveryProximityPlacementGroupCustomDetailsImpl { + return BaseRecoveryProximityPlacementGroupCustomDetailsImpl{ + ResourceType: s.ResourceType, + } +} + +var _ json.Marshaler = ExistingRecoveryProximityPlacementGroup{} + +func (s ExistingRecoveryProximityPlacementGroup) MarshalJSON() ([]byte, error) { + type wrapper ExistingRecoveryProximityPlacementGroup + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ExistingRecoveryProximityPlacementGroup: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ExistingRecoveryProximityPlacementGroup: %+v", err) + } + + decoded["resourceType"] = "Existing" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ExistingRecoveryProximityPlacementGroup: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_existingrecoveryrecoveryresourcegroup.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_existingrecoveryrecoveryresourcegroup.go new file mode 100644 index 00000000000..aaeb02cfaf5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_existingrecoveryrecoveryresourcegroup.go @@ -0,0 +1,50 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryResourceGroupCustomDetails = ExistingRecoveryRecoveryResourceGroup{} + +type ExistingRecoveryRecoveryResourceGroup struct { + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + + // Fields inherited from RecoveryResourceGroupCustomDetails + + ResourceType string `json:"resourceType"` +} + +func (s ExistingRecoveryRecoveryResourceGroup) RecoveryResourceGroupCustomDetails() BaseRecoveryResourceGroupCustomDetailsImpl { + return BaseRecoveryResourceGroupCustomDetailsImpl{ + ResourceType: s.ResourceType, + } +} + +var _ json.Marshaler = ExistingRecoveryRecoveryResourceGroup{} + +func (s ExistingRecoveryRecoveryResourceGroup) MarshalJSON() ([]byte, error) { + type wrapper ExistingRecoveryRecoveryResourceGroup + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ExistingRecoveryRecoveryResourceGroup: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ExistingRecoveryRecoveryResourceGroup: %+v", err) + } + + decoded["resourceType"] = "Existing" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ExistingRecoveryRecoveryResourceGroup: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_existingrecoveryvirtualnetwork.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_existingrecoveryvirtualnetwork.go new file mode 100644 index 00000000000..d423cd45704 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_existingrecoveryvirtualnetwork.go @@ -0,0 +1,51 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryVirtualNetworkCustomDetails = ExistingRecoveryVirtualNetwork{} + +type ExistingRecoveryVirtualNetwork struct { + RecoverySubnetName *string `json:"recoverySubnetName,omitempty"` + RecoveryVirtualNetworkId string `json:"recoveryVirtualNetworkId"` + + // Fields inherited from RecoveryVirtualNetworkCustomDetails + + ResourceType string `json:"resourceType"` +} + +func (s ExistingRecoveryVirtualNetwork) RecoveryVirtualNetworkCustomDetails() BaseRecoveryVirtualNetworkCustomDetailsImpl { + return BaseRecoveryVirtualNetworkCustomDetailsImpl{ + ResourceType: s.ResourceType, + } +} + +var _ json.Marshaler = ExistingRecoveryVirtualNetwork{} + +func (s ExistingRecoveryVirtualNetwork) MarshalJSON() ([]byte, error) { + type wrapper ExistingRecoveryVirtualNetwork + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ExistingRecoveryVirtualNetwork: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ExistingRecoveryVirtualNetwork: %+v", err) + } + + decoded["resourceType"] = "Existing" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ExistingRecoveryVirtualNetwork: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_existingstorageaccount.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_existingstorageaccount.go new file mode 100644 index 00000000000..aff65dcc0b5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_existingstorageaccount.go @@ -0,0 +1,50 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ StorageAccountCustomDetails = ExistingStorageAccount{} + +type ExistingStorageAccount struct { + AzureStorageAccountId string `json:"azureStorageAccountId"` + + // Fields inherited from StorageAccountCustomDetails + + ResourceType string `json:"resourceType"` +} + +func (s ExistingStorageAccount) StorageAccountCustomDetails() BaseStorageAccountCustomDetailsImpl { + return BaseStorageAccountCustomDetailsImpl{ + ResourceType: s.ResourceType, + } +} + +var _ json.Marshaler = ExistingStorageAccount{} + +func (s ExistingStorageAccount) MarshalJSON() ([]byte, error) { + type wrapper ExistingStorageAccount + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ExistingStorageAccount: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ExistingStorageAccount: %+v", err) + } + + decoded["resourceType"] = "Existing" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ExistingStorageAccount: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_keyencryptionkeyinfo.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_keyencryptionkeyinfo.go new file mode 100644 index 00000000000..b4a8b6e0c54 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_keyencryptionkeyinfo.go @@ -0,0 +1,9 @@ +package replicationprotectionintents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyEncryptionKeyInfo struct { + KeyIdentifier *string `json:"keyIdentifier,omitempty"` + KeyVaultResourceArmId *string `json:"keyVaultResourceArmId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_newprotectionprofile.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_newprotectionprofile.go new file mode 100644 index 00000000000..024c9f7c66e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_newprotectionprofile.go @@ -0,0 +1,54 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionProfileCustomDetails = NewProtectionProfile{} + +type NewProtectionProfile struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus SetMultiVMSyncStatus `json:"multiVmSyncStatus"` + PolicyName string `json:"policyName"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + + // Fields inherited from ProtectionProfileCustomDetails + + ResourceType string `json:"resourceType"` +} + +func (s NewProtectionProfile) ProtectionProfileCustomDetails() BaseProtectionProfileCustomDetailsImpl { + return BaseProtectionProfileCustomDetailsImpl{ + ResourceType: s.ResourceType, + } +} + +var _ json.Marshaler = NewProtectionProfile{} + +func (s NewProtectionProfile) MarshalJSON() ([]byte, error) { + type wrapper NewProtectionProfile + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling NewProtectionProfile: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling NewProtectionProfile: %+v", err) + } + + decoded["resourceType"] = "New" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling NewProtectionProfile: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_newrecoveryvirtualnetwork.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_newrecoveryvirtualnetwork.go new file mode 100644 index 00000000000..4b1609e51d9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_newrecoveryvirtualnetwork.go @@ -0,0 +1,51 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryVirtualNetworkCustomDetails = NewRecoveryVirtualNetwork{} + +type NewRecoveryVirtualNetwork struct { + RecoveryVirtualNetworkName *string `json:"recoveryVirtualNetworkName,omitempty"` + RecoveryVirtualNetworkResourceGroupName *string `json:"recoveryVirtualNetworkResourceGroupName,omitempty"` + + // Fields inherited from RecoveryVirtualNetworkCustomDetails + + ResourceType string `json:"resourceType"` +} + +func (s NewRecoveryVirtualNetwork) RecoveryVirtualNetworkCustomDetails() BaseRecoveryVirtualNetworkCustomDetailsImpl { + return BaseRecoveryVirtualNetworkCustomDetailsImpl{ + ResourceType: s.ResourceType, + } +} + +var _ json.Marshaler = NewRecoveryVirtualNetwork{} + +func (s NewRecoveryVirtualNetwork) MarshalJSON() ([]byte, error) { + type wrapper NewRecoveryVirtualNetwork + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling NewRecoveryVirtualNetwork: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling NewRecoveryVirtualNetwork: %+v", err) + } + + decoded["resourceType"] = "New" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling NewRecoveryVirtualNetwork: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_protectionprofilecustomdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_protectionprofilecustomdetails.go new file mode 100644 index 00000000000..cfd62e1171e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_protectionprofilecustomdetails.go @@ -0,0 +1,83 @@ +package replicationprotectionintents + +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 ProtectionProfileCustomDetails interface { + ProtectionProfileCustomDetails() BaseProtectionProfileCustomDetailsImpl +} + +var _ ProtectionProfileCustomDetails = BaseProtectionProfileCustomDetailsImpl{} + +type BaseProtectionProfileCustomDetailsImpl struct { + ResourceType string `json:"resourceType"` +} + +func (s BaseProtectionProfileCustomDetailsImpl) ProtectionProfileCustomDetails() BaseProtectionProfileCustomDetailsImpl { + return s +} + +var _ ProtectionProfileCustomDetails = RawProtectionProfileCustomDetailsImpl{} + +// RawProtectionProfileCustomDetailsImpl 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 RawProtectionProfileCustomDetailsImpl struct { + protectionProfileCustomDetails BaseProtectionProfileCustomDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawProtectionProfileCustomDetailsImpl) ProtectionProfileCustomDetails() BaseProtectionProfileCustomDetailsImpl { + return s.protectionProfileCustomDetails +} + +func UnmarshalProtectionProfileCustomDetailsImplementation(input []byte) (ProtectionProfileCustomDetails, 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 ProtectionProfileCustomDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["resourceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Existing") { + var out ExistingProtectionProfile + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ExistingProtectionProfile: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "New") { + var out NewProtectionProfile + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into NewProtectionProfile: %+v", err) + } + return out, nil + } + + var parent BaseProtectionProfileCustomDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseProtectionProfileCustomDetailsImpl: %+v", err) + } + + return RawProtectionProfileCustomDetailsImpl{ + protectionProfileCustomDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_recoveryavailabilitysetcustomdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_recoveryavailabilitysetcustomdetails.go new file mode 100644 index 00000000000..a5be859681d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_recoveryavailabilitysetcustomdetails.go @@ -0,0 +1,75 @@ +package replicationprotectionintents + +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 RecoveryAvailabilitySetCustomDetails interface { + RecoveryAvailabilitySetCustomDetails() BaseRecoveryAvailabilitySetCustomDetailsImpl +} + +var _ RecoveryAvailabilitySetCustomDetails = BaseRecoveryAvailabilitySetCustomDetailsImpl{} + +type BaseRecoveryAvailabilitySetCustomDetailsImpl struct { + ResourceType string `json:"resourceType"` +} + +func (s BaseRecoveryAvailabilitySetCustomDetailsImpl) RecoveryAvailabilitySetCustomDetails() BaseRecoveryAvailabilitySetCustomDetailsImpl { + return s +} + +var _ RecoveryAvailabilitySetCustomDetails = RawRecoveryAvailabilitySetCustomDetailsImpl{} + +// RawRecoveryAvailabilitySetCustomDetailsImpl 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 RawRecoveryAvailabilitySetCustomDetailsImpl struct { + recoveryAvailabilitySetCustomDetails BaseRecoveryAvailabilitySetCustomDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawRecoveryAvailabilitySetCustomDetailsImpl) RecoveryAvailabilitySetCustomDetails() BaseRecoveryAvailabilitySetCustomDetailsImpl { + return s.recoveryAvailabilitySetCustomDetails +} + +func UnmarshalRecoveryAvailabilitySetCustomDetailsImplementation(input []byte) (RecoveryAvailabilitySetCustomDetails, 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 RecoveryAvailabilitySetCustomDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["resourceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Existing") { + var out ExistingRecoveryAvailabilitySet + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ExistingRecoveryAvailabilitySet: %+v", err) + } + return out, nil + } + + var parent BaseRecoveryAvailabilitySetCustomDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRecoveryAvailabilitySetCustomDetailsImpl: %+v", err) + } + + return RawRecoveryAvailabilitySetCustomDetailsImpl{ + recoveryAvailabilitySetCustomDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_recoveryproximityplacementgroupcustomdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_recoveryproximityplacementgroupcustomdetails.go new file mode 100644 index 00000000000..cd88e1a7a13 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_recoveryproximityplacementgroupcustomdetails.go @@ -0,0 +1,75 @@ +package replicationprotectionintents + +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 RecoveryProximityPlacementGroupCustomDetails interface { + RecoveryProximityPlacementGroupCustomDetails() BaseRecoveryProximityPlacementGroupCustomDetailsImpl +} + +var _ RecoveryProximityPlacementGroupCustomDetails = BaseRecoveryProximityPlacementGroupCustomDetailsImpl{} + +type BaseRecoveryProximityPlacementGroupCustomDetailsImpl struct { + ResourceType string `json:"resourceType"` +} + +func (s BaseRecoveryProximityPlacementGroupCustomDetailsImpl) RecoveryProximityPlacementGroupCustomDetails() BaseRecoveryProximityPlacementGroupCustomDetailsImpl { + return s +} + +var _ RecoveryProximityPlacementGroupCustomDetails = RawRecoveryProximityPlacementGroupCustomDetailsImpl{} + +// RawRecoveryProximityPlacementGroupCustomDetailsImpl 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 RawRecoveryProximityPlacementGroupCustomDetailsImpl struct { + recoveryProximityPlacementGroupCustomDetails BaseRecoveryProximityPlacementGroupCustomDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawRecoveryProximityPlacementGroupCustomDetailsImpl) RecoveryProximityPlacementGroupCustomDetails() BaseRecoveryProximityPlacementGroupCustomDetailsImpl { + return s.recoveryProximityPlacementGroupCustomDetails +} + +func UnmarshalRecoveryProximityPlacementGroupCustomDetailsImplementation(input []byte) (RecoveryProximityPlacementGroupCustomDetails, 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 RecoveryProximityPlacementGroupCustomDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["resourceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Existing") { + var out ExistingRecoveryProximityPlacementGroup + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ExistingRecoveryProximityPlacementGroup: %+v", err) + } + return out, nil + } + + var parent BaseRecoveryProximityPlacementGroupCustomDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRecoveryProximityPlacementGroupCustomDetailsImpl: %+v", err) + } + + return RawRecoveryProximityPlacementGroupCustomDetailsImpl{ + recoveryProximityPlacementGroupCustomDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_recoveryresourcegroupcustomdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_recoveryresourcegroupcustomdetails.go new file mode 100644 index 00000000000..784f54bebcf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_recoveryresourcegroupcustomdetails.go @@ -0,0 +1,75 @@ +package replicationprotectionintents + +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 RecoveryResourceGroupCustomDetails interface { + RecoveryResourceGroupCustomDetails() BaseRecoveryResourceGroupCustomDetailsImpl +} + +var _ RecoveryResourceGroupCustomDetails = BaseRecoveryResourceGroupCustomDetailsImpl{} + +type BaseRecoveryResourceGroupCustomDetailsImpl struct { + ResourceType string `json:"resourceType"` +} + +func (s BaseRecoveryResourceGroupCustomDetailsImpl) RecoveryResourceGroupCustomDetails() BaseRecoveryResourceGroupCustomDetailsImpl { + return s +} + +var _ RecoveryResourceGroupCustomDetails = RawRecoveryResourceGroupCustomDetailsImpl{} + +// RawRecoveryResourceGroupCustomDetailsImpl 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 RawRecoveryResourceGroupCustomDetailsImpl struct { + recoveryResourceGroupCustomDetails BaseRecoveryResourceGroupCustomDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawRecoveryResourceGroupCustomDetailsImpl) RecoveryResourceGroupCustomDetails() BaseRecoveryResourceGroupCustomDetailsImpl { + return s.recoveryResourceGroupCustomDetails +} + +func UnmarshalRecoveryResourceGroupCustomDetailsImplementation(input []byte) (RecoveryResourceGroupCustomDetails, 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 RecoveryResourceGroupCustomDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["resourceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Existing") { + var out ExistingRecoveryRecoveryResourceGroup + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ExistingRecoveryRecoveryResourceGroup: %+v", err) + } + return out, nil + } + + var parent BaseRecoveryResourceGroupCustomDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRecoveryResourceGroupCustomDetailsImpl: %+v", err) + } + + return RawRecoveryResourceGroupCustomDetailsImpl{ + recoveryResourceGroupCustomDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_recoveryvirtualnetworkcustomdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_recoveryvirtualnetworkcustomdetails.go new file mode 100644 index 00000000000..848cbc8806b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_recoveryvirtualnetworkcustomdetails.go @@ -0,0 +1,83 @@ +package replicationprotectionintents + +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 RecoveryVirtualNetworkCustomDetails interface { + RecoveryVirtualNetworkCustomDetails() BaseRecoveryVirtualNetworkCustomDetailsImpl +} + +var _ RecoveryVirtualNetworkCustomDetails = BaseRecoveryVirtualNetworkCustomDetailsImpl{} + +type BaseRecoveryVirtualNetworkCustomDetailsImpl struct { + ResourceType string `json:"resourceType"` +} + +func (s BaseRecoveryVirtualNetworkCustomDetailsImpl) RecoveryVirtualNetworkCustomDetails() BaseRecoveryVirtualNetworkCustomDetailsImpl { + return s +} + +var _ RecoveryVirtualNetworkCustomDetails = RawRecoveryVirtualNetworkCustomDetailsImpl{} + +// RawRecoveryVirtualNetworkCustomDetailsImpl 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 RawRecoveryVirtualNetworkCustomDetailsImpl struct { + recoveryVirtualNetworkCustomDetails BaseRecoveryVirtualNetworkCustomDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawRecoveryVirtualNetworkCustomDetailsImpl) RecoveryVirtualNetworkCustomDetails() BaseRecoveryVirtualNetworkCustomDetailsImpl { + return s.recoveryVirtualNetworkCustomDetails +} + +func UnmarshalRecoveryVirtualNetworkCustomDetailsImplementation(input []byte) (RecoveryVirtualNetworkCustomDetails, 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 RecoveryVirtualNetworkCustomDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["resourceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Existing") { + var out ExistingRecoveryVirtualNetwork + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ExistingRecoveryVirtualNetwork: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "New") { + var out NewRecoveryVirtualNetwork + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into NewRecoveryVirtualNetwork: %+v", err) + } + return out, nil + } + + var parent BaseRecoveryVirtualNetworkCustomDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRecoveryVirtualNetworkCustomDetailsImpl: %+v", err) + } + + return RawRecoveryVirtualNetworkCustomDetailsImpl{ + recoveryVirtualNetworkCustomDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_replicationprotectionintent.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_replicationprotectionintent.go new file mode 100644 index 00000000000..1fbffaaf5ab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_replicationprotectionintent.go @@ -0,0 +1,12 @@ +package replicationprotectionintents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProtectionIntent struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ReplicationProtectionIntentProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_replicationprotectionintentproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_replicationprotectionintentproperties.go new file mode 100644 index 00000000000..fcae31616b9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_replicationprotectionintentproperties.go @@ -0,0 +1,54 @@ +package replicationprotectionintents + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProtectionIntentProperties struct { + CreationTimeUTC *string `json:"creationTimeUTC,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + IsActive *bool `json:"isActive,omitempty"` + JobId *string `json:"jobId,omitempty"` + JobState *string `json:"jobState,omitempty"` + ProviderSpecificDetails ReplicationProtectionIntentProviderSpecificSettings `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &ReplicationProtectionIntentProperties{} + +func (s *ReplicationProtectionIntentProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + CreationTimeUTC *string `json:"creationTimeUTC,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + IsActive *bool `json:"isActive,omitempty"` + JobId *string `json:"jobId,omitempty"` + JobState *string `json:"jobState,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.CreationTimeUTC = decoded.CreationTimeUTC + s.FriendlyName = decoded.FriendlyName + s.IsActive = decoded.IsActive + s.JobId = decoded.JobId + s.JobState = decoded.JobState + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ReplicationProtectionIntentProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalReplicationProtectionIntentProviderSpecificSettingsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ReplicationProtectionIntentProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_replicationprotectionintentproviderspecificsettings.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_replicationprotectionintentproviderspecificsettings.go new file mode 100644 index 00000000000..ca02cd47751 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_replicationprotectionintentproviderspecificsettings.go @@ -0,0 +1,75 @@ +package replicationprotectionintents + +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 ReplicationProtectionIntentProviderSpecificSettings interface { + ReplicationProtectionIntentProviderSpecificSettings() BaseReplicationProtectionIntentProviderSpecificSettingsImpl +} + +var _ ReplicationProtectionIntentProviderSpecificSettings = BaseReplicationProtectionIntentProviderSpecificSettingsImpl{} + +type BaseReplicationProtectionIntentProviderSpecificSettingsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseReplicationProtectionIntentProviderSpecificSettingsImpl) ReplicationProtectionIntentProviderSpecificSettings() BaseReplicationProtectionIntentProviderSpecificSettingsImpl { + return s +} + +var _ ReplicationProtectionIntentProviderSpecificSettings = RawReplicationProtectionIntentProviderSpecificSettingsImpl{} + +// RawReplicationProtectionIntentProviderSpecificSettingsImpl 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 RawReplicationProtectionIntentProviderSpecificSettingsImpl struct { + replicationProtectionIntentProviderSpecificSettings BaseReplicationProtectionIntentProviderSpecificSettingsImpl + Type string + Values map[string]interface{} +} + +func (s RawReplicationProtectionIntentProviderSpecificSettingsImpl) ReplicationProtectionIntentProviderSpecificSettings() BaseReplicationProtectionIntentProviderSpecificSettingsImpl { + return s.replicationProtectionIntentProviderSpecificSettings +} + +func UnmarshalReplicationProtectionIntentProviderSpecificSettingsImplementation(input []byte) (ReplicationProtectionIntentProviderSpecificSettings, 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 ReplicationProtectionIntentProviderSpecificSettings into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AReplicationIntentDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AReplicationIntentDetails: %+v", err) + } + return out, nil + } + + var parent BaseReplicationProtectionIntentProviderSpecificSettingsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseReplicationProtectionIntentProviderSpecificSettingsImpl: %+v", err) + } + + return RawReplicationProtectionIntentProviderSpecificSettingsImpl{ + replicationProtectionIntentProviderSpecificSettings: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_storageaccountcustomdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_storageaccountcustomdetails.go new file mode 100644 index 00000000000..ca85a56b9f4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/model_storageaccountcustomdetails.go @@ -0,0 +1,75 @@ +package replicationprotectionintents + +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 StorageAccountCustomDetails interface { + StorageAccountCustomDetails() BaseStorageAccountCustomDetailsImpl +} + +var _ StorageAccountCustomDetails = BaseStorageAccountCustomDetailsImpl{} + +type BaseStorageAccountCustomDetailsImpl struct { + ResourceType string `json:"resourceType"` +} + +func (s BaseStorageAccountCustomDetailsImpl) StorageAccountCustomDetails() BaseStorageAccountCustomDetailsImpl { + return s +} + +var _ StorageAccountCustomDetails = RawStorageAccountCustomDetailsImpl{} + +// RawStorageAccountCustomDetailsImpl 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 RawStorageAccountCustomDetailsImpl struct { + storageAccountCustomDetails BaseStorageAccountCustomDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawStorageAccountCustomDetailsImpl) StorageAccountCustomDetails() BaseStorageAccountCustomDetailsImpl { + return s.storageAccountCustomDetails +} + +func UnmarshalStorageAccountCustomDetailsImplementation(input []byte) (StorageAccountCustomDetails, 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 StorageAccountCustomDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["resourceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Existing") { + var out ExistingStorageAccount + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ExistingStorageAccount: %+v", err) + } + return out, nil + } + + var parent BaseStorageAccountCustomDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseStorageAccountCustomDetailsImpl: %+v", err) + } + + return RawStorageAccountCustomDetailsImpl{ + storageAccountCustomDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/predicates.go new file mode 100644 index 00000000000..9a372249403 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/predicates.go @@ -0,0 +1,32 @@ +package replicationprotectionintents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProtectionIntentOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ReplicationProtectionIntentOperationPredicate) Matches(input ReplicationProtectionIntent) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/version.go new file mode 100644 index 00000000000..752bd3b1158 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationprotectionintents/version.go @@ -0,0 +1,10 @@ +package replicationprotectionintents + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationprotectionintents/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/README.md new file mode 100644 index 00000000000..6c42c8edeeb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/README.md @@ -0,0 +1,203 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans` Documentation + +The `replicationrecoveryplans` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans" +``` + + +### Client Initialization + +```go +client := replicationrecoveryplans.NewReplicationRecoveryPlansClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.Create` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + +payload := replicationrecoveryplans.CreateRecoveryPlanInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.Delete` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.FailoverCancel` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + +if err := client.FailoverCancelThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.FailoverCommit` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + +if err := client.FailoverCommitThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.Get` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + +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: `ReplicationRecoveryPlansClient.List` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.PlannedFailover` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + +payload := replicationrecoveryplans.RecoveryPlanPlannedFailoverInput{ + // ... +} + + +if err := client.PlannedFailoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.Reprotect` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + +if err := client.ReprotectThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.TestFailover` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + +payload := replicationrecoveryplans.RecoveryPlanTestFailoverInput{ + // ... +} + + +if err := client.TestFailoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.TestFailoverCleanup` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + +payload := replicationrecoveryplans.RecoveryPlanTestFailoverCleanupInput{ + // ... +} + + +if err := client.TestFailoverCleanupThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.UnplannedFailover` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + +payload := replicationrecoveryplans.RecoveryPlanUnplannedFailoverInput{ + // ... +} + + +if err := client.UnplannedFailoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.Update` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + +payload := replicationrecoveryplans.UpdateRecoveryPlanInput{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/client.go new file mode 100644 index 00000000000..3337fa87cfc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/client.go @@ -0,0 +1,26 @@ +package replicationrecoveryplans + +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 ReplicationRecoveryPlansClient struct { + Client *resourcemanager.Client +} + +func NewReplicationRecoveryPlansClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationRecoveryPlansClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationrecoveryplans", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationRecoveryPlansClient: %+v", err) + } + + return &ReplicationRecoveryPlansClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/constants.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/constants.go new file mode 100644 index 00000000000..3205b305372 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/constants.go @@ -0,0 +1,691 @@ +package replicationrecoveryplans + +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 A2ARpRecoveryPointType string + +const ( + A2ARpRecoveryPointTypeLatest A2ARpRecoveryPointType = "Latest" + A2ARpRecoveryPointTypeLatestApplicationConsistent A2ARpRecoveryPointType = "LatestApplicationConsistent" + A2ARpRecoveryPointTypeLatestCrashConsistent A2ARpRecoveryPointType = "LatestCrashConsistent" + A2ARpRecoveryPointTypeLatestProcessed A2ARpRecoveryPointType = "LatestProcessed" +) + +func PossibleValuesForA2ARpRecoveryPointType() []string { + return []string{ + string(A2ARpRecoveryPointTypeLatest), + string(A2ARpRecoveryPointTypeLatestApplicationConsistent), + string(A2ARpRecoveryPointTypeLatestCrashConsistent), + string(A2ARpRecoveryPointTypeLatestProcessed), + } +} + +func (s *A2ARpRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseA2ARpRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseA2ARpRecoveryPointType(input string) (*A2ARpRecoveryPointType, error) { + vals := map[string]A2ARpRecoveryPointType{ + "latest": A2ARpRecoveryPointTypeLatest, + "latestapplicationconsistent": A2ARpRecoveryPointTypeLatestApplicationConsistent, + "latestcrashconsistent": A2ARpRecoveryPointTypeLatestCrashConsistent, + "latestprocessed": A2ARpRecoveryPointTypeLatestProcessed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := A2ARpRecoveryPointType(input) + return &out, nil +} + +type AlternateLocationRecoveryOption string + +const ( + AlternateLocationRecoveryOptionCreateVMIfNotFound AlternateLocationRecoveryOption = "CreateVmIfNotFound" + AlternateLocationRecoveryOptionNoAction AlternateLocationRecoveryOption = "NoAction" +) + +func PossibleValuesForAlternateLocationRecoveryOption() []string { + return []string{ + string(AlternateLocationRecoveryOptionCreateVMIfNotFound), + string(AlternateLocationRecoveryOptionNoAction), + } +} + +func (s *AlternateLocationRecoveryOption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAlternateLocationRecoveryOption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAlternateLocationRecoveryOption(input string) (*AlternateLocationRecoveryOption, error) { + vals := map[string]AlternateLocationRecoveryOption{ + "createvmifnotfound": AlternateLocationRecoveryOptionCreateVMIfNotFound, + "noaction": AlternateLocationRecoveryOptionNoAction, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AlternateLocationRecoveryOption(input) + return &out, nil +} + +type DataSyncStatus string + +const ( + DataSyncStatusForDownTime DataSyncStatus = "ForDownTime" + DataSyncStatusForSynchronization DataSyncStatus = "ForSynchronization" +) + +func PossibleValuesForDataSyncStatus() []string { + return []string{ + string(DataSyncStatusForDownTime), + string(DataSyncStatusForSynchronization), + } +} + +func (s *DataSyncStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataSyncStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataSyncStatus(input string) (*DataSyncStatus, error) { + vals := map[string]DataSyncStatus{ + "fordowntime": DataSyncStatusForDownTime, + "forsynchronization": DataSyncStatusForSynchronization, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataSyncStatus(input) + return &out, nil +} + +type FailoverDeploymentModel string + +const ( + FailoverDeploymentModelClassic FailoverDeploymentModel = "Classic" + FailoverDeploymentModelNotApplicable FailoverDeploymentModel = "NotApplicable" + FailoverDeploymentModelResourceManager FailoverDeploymentModel = "ResourceManager" +) + +func PossibleValuesForFailoverDeploymentModel() []string { + return []string{ + string(FailoverDeploymentModelClassic), + string(FailoverDeploymentModelNotApplicable), + string(FailoverDeploymentModelResourceManager), + } +} + +func (s *FailoverDeploymentModel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFailoverDeploymentModel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFailoverDeploymentModel(input string) (*FailoverDeploymentModel, error) { + vals := map[string]FailoverDeploymentModel{ + "classic": FailoverDeploymentModelClassic, + "notapplicable": FailoverDeploymentModelNotApplicable, + "resourcemanager": FailoverDeploymentModelResourceManager, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FailoverDeploymentModel(input) + return &out, nil +} + +type HyperVReplicaAzureRpRecoveryPointType string + +const ( + HyperVReplicaAzureRpRecoveryPointTypeLatest HyperVReplicaAzureRpRecoveryPointType = "Latest" + HyperVReplicaAzureRpRecoveryPointTypeLatestApplicationConsistent HyperVReplicaAzureRpRecoveryPointType = "LatestApplicationConsistent" + HyperVReplicaAzureRpRecoveryPointTypeLatestProcessed HyperVReplicaAzureRpRecoveryPointType = "LatestProcessed" +) + +func PossibleValuesForHyperVReplicaAzureRpRecoveryPointType() []string { + return []string{ + string(HyperVReplicaAzureRpRecoveryPointTypeLatest), + string(HyperVReplicaAzureRpRecoveryPointTypeLatestApplicationConsistent), + string(HyperVReplicaAzureRpRecoveryPointTypeLatestProcessed), + } +} + +func (s *HyperVReplicaAzureRpRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHyperVReplicaAzureRpRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHyperVReplicaAzureRpRecoveryPointType(input string) (*HyperVReplicaAzureRpRecoveryPointType, error) { + vals := map[string]HyperVReplicaAzureRpRecoveryPointType{ + "latest": HyperVReplicaAzureRpRecoveryPointTypeLatest, + "latestapplicationconsistent": HyperVReplicaAzureRpRecoveryPointTypeLatestApplicationConsistent, + "latestprocessed": HyperVReplicaAzureRpRecoveryPointTypeLatestProcessed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HyperVReplicaAzureRpRecoveryPointType(input) + return &out, nil +} + +type InMageRcmFailbackRecoveryPointType string + +const ( + InMageRcmFailbackRecoveryPointTypeApplicationConsistent InMageRcmFailbackRecoveryPointType = "ApplicationConsistent" + InMageRcmFailbackRecoveryPointTypeCrashConsistent InMageRcmFailbackRecoveryPointType = "CrashConsistent" +) + +func PossibleValuesForInMageRcmFailbackRecoveryPointType() []string { + return []string{ + string(InMageRcmFailbackRecoveryPointTypeApplicationConsistent), + string(InMageRcmFailbackRecoveryPointTypeCrashConsistent), + } +} + +func (s *InMageRcmFailbackRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInMageRcmFailbackRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInMageRcmFailbackRecoveryPointType(input string) (*InMageRcmFailbackRecoveryPointType, error) { + vals := map[string]InMageRcmFailbackRecoveryPointType{ + "applicationconsistent": InMageRcmFailbackRecoveryPointTypeApplicationConsistent, + "crashconsistent": InMageRcmFailbackRecoveryPointTypeCrashConsistent, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InMageRcmFailbackRecoveryPointType(input) + return &out, nil +} + +type InMageV2RpRecoveryPointType string + +const ( + InMageV2RpRecoveryPointTypeLatest InMageV2RpRecoveryPointType = "Latest" + InMageV2RpRecoveryPointTypeLatestApplicationConsistent InMageV2RpRecoveryPointType = "LatestApplicationConsistent" + InMageV2RpRecoveryPointTypeLatestCrashConsistent InMageV2RpRecoveryPointType = "LatestCrashConsistent" + InMageV2RpRecoveryPointTypeLatestProcessed InMageV2RpRecoveryPointType = "LatestProcessed" +) + +func PossibleValuesForInMageV2RpRecoveryPointType() []string { + return []string{ + string(InMageV2RpRecoveryPointTypeLatest), + string(InMageV2RpRecoveryPointTypeLatestApplicationConsistent), + string(InMageV2RpRecoveryPointTypeLatestCrashConsistent), + string(InMageV2RpRecoveryPointTypeLatestProcessed), + } +} + +func (s *InMageV2RpRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInMageV2RpRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInMageV2RpRecoveryPointType(input string) (*InMageV2RpRecoveryPointType, error) { + vals := map[string]InMageV2RpRecoveryPointType{ + "latest": InMageV2RpRecoveryPointTypeLatest, + "latestapplicationconsistent": InMageV2RpRecoveryPointTypeLatestApplicationConsistent, + "latestcrashconsistent": InMageV2RpRecoveryPointTypeLatestCrashConsistent, + "latestprocessed": InMageV2RpRecoveryPointTypeLatestProcessed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InMageV2RpRecoveryPointType(input) + return &out, nil +} + +type MultiVMSyncPointOption string + +const ( + MultiVMSyncPointOptionUseMultiVMSyncRecoveryPoint MultiVMSyncPointOption = "UseMultiVmSyncRecoveryPoint" + MultiVMSyncPointOptionUsePerVMRecoveryPoint MultiVMSyncPointOption = "UsePerVmRecoveryPoint" +) + +func PossibleValuesForMultiVMSyncPointOption() []string { + return []string{ + string(MultiVMSyncPointOptionUseMultiVMSyncRecoveryPoint), + string(MultiVMSyncPointOptionUsePerVMRecoveryPoint), + } +} + +func (s *MultiVMSyncPointOption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMultiVMSyncPointOption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMultiVMSyncPointOption(input string) (*MultiVMSyncPointOption, error) { + vals := map[string]MultiVMSyncPointOption{ + "usemultivmsyncrecoverypoint": MultiVMSyncPointOptionUseMultiVMSyncRecoveryPoint, + "usepervmrecoverypoint": MultiVMSyncPointOptionUsePerVMRecoveryPoint, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MultiVMSyncPointOption(input) + return &out, nil +} + +type PossibleOperationsDirections string + +const ( + PossibleOperationsDirectionsPrimaryToRecovery PossibleOperationsDirections = "PrimaryToRecovery" + PossibleOperationsDirectionsRecoveryToPrimary PossibleOperationsDirections = "RecoveryToPrimary" +) + +func PossibleValuesForPossibleOperationsDirections() []string { + return []string{ + string(PossibleOperationsDirectionsPrimaryToRecovery), + string(PossibleOperationsDirectionsRecoveryToPrimary), + } +} + +func (s *PossibleOperationsDirections) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePossibleOperationsDirections(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePossibleOperationsDirections(input string) (*PossibleOperationsDirections, error) { + vals := map[string]PossibleOperationsDirections{ + "primarytorecovery": PossibleOperationsDirectionsPrimaryToRecovery, + "recoverytoprimary": PossibleOperationsDirectionsRecoveryToPrimary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PossibleOperationsDirections(input) + return &out, nil +} + +type RecoveryPlanActionLocation string + +const ( + RecoveryPlanActionLocationPrimary RecoveryPlanActionLocation = "Primary" + RecoveryPlanActionLocationRecovery RecoveryPlanActionLocation = "Recovery" +) + +func PossibleValuesForRecoveryPlanActionLocation() []string { + return []string{ + string(RecoveryPlanActionLocationPrimary), + string(RecoveryPlanActionLocationRecovery), + } +} + +func (s *RecoveryPlanActionLocation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecoveryPlanActionLocation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecoveryPlanActionLocation(input string) (*RecoveryPlanActionLocation, error) { + vals := map[string]RecoveryPlanActionLocation{ + "primary": RecoveryPlanActionLocationPrimary, + "recovery": RecoveryPlanActionLocationRecovery, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPlanActionLocation(input) + return &out, nil +} + +type RecoveryPlanGroupType string + +const ( + RecoveryPlanGroupTypeBoot RecoveryPlanGroupType = "Boot" + RecoveryPlanGroupTypeFailover RecoveryPlanGroupType = "Failover" + RecoveryPlanGroupTypeShutdown RecoveryPlanGroupType = "Shutdown" +) + +func PossibleValuesForRecoveryPlanGroupType() []string { + return []string{ + string(RecoveryPlanGroupTypeBoot), + string(RecoveryPlanGroupTypeFailover), + string(RecoveryPlanGroupTypeShutdown), + } +} + +func (s *RecoveryPlanGroupType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecoveryPlanGroupType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecoveryPlanGroupType(input string) (*RecoveryPlanGroupType, error) { + vals := map[string]RecoveryPlanGroupType{ + "boot": RecoveryPlanGroupTypeBoot, + "failover": RecoveryPlanGroupTypeFailover, + "shutdown": RecoveryPlanGroupTypeShutdown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPlanGroupType(input) + return &out, nil +} + +type RecoveryPlanPointType string + +const ( + RecoveryPlanPointTypeLatest RecoveryPlanPointType = "Latest" + RecoveryPlanPointTypeLatestApplicationConsistent RecoveryPlanPointType = "LatestApplicationConsistent" + RecoveryPlanPointTypeLatestCrashConsistent RecoveryPlanPointType = "LatestCrashConsistent" + RecoveryPlanPointTypeLatestProcessed RecoveryPlanPointType = "LatestProcessed" +) + +func PossibleValuesForRecoveryPlanPointType() []string { + return []string{ + string(RecoveryPlanPointTypeLatest), + string(RecoveryPlanPointTypeLatestApplicationConsistent), + string(RecoveryPlanPointTypeLatestCrashConsistent), + string(RecoveryPlanPointTypeLatestProcessed), + } +} + +func (s *RecoveryPlanPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecoveryPlanPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecoveryPlanPointType(input string) (*RecoveryPlanPointType, error) { + vals := map[string]RecoveryPlanPointType{ + "latest": RecoveryPlanPointTypeLatest, + "latestapplicationconsistent": RecoveryPlanPointTypeLatestApplicationConsistent, + "latestcrashconsistent": RecoveryPlanPointTypeLatestCrashConsistent, + "latestprocessed": RecoveryPlanPointTypeLatestProcessed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPlanPointType(input) + return &out, nil +} + +type ReplicationProtectedItemOperation string + +const ( + ReplicationProtectedItemOperationCancelFailover ReplicationProtectedItemOperation = "CancelFailover" + ReplicationProtectedItemOperationChangePit ReplicationProtectedItemOperation = "ChangePit" + ReplicationProtectedItemOperationCommit ReplicationProtectedItemOperation = "Commit" + ReplicationProtectedItemOperationCompleteMigration ReplicationProtectedItemOperation = "CompleteMigration" + ReplicationProtectedItemOperationDisableProtection ReplicationProtectedItemOperation = "DisableProtection" + ReplicationProtectedItemOperationFailback ReplicationProtectedItemOperation = "Failback" + ReplicationProtectedItemOperationFinalizeFailback ReplicationProtectedItemOperation = "FinalizeFailback" + ReplicationProtectedItemOperationPlannedFailover ReplicationProtectedItemOperation = "PlannedFailover" + ReplicationProtectedItemOperationRepairReplication ReplicationProtectedItemOperation = "RepairReplication" + ReplicationProtectedItemOperationReverseReplicate ReplicationProtectedItemOperation = "ReverseReplicate" + ReplicationProtectedItemOperationSwitchProtection ReplicationProtectedItemOperation = "SwitchProtection" + ReplicationProtectedItemOperationTestFailover ReplicationProtectedItemOperation = "TestFailover" + ReplicationProtectedItemOperationTestFailoverCleanup ReplicationProtectedItemOperation = "TestFailoverCleanup" + ReplicationProtectedItemOperationUnplannedFailover ReplicationProtectedItemOperation = "UnplannedFailover" +) + +func PossibleValuesForReplicationProtectedItemOperation() []string { + return []string{ + string(ReplicationProtectedItemOperationCancelFailover), + string(ReplicationProtectedItemOperationChangePit), + string(ReplicationProtectedItemOperationCommit), + string(ReplicationProtectedItemOperationCompleteMigration), + string(ReplicationProtectedItemOperationDisableProtection), + string(ReplicationProtectedItemOperationFailback), + string(ReplicationProtectedItemOperationFinalizeFailback), + string(ReplicationProtectedItemOperationPlannedFailover), + string(ReplicationProtectedItemOperationRepairReplication), + string(ReplicationProtectedItemOperationReverseReplicate), + string(ReplicationProtectedItemOperationSwitchProtection), + string(ReplicationProtectedItemOperationTestFailover), + string(ReplicationProtectedItemOperationTestFailoverCleanup), + string(ReplicationProtectedItemOperationUnplannedFailover), + } +} + +func (s *ReplicationProtectedItemOperation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReplicationProtectedItemOperation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReplicationProtectedItemOperation(input string) (*ReplicationProtectedItemOperation, error) { + vals := map[string]ReplicationProtectedItemOperation{ + "cancelfailover": ReplicationProtectedItemOperationCancelFailover, + "changepit": ReplicationProtectedItemOperationChangePit, + "commit": ReplicationProtectedItemOperationCommit, + "completemigration": ReplicationProtectedItemOperationCompleteMigration, + "disableprotection": ReplicationProtectedItemOperationDisableProtection, + "failback": ReplicationProtectedItemOperationFailback, + "finalizefailback": ReplicationProtectedItemOperationFinalizeFailback, + "plannedfailover": ReplicationProtectedItemOperationPlannedFailover, + "repairreplication": ReplicationProtectedItemOperationRepairReplication, + "reversereplicate": ReplicationProtectedItemOperationReverseReplicate, + "switchprotection": ReplicationProtectedItemOperationSwitchProtection, + "testfailover": ReplicationProtectedItemOperationTestFailover, + "testfailovercleanup": ReplicationProtectedItemOperationTestFailoverCleanup, + "unplannedfailover": ReplicationProtectedItemOperationUnplannedFailover, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReplicationProtectedItemOperation(input) + return &out, nil +} + +type RpInMageRecoveryPointType string + +const ( + RpInMageRecoveryPointTypeCustom RpInMageRecoveryPointType = "Custom" + RpInMageRecoveryPointTypeLatestTag RpInMageRecoveryPointType = "LatestTag" + RpInMageRecoveryPointTypeLatestTime RpInMageRecoveryPointType = "LatestTime" +) + +func PossibleValuesForRpInMageRecoveryPointType() []string { + return []string{ + string(RpInMageRecoveryPointTypeCustom), + string(RpInMageRecoveryPointTypeLatestTag), + string(RpInMageRecoveryPointTypeLatestTime), + } +} + +func (s *RpInMageRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRpInMageRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRpInMageRecoveryPointType(input string) (*RpInMageRecoveryPointType, error) { + vals := map[string]RpInMageRecoveryPointType{ + "custom": RpInMageRecoveryPointTypeCustom, + "latesttag": RpInMageRecoveryPointTypeLatestTag, + "latesttime": RpInMageRecoveryPointTypeLatestTime, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RpInMageRecoveryPointType(input) + return &out, nil +} + +type SourceSiteOperations string + +const ( + SourceSiteOperationsNotRequired SourceSiteOperations = "NotRequired" + SourceSiteOperationsRequired SourceSiteOperations = "Required" +) + +func PossibleValuesForSourceSiteOperations() []string { + return []string{ + string(SourceSiteOperationsNotRequired), + string(SourceSiteOperationsRequired), + } +} + +func (s *SourceSiteOperations) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSourceSiteOperations(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSourceSiteOperations(input string) (*SourceSiteOperations, error) { + vals := map[string]SourceSiteOperations{ + "notrequired": SourceSiteOperationsNotRequired, + "required": SourceSiteOperationsRequired, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SourceSiteOperations(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/id_replicationrecoveryplan.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/id_replicationrecoveryplan.go new file mode 100644 index 00000000000..02aef0ff679 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/id_replicationrecoveryplan.go @@ -0,0 +1,139 @@ +package replicationrecoveryplans + +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(&ReplicationRecoveryPlanId{}) +} + +var _ resourceids.ResourceId = &ReplicationRecoveryPlanId{} + +// ReplicationRecoveryPlanId is a struct representing the Resource ID for a Replication Recovery Plan +type ReplicationRecoveryPlanId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationRecoveryPlanName string +} + +// NewReplicationRecoveryPlanID returns a new ReplicationRecoveryPlanId struct +func NewReplicationRecoveryPlanID(subscriptionId string, resourceGroupName string, vaultName string, replicationRecoveryPlanName string) ReplicationRecoveryPlanId { + return ReplicationRecoveryPlanId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationRecoveryPlanName: replicationRecoveryPlanName, + } +} + +// ParseReplicationRecoveryPlanID parses 'input' into a ReplicationRecoveryPlanId +func ParseReplicationRecoveryPlanID(input string) (*ReplicationRecoveryPlanId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationRecoveryPlanId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationRecoveryPlanId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationRecoveryPlanIDInsensitively parses 'input' case-insensitively into a ReplicationRecoveryPlanId +// note: this method should only be used for API response data and not user input +func ParseReplicationRecoveryPlanIDInsensitively(input string) (*ReplicationRecoveryPlanId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationRecoveryPlanId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationRecoveryPlanId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationRecoveryPlanId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationRecoveryPlanName, ok = input.Parsed["replicationRecoveryPlanName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationRecoveryPlanName", input) + } + + return nil +} + +// ValidateReplicationRecoveryPlanID checks that 'input' can be parsed as a Replication Recovery Plan ID +func ValidateReplicationRecoveryPlanID(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 := ParseReplicationRecoveryPlanID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Recovery Plan ID +func (id ReplicationRecoveryPlanId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationRecoveryPlans/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationRecoveryPlanName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Recovery Plan ID +func (id ReplicationRecoveryPlanId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationRecoveryPlans", "replicationRecoveryPlans", "replicationRecoveryPlans"), + resourceids.UserSpecifiedSegment("replicationRecoveryPlanName", "replicationRecoveryPlanName"), + } +} + +// String returns a human-readable description of this Replication Recovery Plan ID +func (id ReplicationRecoveryPlanId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Recovery Plan Name: %q", id.ReplicationRecoveryPlanName), + } + return fmt.Sprintf("Replication Recovery Plan (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/id_replicationrecoveryplan_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/id_replicationrecoveryplan_test.go new file mode 100644 index 00000000000..64c0aac5f20 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/id_replicationrecoveryplan_test.go @@ -0,0 +1,327 @@ +package replicationrecoveryplans + +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 = &ReplicationRecoveryPlanId{} + +func TestNewReplicationRecoveryPlanID(t *testing.T) { + id := NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationRecoveryPlanName != "replicationRecoveryPlanName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationRecoveryPlanName'", id.ReplicationRecoveryPlanName, "replicationRecoveryPlanName") + } +} + +func TestFormatReplicationRecoveryPlanID(t *testing.T) { + actual := NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationRecoveryPlans/replicationRecoveryPlanName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationRecoveryPlanID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationRecoveryPlanId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationRecoveryPlans", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationRecoveryPlans/replicationRecoveryPlanName", + Expected: &ReplicationRecoveryPlanId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationRecoveryPlanName: "replicationRecoveryPlanName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationRecoveryPlans/replicationRecoveryPlanName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationRecoveryPlanID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationRecoveryPlanName != v.Expected.ReplicationRecoveryPlanName { + t.Fatalf("Expected %q but got %q for ReplicationRecoveryPlanName", v.Expected.ReplicationRecoveryPlanName, actual.ReplicationRecoveryPlanName) + } + + } +} + +func TestParseReplicationRecoveryPlanIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationRecoveryPlanId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationRecoveryPlans", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnReCoVeRyPlAnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationRecoveryPlans/replicationRecoveryPlanName", + Expected: &ReplicationRecoveryPlanId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationRecoveryPlanName: "replicationRecoveryPlanName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationRecoveryPlans/replicationRecoveryPlanName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnReCoVeRyPlAnS/rEpLiCaTiOnReCoVeRyPlAnNaMe", + Expected: &ReplicationRecoveryPlanId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationRecoveryPlanName: "rEpLiCaTiOnReCoVeRyPlAnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnReCoVeRyPlAnS/rEpLiCaTiOnReCoVeRyPlAnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationRecoveryPlanIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationRecoveryPlanName != v.Expected.ReplicationRecoveryPlanName { + t.Fatalf("Expected %q but got %q for ReplicationRecoveryPlanName", v.Expected.ReplicationRecoveryPlanName, actual.ReplicationRecoveryPlanName) + } + + } +} + +func TestSegmentsForReplicationRecoveryPlanId(t *testing.T) { + segments := ReplicationRecoveryPlanId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationRecoveryPlanId 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/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/id_vault.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/id_vault.go new file mode 100644 index 00000000000..634bd8573b8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/id_vault.go @@ -0,0 +1,130 @@ +package replicationrecoveryplans + +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(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(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 := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/id_vault_test.go new file mode 100644 index 00000000000..3f67d09bb04 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationrecoveryplans + +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 = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId 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/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_create.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_create.go new file mode 100644 index 00000000000..208bd2e921a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_create.go @@ -0,0 +1,75 @@ +package replicationrecoveryplans + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// Create ... +func (c ReplicationRecoveryPlansClient) Create(ctx context.Context, id ReplicationRecoveryPlanId, input CreateRecoveryPlanInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationRecoveryPlansClient) CreateThenPoll(ctx context.Context, id ReplicationRecoveryPlanId, input CreateRecoveryPlanInput) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_delete.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_delete.go new file mode 100644 index 00000000000..361ccfa4989 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_delete.go @@ -0,0 +1,70 @@ +package replicationrecoveryplans + +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 ReplicationRecoveryPlansClient) Delete(ctx context.Context, id ReplicationRecoveryPlanId) (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 ReplicationRecoveryPlansClient) DeleteThenPoll(ctx context.Context, id ReplicationRecoveryPlanId) 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/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_failovercancel.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_failovercancel.go new file mode 100644 index 00000000000..cdd458efe6e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_failovercancel.go @@ -0,0 +1,71 @@ +package replicationrecoveryplans + +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 FailoverCancelOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// FailoverCancel ... +func (c ReplicationRecoveryPlansClient) FailoverCancel(ctx context.Context, id ReplicationRecoveryPlanId) (result FailoverCancelOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/failoverCancel", 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 +} + +// FailoverCancelThenPoll performs FailoverCancel then polls until it's completed +func (c ReplicationRecoveryPlansClient) FailoverCancelThenPoll(ctx context.Context, id ReplicationRecoveryPlanId) error { + result, err := c.FailoverCancel(ctx, id) + if err != nil { + return fmt.Errorf("performing FailoverCancel: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after FailoverCancel: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_failovercommit.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_failovercommit.go new file mode 100644 index 00000000000..616be805c7c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_failovercommit.go @@ -0,0 +1,71 @@ +package replicationrecoveryplans + +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 FailoverCommitOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// FailoverCommit ... +func (c ReplicationRecoveryPlansClient) FailoverCommit(ctx context.Context, id ReplicationRecoveryPlanId) (result FailoverCommitOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/failoverCommit", 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 +} + +// FailoverCommitThenPoll performs FailoverCommit then polls until it's completed +func (c ReplicationRecoveryPlansClient) FailoverCommitThenPoll(ctx context.Context, id ReplicationRecoveryPlanId) error { + result, err := c.FailoverCommit(ctx, id) + if err != nil { + return fmt.Errorf("performing FailoverCommit: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after FailoverCommit: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_get.go new file mode 100644 index 00000000000..3bb61627501 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_get.go @@ -0,0 +1,53 @@ +package replicationrecoveryplans + +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 *RecoveryPlan +} + +// Get ... +func (c ReplicationRecoveryPlansClient) Get(ctx context.Context, id ReplicationRecoveryPlanId) (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 RecoveryPlan + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_list.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_list.go new file mode 100644 index 00000000000..d8446f2ae10 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_list.go @@ -0,0 +1,105 @@ +package replicationrecoveryplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RecoveryPlan +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RecoveryPlan +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ReplicationRecoveryPlansClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/replicationRecoveryPlans", 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 *[]RecoveryPlan `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationRecoveryPlansClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, RecoveryPlanOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationRecoveryPlansClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate RecoveryPlanOperationPredicate) (result ListCompleteResult, err error) { + items := make([]RecoveryPlan, 0) + + resp, err := c.List(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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_plannedfailover.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_plannedfailover.go new file mode 100644 index 00000000000..9e199f4febe --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_plannedfailover.go @@ -0,0 +1,75 @@ +package replicationrecoveryplans + +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 PlannedFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// PlannedFailover ... +func (c ReplicationRecoveryPlansClient) PlannedFailover(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanPlannedFailoverInput) (result PlannedFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/plannedFailover", 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 +} + +// PlannedFailoverThenPoll performs PlannedFailover then polls until it's completed +func (c ReplicationRecoveryPlansClient) PlannedFailoverThenPoll(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanPlannedFailoverInput) error { + result, err := c.PlannedFailover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PlannedFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PlannedFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_reprotect.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_reprotect.go new file mode 100644 index 00000000000..4ba2693d77c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_reprotect.go @@ -0,0 +1,71 @@ +package replicationrecoveryplans + +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 ReprotectOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// Reprotect ... +func (c ReplicationRecoveryPlansClient) Reprotect(ctx context.Context, id ReplicationRecoveryPlanId) (result ReprotectOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reProtect", 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 +} + +// ReprotectThenPoll performs Reprotect then polls until it's completed +func (c ReplicationRecoveryPlansClient) ReprotectThenPoll(ctx context.Context, id ReplicationRecoveryPlanId) error { + result, err := c.Reprotect(ctx, id) + if err != nil { + return fmt.Errorf("performing Reprotect: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Reprotect: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_testfailover.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_testfailover.go new file mode 100644 index 00000000000..5ce4c216166 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_testfailover.go @@ -0,0 +1,75 @@ +package replicationrecoveryplans + +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 TestFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// TestFailover ... +func (c ReplicationRecoveryPlansClient) TestFailover(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanTestFailoverInput) (result TestFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testFailover", 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 +} + +// TestFailoverThenPoll performs TestFailover then polls until it's completed +func (c ReplicationRecoveryPlansClient) TestFailoverThenPoll(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanTestFailoverInput) error { + result, err := c.TestFailover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TestFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TestFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_testfailovercleanup.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_testfailovercleanup.go new file mode 100644 index 00000000000..77c89a02297 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_testfailovercleanup.go @@ -0,0 +1,75 @@ +package replicationrecoveryplans + +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 TestFailoverCleanupOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// TestFailoverCleanup ... +func (c ReplicationRecoveryPlansClient) TestFailoverCleanup(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanTestFailoverCleanupInput) (result TestFailoverCleanupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testFailoverCleanup", 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 +} + +// TestFailoverCleanupThenPoll performs TestFailoverCleanup then polls until it's completed +func (c ReplicationRecoveryPlansClient) TestFailoverCleanupThenPoll(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanTestFailoverCleanupInput) error { + result, err := c.TestFailoverCleanup(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TestFailoverCleanup: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TestFailoverCleanup: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_unplannedfailover.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_unplannedfailover.go new file mode 100644 index 00000000000..a2c4fe6c90d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_unplannedfailover.go @@ -0,0 +1,75 @@ +package replicationrecoveryplans + +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 UnplannedFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// UnplannedFailover ... +func (c ReplicationRecoveryPlansClient) UnplannedFailover(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanUnplannedFailoverInput) (result UnplannedFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/unplannedFailover", 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 +} + +// UnplannedFailoverThenPoll performs UnplannedFailover then polls until it's completed +func (c ReplicationRecoveryPlansClient) UnplannedFailoverThenPoll(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanUnplannedFailoverInput) error { + result, err := c.UnplannedFailover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UnplannedFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UnplannedFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_update.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_update.go new file mode 100644 index 00000000000..45c17f2850c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/method_update.go @@ -0,0 +1,75 @@ +package replicationrecoveryplans + +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 *RecoveryPlan +} + +// Update ... +func (c ReplicationRecoveryPlansClient) Update(ctx context.Context, id ReplicationRecoveryPlanId, input UpdateRecoveryPlanInput) (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 ReplicationRecoveryPlansClient) UpdateThenPoll(ctx context.Context, id ReplicationRecoveryPlanId, input UpdateRecoveryPlanInput) 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/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_createrecoveryplaninput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_createrecoveryplaninput.go new file mode 100644 index 00000000000..283b7b90f39 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_createrecoveryplaninput.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateRecoveryPlanInput struct { + Properties CreateRecoveryPlanInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_createrecoveryplaninputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_createrecoveryplaninputproperties.go new file mode 100644 index 00000000000..c0779757fd4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_createrecoveryplaninputproperties.go @@ -0,0 +1,60 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateRecoveryPlanInputProperties struct { + FailoverDeploymentModel *FailoverDeploymentModel `json:"failoverDeploymentModel,omitempty"` + Groups []RecoveryPlanGroup `json:"groups"` + PrimaryFabricId string `json:"primaryFabricId"` + ProviderSpecificInput *[]RecoveryPlanProviderSpecificInput `json:"providerSpecificInput,omitempty"` + RecoveryFabricId string `json:"recoveryFabricId"` +} + +var _ json.Unmarshaler = &CreateRecoveryPlanInputProperties{} + +func (s *CreateRecoveryPlanInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FailoverDeploymentModel *FailoverDeploymentModel `json:"failoverDeploymentModel,omitempty"` + Groups []RecoveryPlanGroup `json:"groups"` + PrimaryFabricId string `json:"primaryFabricId"` + RecoveryFabricId string `json:"recoveryFabricId"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FailoverDeploymentModel = decoded.FailoverDeploymentModel + s.Groups = decoded.Groups + s.PrimaryFabricId = decoded.PrimaryFabricId + s.RecoveryFabricId = decoded.RecoveryFabricId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CreateRecoveryPlanInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificInput"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling ProviderSpecificInput into list []json.RawMessage: %+v", err) + } + + output := make([]RecoveryPlanProviderSpecificInput, 0) + for i, val := range listTemp { + impl, err := UnmarshalRecoveryPlanProviderSpecificInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'ProviderSpecificInput' for 'CreateRecoveryPlanInputProperties': %+v", i, err) + } + output = append(output, impl) + } + s.ProviderSpecificInput = &output + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_currentscenariodetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_currentscenariodetails.go new file mode 100644 index 00000000000..fbcd02e69f9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_currentscenariodetails.go @@ -0,0 +1,28 @@ +package replicationrecoveryplans + +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 CurrentScenarioDetails struct { + JobId *string `json:"jobId,omitempty"` + ScenarioName *string `json:"scenarioName,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *CurrentScenarioDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CurrentScenarioDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplan.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplan.go new file mode 100644 index 00000000000..f2f8f5ac73f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplan.go @@ -0,0 +1,12 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlan struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RecoveryPlanProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplana2adetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplana2adetails.go new file mode 100644 index 00000000000..67f3a9adf65 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplana2adetails.go @@ -0,0 +1,55 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanProviderSpecificDetails = RecoveryPlanA2ADetails{} + +type RecoveryPlanA2ADetails struct { + PrimaryExtendedLocation *edgezones.Model `json:"primaryExtendedLocation,omitempty"` + PrimaryZone *string `json:"primaryZone,omitempty"` + RecoveryExtendedLocation *edgezones.Model `json:"recoveryExtendedLocation,omitempty"` + RecoveryZone *string `json:"recoveryZone,omitempty"` + + // Fields inherited from RecoveryPlanProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanA2ADetails) RecoveryPlanProviderSpecificDetails() BaseRecoveryPlanProviderSpecificDetailsImpl { + return BaseRecoveryPlanProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanA2ADetails{} + +func (s RecoveryPlanA2ADetails) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanA2ADetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanA2ADetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanA2ADetails: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanA2ADetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplana2afailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplana2afailoverinput.go new file mode 100644 index 00000000000..a33bb19bdc1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplana2afailoverinput.go @@ -0,0 +1,52 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanProviderSpecificFailoverInput = RecoveryPlanA2AFailoverInput{} + +type RecoveryPlanA2AFailoverInput struct { + CloudServiceCreationOption *string `json:"cloudServiceCreationOption,omitempty"` + MultiVMSyncPointOption *MultiVMSyncPointOption `json:"multiVmSyncPointOption,omitempty"` + RecoveryPointType A2ARpRecoveryPointType `json:"recoveryPointType"` + + // Fields inherited from RecoveryPlanProviderSpecificFailoverInput + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanA2AFailoverInput) RecoveryPlanProviderSpecificFailoverInput() BaseRecoveryPlanProviderSpecificFailoverInputImpl { + return BaseRecoveryPlanProviderSpecificFailoverInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanA2AFailoverInput{} + +func (s RecoveryPlanA2AFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanA2AFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanA2AFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanA2AFailoverInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanA2AFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplana2ainput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplana2ainput.go new file mode 100644 index 00000000000..3768e22d457 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplana2ainput.go @@ -0,0 +1,55 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanProviderSpecificInput = RecoveryPlanA2AInput{} + +type RecoveryPlanA2AInput struct { + PrimaryExtendedLocation *edgezones.Model `json:"primaryExtendedLocation,omitempty"` + PrimaryZone *string `json:"primaryZone,omitempty"` + RecoveryExtendedLocation *edgezones.Model `json:"recoveryExtendedLocation,omitempty"` + RecoveryZone *string `json:"recoveryZone,omitempty"` + + // Fields inherited from RecoveryPlanProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanA2AInput) RecoveryPlanProviderSpecificInput() BaseRecoveryPlanProviderSpecificInputImpl { + return BaseRecoveryPlanProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanA2AInput{} + +func (s RecoveryPlanA2AInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanA2AInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanA2AInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanA2AInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanA2AInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanaction.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanaction.go new file mode 100644 index 00000000000..176b1d7a5f8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanaction.go @@ -0,0 +1,48 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanAction struct { + ActionName string `json:"actionName"` + CustomDetails RecoveryPlanActionDetails `json:"customDetails"` + FailoverDirections []PossibleOperationsDirections `json:"failoverDirections"` + FailoverTypes []ReplicationProtectedItemOperation `json:"failoverTypes"` +} + +var _ json.Unmarshaler = &RecoveryPlanAction{} + +func (s *RecoveryPlanAction) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ActionName string `json:"actionName"` + FailoverDirections []PossibleOperationsDirections `json:"failoverDirections"` + FailoverTypes []ReplicationProtectedItemOperation `json:"failoverTypes"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ActionName = decoded.ActionName + s.FailoverDirections = decoded.FailoverDirections + s.FailoverTypes = decoded.FailoverTypes + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RecoveryPlanAction into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["customDetails"]; ok { + impl, err := UnmarshalRecoveryPlanActionDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CustomDetails' for 'RecoveryPlanAction': %+v", err) + } + s.CustomDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanactiondetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanactiondetails.go new file mode 100644 index 00000000000..cd463d578aa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanactiondetails.go @@ -0,0 +1,91 @@ +package replicationrecoveryplans + +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 RecoveryPlanActionDetails interface { + RecoveryPlanActionDetails() BaseRecoveryPlanActionDetailsImpl +} + +var _ RecoveryPlanActionDetails = BaseRecoveryPlanActionDetailsImpl{} + +type BaseRecoveryPlanActionDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseRecoveryPlanActionDetailsImpl) RecoveryPlanActionDetails() BaseRecoveryPlanActionDetailsImpl { + return s +} + +var _ RecoveryPlanActionDetails = RawRecoveryPlanActionDetailsImpl{} + +// RawRecoveryPlanActionDetailsImpl 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 RawRecoveryPlanActionDetailsImpl struct { + recoveryPlanActionDetails BaseRecoveryPlanActionDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawRecoveryPlanActionDetailsImpl) RecoveryPlanActionDetails() BaseRecoveryPlanActionDetailsImpl { + return s.recoveryPlanActionDetails +} + +func UnmarshalRecoveryPlanActionDetailsImplementation(input []byte) (RecoveryPlanActionDetails, 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 RecoveryPlanActionDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AutomationRunbookActionDetails") { + var out RecoveryPlanAutomationRunbookActionDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanAutomationRunbookActionDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ManualActionDetails") { + var out RecoveryPlanManualActionDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanManualActionDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ScriptActionDetails") { + var out RecoveryPlanScriptActionDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanScriptActionDetails: %+v", err) + } + return out, nil + } + + var parent BaseRecoveryPlanActionDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRecoveryPlanActionDetailsImpl: %+v", err) + } + + return RawRecoveryPlanActionDetailsImpl{ + recoveryPlanActionDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanautomationrunbookactiondetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanautomationrunbookactiondetails.go new file mode 100644 index 00000000000..a1648419ce9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanautomationrunbookactiondetails.go @@ -0,0 +1,52 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanActionDetails = RecoveryPlanAutomationRunbookActionDetails{} + +type RecoveryPlanAutomationRunbookActionDetails struct { + FabricLocation RecoveryPlanActionLocation `json:"fabricLocation"` + RunbookId *string `json:"runbookId,omitempty"` + Timeout *string `json:"timeout,omitempty"` + + // Fields inherited from RecoveryPlanActionDetails + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanAutomationRunbookActionDetails) RecoveryPlanActionDetails() BaseRecoveryPlanActionDetailsImpl { + return BaseRecoveryPlanActionDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanAutomationRunbookActionDetails{} + +func (s RecoveryPlanAutomationRunbookActionDetails) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanAutomationRunbookActionDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanAutomationRunbookActionDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanAutomationRunbookActionDetails: %+v", err) + } + + decoded["instanceType"] = "AutomationRunbookActionDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanAutomationRunbookActionDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplangroup.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplangroup.go new file mode 100644 index 00000000000..9100cabc9e0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplangroup.go @@ -0,0 +1,11 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanGroup struct { + EndGroupActions *[]RecoveryPlanAction `json:"endGroupActions,omitempty"` + GroupType RecoveryPlanGroupType `json:"groupType"` + ReplicationProtectedItems *[]RecoveryPlanProtectedItem `json:"replicationProtectedItems,omitempty"` + StartGroupActions *[]RecoveryPlanAction `json:"startGroupActions,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanhypervreplicaazurefailbackinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanhypervreplicaazurefailbackinput.go new file mode 100644 index 00000000000..9a4b0f1b42f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanhypervreplicaazurefailbackinput.go @@ -0,0 +1,51 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanProviderSpecificFailoverInput = RecoveryPlanHyperVReplicaAzureFailbackInput{} + +type RecoveryPlanHyperVReplicaAzureFailbackInput struct { + DataSyncOption DataSyncStatus `json:"dataSyncOption"` + RecoveryVMCreationOption AlternateLocationRecoveryOption `json:"recoveryVmCreationOption"` + + // Fields inherited from RecoveryPlanProviderSpecificFailoverInput + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanHyperVReplicaAzureFailbackInput) RecoveryPlanProviderSpecificFailoverInput() BaseRecoveryPlanProviderSpecificFailoverInputImpl { + return BaseRecoveryPlanProviderSpecificFailoverInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanHyperVReplicaAzureFailbackInput{} + +func (s RecoveryPlanHyperVReplicaAzureFailbackInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanHyperVReplicaAzureFailbackInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanHyperVReplicaAzureFailbackInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanHyperVReplicaAzureFailbackInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzureFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanHyperVReplicaAzureFailbackInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanhypervreplicaazurefailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanhypervreplicaazurefailoverinput.go new file mode 100644 index 00000000000..34356511841 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanhypervreplicaazurefailoverinput.go @@ -0,0 +1,52 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanProviderSpecificFailoverInput = RecoveryPlanHyperVReplicaAzureFailoverInput{} + +type RecoveryPlanHyperVReplicaAzureFailoverInput struct { + PrimaryKekCertificatePfx *string `json:"primaryKekCertificatePfx,omitempty"` + RecoveryPointType *HyperVReplicaAzureRpRecoveryPointType `json:"recoveryPointType,omitempty"` + SecondaryKekCertificatePfx *string `json:"secondaryKekCertificatePfx,omitempty"` + + // Fields inherited from RecoveryPlanProviderSpecificFailoverInput + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanHyperVReplicaAzureFailoverInput) RecoveryPlanProviderSpecificFailoverInput() BaseRecoveryPlanProviderSpecificFailoverInputImpl { + return BaseRecoveryPlanProviderSpecificFailoverInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanHyperVReplicaAzureFailoverInput{} + +func (s RecoveryPlanHyperVReplicaAzureFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanHyperVReplicaAzureFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanHyperVReplicaAzureFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanHyperVReplicaAzureFailoverInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanHyperVReplicaAzureFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplaninmageazurev2failoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplaninmageazurev2failoverinput.go new file mode 100644 index 00000000000..3bdbbc0769f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplaninmageazurev2failoverinput.go @@ -0,0 +1,51 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanProviderSpecificFailoverInput = RecoveryPlanInMageAzureV2FailoverInput{} + +type RecoveryPlanInMageAzureV2FailoverInput struct { + RecoveryPointType InMageV2RpRecoveryPointType `json:"recoveryPointType"` + UseMultiVMSyncPoint *string `json:"useMultiVmSyncPoint,omitempty"` + + // Fields inherited from RecoveryPlanProviderSpecificFailoverInput + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanInMageAzureV2FailoverInput) RecoveryPlanProviderSpecificFailoverInput() BaseRecoveryPlanProviderSpecificFailoverInputImpl { + return BaseRecoveryPlanProviderSpecificFailoverInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanInMageAzureV2FailoverInput{} + +func (s RecoveryPlanInMageAzureV2FailoverInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanInMageAzureV2FailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanInMageAzureV2FailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanInMageAzureV2FailoverInput: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanInMageAzureV2FailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplaninmagefailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplaninmagefailoverinput.go new file mode 100644 index 00000000000..bb3d2294b2b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplaninmagefailoverinput.go @@ -0,0 +1,50 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanProviderSpecificFailoverInput = RecoveryPlanInMageFailoverInput{} + +type RecoveryPlanInMageFailoverInput struct { + RecoveryPointType RpInMageRecoveryPointType `json:"recoveryPointType"` + + // Fields inherited from RecoveryPlanProviderSpecificFailoverInput + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanInMageFailoverInput) RecoveryPlanProviderSpecificFailoverInput() BaseRecoveryPlanProviderSpecificFailoverInputImpl { + return BaseRecoveryPlanProviderSpecificFailoverInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanInMageFailoverInput{} + +func (s RecoveryPlanInMageFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanInMageFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanInMageFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanInMageFailoverInput: %+v", err) + } + + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanInMageFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplaninmagercmfailbackfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplaninmagercmfailbackfailoverinput.go new file mode 100644 index 00000000000..f49c9de401d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplaninmagercmfailbackfailoverinput.go @@ -0,0 +1,51 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanProviderSpecificFailoverInput = RecoveryPlanInMageRcmFailbackFailoverInput{} + +type RecoveryPlanInMageRcmFailbackFailoverInput struct { + RecoveryPointType InMageRcmFailbackRecoveryPointType `json:"recoveryPointType"` + UseMultiVMSyncPoint *string `json:"useMultiVmSyncPoint,omitempty"` + + // Fields inherited from RecoveryPlanProviderSpecificFailoverInput + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanInMageRcmFailbackFailoverInput) RecoveryPlanProviderSpecificFailoverInput() BaseRecoveryPlanProviderSpecificFailoverInputImpl { + return BaseRecoveryPlanProviderSpecificFailoverInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanInMageRcmFailbackFailoverInput{} + +func (s RecoveryPlanInMageRcmFailbackFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanInMageRcmFailbackFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanInMageRcmFailbackFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanInMageRcmFailbackFailoverInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcmFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanInMageRcmFailbackFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplaninmagercmfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplaninmagercmfailoverinput.go new file mode 100644 index 00000000000..04eb0d55758 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplaninmagercmfailoverinput.go @@ -0,0 +1,51 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanProviderSpecificFailoverInput = RecoveryPlanInMageRcmFailoverInput{} + +type RecoveryPlanInMageRcmFailoverInput struct { + RecoveryPointType RecoveryPlanPointType `json:"recoveryPointType"` + UseMultiVMSyncPoint *string `json:"useMultiVmSyncPoint,omitempty"` + + // Fields inherited from RecoveryPlanProviderSpecificFailoverInput + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanInMageRcmFailoverInput) RecoveryPlanProviderSpecificFailoverInput() BaseRecoveryPlanProviderSpecificFailoverInputImpl { + return BaseRecoveryPlanProviderSpecificFailoverInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanInMageRcmFailoverInput{} + +func (s RecoveryPlanInMageRcmFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanInMageRcmFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanInMageRcmFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanInMageRcmFailoverInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanInMageRcmFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanmanualactiondetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanmanualactiondetails.go new file mode 100644 index 00000000000..91503cc854c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanmanualactiondetails.go @@ -0,0 +1,50 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanActionDetails = RecoveryPlanManualActionDetails{} + +type RecoveryPlanManualActionDetails struct { + Description *string `json:"description,omitempty"` + + // Fields inherited from RecoveryPlanActionDetails + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanManualActionDetails) RecoveryPlanActionDetails() BaseRecoveryPlanActionDetailsImpl { + return BaseRecoveryPlanActionDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanManualActionDetails{} + +func (s RecoveryPlanManualActionDetails) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanManualActionDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanManualActionDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanManualActionDetails: %+v", err) + } + + decoded["instanceType"] = "ManualActionDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanManualActionDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanplannedfailoverinput.go new file mode 100644 index 00000000000..5afa04d9119 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanplannedfailoverinput.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanPlannedFailoverInput struct { + Properties RecoveryPlanPlannedFailoverInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanplannedfailoverinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanplannedfailoverinputproperties.go new file mode 100644 index 00000000000..81ea5a587bb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanplannedfailoverinputproperties.go @@ -0,0 +1,51 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanPlannedFailoverInputProperties struct { + FailoverDirection PossibleOperationsDirections `json:"failoverDirection"` + ProviderSpecificDetails *[]RecoveryPlanProviderSpecificFailoverInput `json:"providerSpecificDetails,omitempty"` +} + +var _ json.Unmarshaler = &RecoveryPlanPlannedFailoverInputProperties{} + +func (s *RecoveryPlanPlannedFailoverInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FailoverDirection PossibleOperationsDirections `json:"failoverDirection"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RecoveryPlanPlannedFailoverInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling ProviderSpecificDetails into list []json.RawMessage: %+v", err) + } + + output := make([]RecoveryPlanProviderSpecificFailoverInput, 0) + for i, val := range listTemp { + impl, err := UnmarshalRecoveryPlanProviderSpecificFailoverInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'ProviderSpecificDetails' for 'RecoveryPlanPlannedFailoverInputProperties': %+v", i, err) + } + output = append(output, impl) + } + s.ProviderSpecificDetails = &output + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanproperties.go new file mode 100644 index 00000000000..035d56e1864 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanproperties.go @@ -0,0 +1,132 @@ +package replicationrecoveryplans + +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. + +type RecoveryPlanProperties struct { + AllowedOperations *[]string `json:"allowedOperations,omitempty"` + CurrentScenario *CurrentScenarioDetails `json:"currentScenario,omitempty"` + CurrentScenarioStatus *string `json:"currentScenarioStatus,omitempty"` + CurrentScenarioStatusDescription *string `json:"currentScenarioStatusDescription,omitempty"` + FailoverDeploymentModel *string `json:"failoverDeploymentModel,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Groups *[]RecoveryPlanGroup `json:"groups,omitempty"` + LastPlannedFailoverTime *string `json:"lastPlannedFailoverTime,omitempty"` + LastTestFailoverTime *string `json:"lastTestFailoverTime,omitempty"` + LastUnplannedFailoverTime *string `json:"lastUnplannedFailoverTime,omitempty"` + PrimaryFabricFriendlyName *string `json:"primaryFabricFriendlyName,omitempty"` + PrimaryFabricId *string `json:"primaryFabricId,omitempty"` + ProviderSpecificDetails *[]RecoveryPlanProviderSpecificDetails `json:"providerSpecificDetails,omitempty"` + RecoveryFabricFriendlyName *string `json:"recoveryFabricFriendlyName,omitempty"` + RecoveryFabricId *string `json:"recoveryFabricId,omitempty"` + ReplicationProviders *[]string `json:"replicationProviders,omitempty"` +} + +func (o *RecoveryPlanProperties) GetLastPlannedFailoverTimeAsTime() (*time.Time, error) { + if o.LastPlannedFailoverTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastPlannedFailoverTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryPlanProperties) SetLastPlannedFailoverTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastPlannedFailoverTime = &formatted +} + +func (o *RecoveryPlanProperties) GetLastTestFailoverTimeAsTime() (*time.Time, error) { + if o.LastTestFailoverTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastTestFailoverTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryPlanProperties) SetLastTestFailoverTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastTestFailoverTime = &formatted +} + +func (o *RecoveryPlanProperties) GetLastUnplannedFailoverTimeAsTime() (*time.Time, error) { + if o.LastUnplannedFailoverTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastUnplannedFailoverTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryPlanProperties) SetLastUnplannedFailoverTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastUnplannedFailoverTime = &formatted +} + +var _ json.Unmarshaler = &RecoveryPlanProperties{} + +func (s *RecoveryPlanProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AllowedOperations *[]string `json:"allowedOperations,omitempty"` + CurrentScenario *CurrentScenarioDetails `json:"currentScenario,omitempty"` + CurrentScenarioStatus *string `json:"currentScenarioStatus,omitempty"` + CurrentScenarioStatusDescription *string `json:"currentScenarioStatusDescription,omitempty"` + FailoverDeploymentModel *string `json:"failoverDeploymentModel,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Groups *[]RecoveryPlanGroup `json:"groups,omitempty"` + LastPlannedFailoverTime *string `json:"lastPlannedFailoverTime,omitempty"` + LastTestFailoverTime *string `json:"lastTestFailoverTime,omitempty"` + LastUnplannedFailoverTime *string `json:"lastUnplannedFailoverTime,omitempty"` + PrimaryFabricFriendlyName *string `json:"primaryFabricFriendlyName,omitempty"` + PrimaryFabricId *string `json:"primaryFabricId,omitempty"` + RecoveryFabricFriendlyName *string `json:"recoveryFabricFriendlyName,omitempty"` + RecoveryFabricId *string `json:"recoveryFabricId,omitempty"` + ReplicationProviders *[]string `json:"replicationProviders,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AllowedOperations = decoded.AllowedOperations + s.CurrentScenario = decoded.CurrentScenario + s.CurrentScenarioStatus = decoded.CurrentScenarioStatus + s.CurrentScenarioStatusDescription = decoded.CurrentScenarioStatusDescription + s.FailoverDeploymentModel = decoded.FailoverDeploymentModel + s.FriendlyName = decoded.FriendlyName + s.Groups = decoded.Groups + s.LastPlannedFailoverTime = decoded.LastPlannedFailoverTime + s.LastTestFailoverTime = decoded.LastTestFailoverTime + s.LastUnplannedFailoverTime = decoded.LastUnplannedFailoverTime + s.PrimaryFabricFriendlyName = decoded.PrimaryFabricFriendlyName + s.PrimaryFabricId = decoded.PrimaryFabricId + s.RecoveryFabricFriendlyName = decoded.RecoveryFabricFriendlyName + s.RecoveryFabricId = decoded.RecoveryFabricId + s.ReplicationProviders = decoded.ReplicationProviders + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RecoveryPlanProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling ProviderSpecificDetails into list []json.RawMessage: %+v", err) + } + + output := make([]RecoveryPlanProviderSpecificDetails, 0) + for i, val := range listTemp { + impl, err := UnmarshalRecoveryPlanProviderSpecificDetailsImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'ProviderSpecificDetails' for 'RecoveryPlanProperties': %+v", i, err) + } + output = append(output, impl) + } + s.ProviderSpecificDetails = &output + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanprotecteditem.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanprotecteditem.go new file mode 100644 index 00000000000..e3d9c1e2cbf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanprotecteditem.go @@ -0,0 +1,9 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanProtectedItem struct { + Id *string `json:"id,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanproviderspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanproviderspecificdetails.go new file mode 100644 index 00000000000..903584989ae --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanproviderspecificdetails.go @@ -0,0 +1,75 @@ +package replicationrecoveryplans + +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 RecoveryPlanProviderSpecificDetails interface { + RecoveryPlanProviderSpecificDetails() BaseRecoveryPlanProviderSpecificDetailsImpl +} + +var _ RecoveryPlanProviderSpecificDetails = BaseRecoveryPlanProviderSpecificDetailsImpl{} + +type BaseRecoveryPlanProviderSpecificDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseRecoveryPlanProviderSpecificDetailsImpl) RecoveryPlanProviderSpecificDetails() BaseRecoveryPlanProviderSpecificDetailsImpl { + return s +} + +var _ RecoveryPlanProviderSpecificDetails = RawRecoveryPlanProviderSpecificDetailsImpl{} + +// RawRecoveryPlanProviderSpecificDetailsImpl 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 RawRecoveryPlanProviderSpecificDetailsImpl struct { + recoveryPlanProviderSpecificDetails BaseRecoveryPlanProviderSpecificDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawRecoveryPlanProviderSpecificDetailsImpl) RecoveryPlanProviderSpecificDetails() BaseRecoveryPlanProviderSpecificDetailsImpl { + return s.recoveryPlanProviderSpecificDetails +} + +func UnmarshalRecoveryPlanProviderSpecificDetailsImplementation(input []byte) (RecoveryPlanProviderSpecificDetails, 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 RecoveryPlanProviderSpecificDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out RecoveryPlanA2ADetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanA2ADetails: %+v", err) + } + return out, nil + } + + var parent BaseRecoveryPlanProviderSpecificDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRecoveryPlanProviderSpecificDetailsImpl: %+v", err) + } + + return RawRecoveryPlanProviderSpecificDetailsImpl{ + recoveryPlanProviderSpecificDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanproviderspecificfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanproviderspecificfailoverinput.go new file mode 100644 index 00000000000..d5045326bfc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanproviderspecificfailoverinput.go @@ -0,0 +1,123 @@ +package replicationrecoveryplans + +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 RecoveryPlanProviderSpecificFailoverInput interface { + RecoveryPlanProviderSpecificFailoverInput() BaseRecoveryPlanProviderSpecificFailoverInputImpl +} + +var _ RecoveryPlanProviderSpecificFailoverInput = BaseRecoveryPlanProviderSpecificFailoverInputImpl{} + +type BaseRecoveryPlanProviderSpecificFailoverInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseRecoveryPlanProviderSpecificFailoverInputImpl) RecoveryPlanProviderSpecificFailoverInput() BaseRecoveryPlanProviderSpecificFailoverInputImpl { + return s +} + +var _ RecoveryPlanProviderSpecificFailoverInput = RawRecoveryPlanProviderSpecificFailoverInputImpl{} + +// RawRecoveryPlanProviderSpecificFailoverInputImpl 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 RawRecoveryPlanProviderSpecificFailoverInputImpl struct { + recoveryPlanProviderSpecificFailoverInput BaseRecoveryPlanProviderSpecificFailoverInputImpl + Type string + Values map[string]interface{} +} + +func (s RawRecoveryPlanProviderSpecificFailoverInputImpl) RecoveryPlanProviderSpecificFailoverInput() BaseRecoveryPlanProviderSpecificFailoverInputImpl { + return s.recoveryPlanProviderSpecificFailoverInput +} + +func UnmarshalRecoveryPlanProviderSpecificFailoverInputImplementation(input []byte) (RecoveryPlanProviderSpecificFailoverInput, 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 RecoveryPlanProviderSpecificFailoverInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out RecoveryPlanA2AFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanA2AFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzureFailback") { + var out RecoveryPlanHyperVReplicaAzureFailbackInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanHyperVReplicaAzureFailbackInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out RecoveryPlanHyperVReplicaAzureFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanHyperVReplicaAzureFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out RecoveryPlanInMageAzureV2FailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanInMageAzureV2FailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out RecoveryPlanInMageFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanInMageFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcmFailback") { + var out RecoveryPlanInMageRcmFailbackFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanInMageRcmFailbackFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out RecoveryPlanInMageRcmFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanInMageRcmFailoverInput: %+v", err) + } + return out, nil + } + + var parent BaseRecoveryPlanProviderSpecificFailoverInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRecoveryPlanProviderSpecificFailoverInputImpl: %+v", err) + } + + return RawRecoveryPlanProviderSpecificFailoverInputImpl{ + recoveryPlanProviderSpecificFailoverInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanproviderspecificinput.go new file mode 100644 index 00000000000..8b431bd3c1b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationrecoveryplans + +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 RecoveryPlanProviderSpecificInput interface { + RecoveryPlanProviderSpecificInput() BaseRecoveryPlanProviderSpecificInputImpl +} + +var _ RecoveryPlanProviderSpecificInput = BaseRecoveryPlanProviderSpecificInputImpl{} + +type BaseRecoveryPlanProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseRecoveryPlanProviderSpecificInputImpl) RecoveryPlanProviderSpecificInput() BaseRecoveryPlanProviderSpecificInputImpl { + return s +} + +var _ RecoveryPlanProviderSpecificInput = RawRecoveryPlanProviderSpecificInputImpl{} + +// RawRecoveryPlanProviderSpecificInputImpl 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 RawRecoveryPlanProviderSpecificInputImpl struct { + recoveryPlanProviderSpecificInput BaseRecoveryPlanProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawRecoveryPlanProviderSpecificInputImpl) RecoveryPlanProviderSpecificInput() BaseRecoveryPlanProviderSpecificInputImpl { + return s.recoveryPlanProviderSpecificInput +} + +func UnmarshalRecoveryPlanProviderSpecificInputImplementation(input []byte) (RecoveryPlanProviderSpecificInput, 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 RecoveryPlanProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out RecoveryPlanA2AInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanA2AInput: %+v", err) + } + return out, nil + } + + var parent BaseRecoveryPlanProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRecoveryPlanProviderSpecificInputImpl: %+v", err) + } + + return RawRecoveryPlanProviderSpecificInputImpl{ + recoveryPlanProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanscriptactiondetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanscriptactiondetails.go new file mode 100644 index 00000000000..9e44da053e9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanscriptactiondetails.go @@ -0,0 +1,52 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanActionDetails = RecoveryPlanScriptActionDetails{} + +type RecoveryPlanScriptActionDetails struct { + FabricLocation RecoveryPlanActionLocation `json:"fabricLocation"` + Path string `json:"path"` + Timeout *string `json:"timeout,omitempty"` + + // Fields inherited from RecoveryPlanActionDetails + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanScriptActionDetails) RecoveryPlanActionDetails() BaseRecoveryPlanActionDetailsImpl { + return BaseRecoveryPlanActionDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanScriptActionDetails{} + +func (s RecoveryPlanScriptActionDetails) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanScriptActionDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanScriptActionDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanScriptActionDetails: %+v", err) + } + + decoded["instanceType"] = "ScriptActionDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanScriptActionDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplantestfailovercleanupinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplantestfailovercleanupinput.go new file mode 100644 index 00000000000..4379adce6cd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplantestfailovercleanupinput.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanTestFailoverCleanupInput struct { + Properties RecoveryPlanTestFailoverCleanupInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplantestfailovercleanupinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplantestfailovercleanupinputproperties.go new file mode 100644 index 00000000000..2b3b65c28c3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplantestfailovercleanupinputproperties.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanTestFailoverCleanupInputProperties struct { + Comments *string `json:"comments,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplantestfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplantestfailoverinput.go new file mode 100644 index 00000000000..c5706924b4e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplantestfailoverinput.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanTestFailoverInput struct { + Properties RecoveryPlanTestFailoverInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplantestfailoverinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplantestfailoverinputproperties.go new file mode 100644 index 00000000000..71fc1444108 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplantestfailoverinputproperties.go @@ -0,0 +1,57 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanTestFailoverInputProperties struct { + FailoverDirection PossibleOperationsDirections `json:"failoverDirection"` + NetworkId *string `json:"networkId,omitempty"` + NetworkType string `json:"networkType"` + ProviderSpecificDetails *[]RecoveryPlanProviderSpecificFailoverInput `json:"providerSpecificDetails,omitempty"` +} + +var _ json.Unmarshaler = &RecoveryPlanTestFailoverInputProperties{} + +func (s *RecoveryPlanTestFailoverInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FailoverDirection PossibleOperationsDirections `json:"failoverDirection"` + NetworkId *string `json:"networkId,omitempty"` + NetworkType string `json:"networkType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + s.NetworkId = decoded.NetworkId + s.NetworkType = decoded.NetworkType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RecoveryPlanTestFailoverInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling ProviderSpecificDetails into list []json.RawMessage: %+v", err) + } + + output := make([]RecoveryPlanProviderSpecificFailoverInput, 0) + for i, val := range listTemp { + impl, err := UnmarshalRecoveryPlanProviderSpecificFailoverInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'ProviderSpecificDetails' for 'RecoveryPlanTestFailoverInputProperties': %+v", i, err) + } + output = append(output, impl) + } + s.ProviderSpecificDetails = &output + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanunplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanunplannedfailoverinput.go new file mode 100644 index 00000000000..92fc6578c58 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanunplannedfailoverinput.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanUnplannedFailoverInput struct { + Properties RecoveryPlanUnplannedFailoverInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanunplannedfailoverinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanunplannedfailoverinputproperties.go new file mode 100644 index 00000000000..e5c8bdd52c9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_recoveryplanunplannedfailoverinputproperties.go @@ -0,0 +1,54 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanUnplannedFailoverInputProperties struct { + FailoverDirection PossibleOperationsDirections `json:"failoverDirection"` + ProviderSpecificDetails *[]RecoveryPlanProviderSpecificFailoverInput `json:"providerSpecificDetails,omitempty"` + SourceSiteOperations SourceSiteOperations `json:"sourceSiteOperations"` +} + +var _ json.Unmarshaler = &RecoveryPlanUnplannedFailoverInputProperties{} + +func (s *RecoveryPlanUnplannedFailoverInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FailoverDirection PossibleOperationsDirections `json:"failoverDirection"` + SourceSiteOperations SourceSiteOperations `json:"sourceSiteOperations"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + s.SourceSiteOperations = decoded.SourceSiteOperations + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RecoveryPlanUnplannedFailoverInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling ProviderSpecificDetails into list []json.RawMessage: %+v", err) + } + + output := make([]RecoveryPlanProviderSpecificFailoverInput, 0) + for i, val := range listTemp { + impl, err := UnmarshalRecoveryPlanProviderSpecificFailoverInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'ProviderSpecificDetails' for 'RecoveryPlanUnplannedFailoverInputProperties': %+v", i, err) + } + output = append(output, impl) + } + s.ProviderSpecificDetails = &output + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_updaterecoveryplaninput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_updaterecoveryplaninput.go new file mode 100644 index 00000000000..f1611672eed --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_updaterecoveryplaninput.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateRecoveryPlanInput struct { + Properties *UpdateRecoveryPlanInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_updaterecoveryplaninputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_updaterecoveryplaninputproperties.go new file mode 100644 index 00000000000..dba269e1ee5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/model_updaterecoveryplaninputproperties.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateRecoveryPlanInputProperties struct { + Groups *[]RecoveryPlanGroup `json:"groups,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/predicates.go new file mode 100644 index 00000000000..d6c5e9c2534 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/predicates.go @@ -0,0 +1,32 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p RecoveryPlanOperationPredicate) Matches(input RecoveryPlan) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/version.go new file mode 100644 index 00000000000..9202cc5da98 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryplans/version.go @@ -0,0 +1,10 @@ +package replicationrecoveryplans + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationrecoveryplans/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/README.md new file mode 100644 index 00000000000..641ede31f4f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/README.md @@ -0,0 +1,123 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders` Documentation + +The `replicationrecoveryservicesproviders` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders" +``` + + +### Client Initialization + +```go +client := replicationrecoveryservicesproviders.NewReplicationRecoveryServicesProvidersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationRecoveryServicesProvidersClient.Create` + +```go +ctx := context.TODO() +id := replicationrecoveryservicesproviders.NewReplicationRecoveryServicesProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationRecoveryServicesProviderName") + +payload := replicationrecoveryservicesproviders.AddRecoveryServicesProviderInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryServicesProvidersClient.Delete` + +```go +ctx := context.TODO() +id := replicationrecoveryservicesproviders.NewReplicationRecoveryServicesProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationRecoveryServicesProviderName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryServicesProvidersClient.Get` + +```go +ctx := context.TODO() +id := replicationrecoveryservicesproviders.NewReplicationRecoveryServicesProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationRecoveryServicesProviderName") + +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: `ReplicationRecoveryServicesProvidersClient.List` + +```go +ctx := context.TODO() +id := replicationrecoveryservicesproviders.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationRecoveryServicesProvidersClient.ListByReplicationFabrics` + +```go +ctx := context.TODO() +id := replicationrecoveryservicesproviders.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +// alternatively `client.ListByReplicationFabrics(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationFabricsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationRecoveryServicesProvidersClient.Purge` + +```go +ctx := context.TODO() +id := replicationrecoveryservicesproviders.NewReplicationRecoveryServicesProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationRecoveryServicesProviderName") + +if err := client.PurgeThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryServicesProvidersClient.RefreshProvider` + +```go +ctx := context.TODO() +id := replicationrecoveryservicesproviders.NewReplicationRecoveryServicesProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationRecoveryServicesProviderName") + +if err := client.RefreshProviderThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/client.go new file mode 100644 index 00000000000..a6150690dac --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/client.go @@ -0,0 +1,26 @@ +package replicationrecoveryservicesproviders + +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 ReplicationRecoveryServicesProvidersClient struct { + Client *resourcemanager.Client +} + +func NewReplicationRecoveryServicesProvidersClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationRecoveryServicesProvidersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationrecoveryservicesproviders", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationRecoveryServicesProvidersClient: %+v", err) + } + + return &ReplicationRecoveryServicesProvidersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/constants.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/constants.go new file mode 100644 index 00000000000..1019dcf0757 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/constants.go @@ -0,0 +1,101 @@ +package replicationrecoveryservicesproviders + +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 AgentVersionStatus string + +const ( + AgentVersionStatusDeprecated AgentVersionStatus = "Deprecated" + AgentVersionStatusNotSupported AgentVersionStatus = "NotSupported" + AgentVersionStatusSecurityUpdateRequired AgentVersionStatus = "SecurityUpdateRequired" + AgentVersionStatusSupported AgentVersionStatus = "Supported" + AgentVersionStatusUpdateRequired AgentVersionStatus = "UpdateRequired" +) + +func PossibleValuesForAgentVersionStatus() []string { + return []string{ + string(AgentVersionStatusDeprecated), + string(AgentVersionStatusNotSupported), + string(AgentVersionStatusSecurityUpdateRequired), + string(AgentVersionStatusSupported), + string(AgentVersionStatusUpdateRequired), + } +} + +func (s *AgentVersionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentVersionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentVersionStatus(input string) (*AgentVersionStatus, error) { + vals := map[string]AgentVersionStatus{ + "deprecated": AgentVersionStatusDeprecated, + "notsupported": AgentVersionStatusNotSupported, + "securityupdaterequired": AgentVersionStatusSecurityUpdateRequired, + "supported": AgentVersionStatusSupported, + "updaterequired": AgentVersionStatusUpdateRequired, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentVersionStatus(input) + return &out, nil +} + +type HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/id_replicationfabric.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/id_replicationfabric.go new file mode 100644 index 00000000000..9b5124c9f9f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/id_replicationfabric.go @@ -0,0 +1,139 @@ +package replicationrecoveryservicesproviders + +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(&ReplicationFabricId{}) +} + +var _ resourceids.ResourceId = &ReplicationFabricId{} + +// ReplicationFabricId is a struct representing the Resource ID for a Replication Fabric +type ReplicationFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string +} + +// NewReplicationFabricID returns a new ReplicationFabricId struct +func NewReplicationFabricID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string) ReplicationFabricId { + return ReplicationFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + } +} + +// ParseReplicationFabricID parses 'input' into a ReplicationFabricId +func ParseReplicationFabricID(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationFabricIDInsensitively parses 'input' case-insensitively into a ReplicationFabricId +// note: this method should only be used for API response data and not user input +func ParseReplicationFabricIDInsensitively(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationFabricId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + return nil +} + +// ValidateReplicationFabricID checks that 'input' can be parsed as a Replication Fabric ID +func ValidateReplicationFabricID(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 := ParseReplicationFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Fabric ID +func (id ReplicationFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Fabric ID +func (id ReplicationFabricId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + } +} + +// String returns a human-readable description of this Replication Fabric ID +func (id ReplicationFabricId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + } + return fmt.Sprintf("Replication Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/id_replicationfabric_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/id_replicationfabric_test.go new file mode 100644 index 00000000000..d7afe711ff4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/id_replicationfabric_test.go @@ -0,0 +1,327 @@ +package replicationrecoveryservicesproviders + +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 = &ReplicationFabricId{} + +func TestNewReplicationFabricID(t *testing.T) { + id := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } +} + +func TestFormatReplicationFabricID(t *testing.T) { + actual := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestParseReplicationFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestSegmentsForReplicationFabricId(t *testing.T) { + segments := ReplicationFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationFabricId 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/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/id_replicationrecoveryservicesprovider.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/id_replicationrecoveryservicesprovider.go new file mode 100644 index 00000000000..9cba3d8c658 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/id_replicationrecoveryservicesprovider.go @@ -0,0 +1,148 @@ +package replicationrecoveryservicesproviders + +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(&ReplicationRecoveryServicesProviderId{}) +} + +var _ resourceids.ResourceId = &ReplicationRecoveryServicesProviderId{} + +// ReplicationRecoveryServicesProviderId is a struct representing the Resource ID for a Replication Recovery Services Provider +type ReplicationRecoveryServicesProviderId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationRecoveryServicesProviderName string +} + +// NewReplicationRecoveryServicesProviderID returns a new ReplicationRecoveryServicesProviderId struct +func NewReplicationRecoveryServicesProviderID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationRecoveryServicesProviderName string) ReplicationRecoveryServicesProviderId { + return ReplicationRecoveryServicesProviderId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationRecoveryServicesProviderName: replicationRecoveryServicesProviderName, + } +} + +// ParseReplicationRecoveryServicesProviderID parses 'input' into a ReplicationRecoveryServicesProviderId +func ParseReplicationRecoveryServicesProviderID(input string) (*ReplicationRecoveryServicesProviderId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationRecoveryServicesProviderId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationRecoveryServicesProviderId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationRecoveryServicesProviderIDInsensitively parses 'input' case-insensitively into a ReplicationRecoveryServicesProviderId +// note: this method should only be used for API response data and not user input +func ParseReplicationRecoveryServicesProviderIDInsensitively(input string) (*ReplicationRecoveryServicesProviderId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationRecoveryServicesProviderId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationRecoveryServicesProviderId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationRecoveryServicesProviderId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationRecoveryServicesProviderName, ok = input.Parsed["replicationRecoveryServicesProviderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationRecoveryServicesProviderName", input) + } + + return nil +} + +// ValidateReplicationRecoveryServicesProviderID checks that 'input' can be parsed as a Replication Recovery Services Provider ID +func ValidateReplicationRecoveryServicesProviderID(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 := ParseReplicationRecoveryServicesProviderID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Recovery Services Provider ID +func (id ReplicationRecoveryServicesProviderId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationRecoveryServicesProviders/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationRecoveryServicesProviderName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Recovery Services Provider ID +func (id ReplicationRecoveryServicesProviderId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationRecoveryServicesProviders", "replicationRecoveryServicesProviders", "replicationRecoveryServicesProviders"), + resourceids.UserSpecifiedSegment("replicationRecoveryServicesProviderName", "replicationRecoveryServicesProviderName"), + } +} + +// String returns a human-readable description of this Replication Recovery Services Provider ID +func (id ReplicationRecoveryServicesProviderId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Recovery Services Provider Name: %q", id.ReplicationRecoveryServicesProviderName), + } + return fmt.Sprintf("Replication Recovery Services Provider (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/id_replicationrecoveryservicesprovider_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/id_replicationrecoveryservicesprovider_test.go new file mode 100644 index 00000000000..330064d9655 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/id_replicationrecoveryservicesprovider_test.go @@ -0,0 +1,372 @@ +package replicationrecoveryservicesproviders + +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 = &ReplicationRecoveryServicesProviderId{} + +func TestNewReplicationRecoveryServicesProviderID(t *testing.T) { + id := NewReplicationRecoveryServicesProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationRecoveryServicesProviderName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationRecoveryServicesProviderName != "replicationRecoveryServicesProviderName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationRecoveryServicesProviderName'", id.ReplicationRecoveryServicesProviderName, "replicationRecoveryServicesProviderName") + } +} + +func TestFormatReplicationRecoveryServicesProviderID(t *testing.T) { + actual := NewReplicationRecoveryServicesProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationRecoveryServicesProviderName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationRecoveryServicesProviders/replicationRecoveryServicesProviderName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationRecoveryServicesProviderID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationRecoveryServicesProviderId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationRecoveryServicesProviders", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationRecoveryServicesProviders/replicationRecoveryServicesProviderName", + Expected: &ReplicationRecoveryServicesProviderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationRecoveryServicesProviderName: "replicationRecoveryServicesProviderName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationRecoveryServicesProviders/replicationRecoveryServicesProviderName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationRecoveryServicesProviderID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationRecoveryServicesProviderName != v.Expected.ReplicationRecoveryServicesProviderName { + t.Fatalf("Expected %q but got %q for ReplicationRecoveryServicesProviderName", v.Expected.ReplicationRecoveryServicesProviderName, actual.ReplicationRecoveryServicesProviderName) + } + + } +} + +func TestParseReplicationRecoveryServicesProviderIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationRecoveryServicesProviderId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationRecoveryServicesProviders", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnReCoVeRySeRvIcEsPrOvIdErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationRecoveryServicesProviders/replicationRecoveryServicesProviderName", + Expected: &ReplicationRecoveryServicesProviderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationRecoveryServicesProviderName: "replicationRecoveryServicesProviderName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationRecoveryServicesProviders/replicationRecoveryServicesProviderName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnReCoVeRySeRvIcEsPrOvIdErS/rEpLiCaTiOnReCoVeRySeRvIcEsPrOvIdErNaMe", + Expected: &ReplicationRecoveryServicesProviderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationRecoveryServicesProviderName: "rEpLiCaTiOnReCoVeRySeRvIcEsPrOvIdErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnReCoVeRySeRvIcEsPrOvIdErS/rEpLiCaTiOnReCoVeRySeRvIcEsPrOvIdErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationRecoveryServicesProviderIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationRecoveryServicesProviderName != v.Expected.ReplicationRecoveryServicesProviderName { + t.Fatalf("Expected %q but got %q for ReplicationRecoveryServicesProviderName", v.Expected.ReplicationRecoveryServicesProviderName, actual.ReplicationRecoveryServicesProviderName) + } + + } +} + +func TestSegmentsForReplicationRecoveryServicesProviderId(t *testing.T) { + segments := ReplicationRecoveryServicesProviderId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationRecoveryServicesProviderId 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/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/id_vault.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/id_vault.go new file mode 100644 index 00000000000..e0624e18242 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/id_vault.go @@ -0,0 +1,130 @@ +package replicationrecoveryservicesproviders + +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(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(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 := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/id_vault_test.go new file mode 100644 index 00000000000..bd041b99e7c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationrecoveryservicesproviders + +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 = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId 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/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/method_create.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/method_create.go new file mode 100644 index 00000000000..d703662cb7a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/method_create.go @@ -0,0 +1,75 @@ +package replicationrecoveryservicesproviders + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryServicesProvider +} + +// Create ... +func (c ReplicationRecoveryServicesProvidersClient) Create(ctx context.Context, id ReplicationRecoveryServicesProviderId, input AddRecoveryServicesProviderInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationRecoveryServicesProvidersClient) CreateThenPoll(ctx context.Context, id ReplicationRecoveryServicesProviderId, input AddRecoveryServicesProviderInput) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/method_delete.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/method_delete.go new file mode 100644 index 00000000000..d415ca70852 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/method_delete.go @@ -0,0 +1,70 @@ +package replicationrecoveryservicesproviders + +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 ReplicationRecoveryServicesProvidersClient) Delete(ctx context.Context, id ReplicationRecoveryServicesProviderId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/remove", 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 ReplicationRecoveryServicesProvidersClient) DeleteThenPoll(ctx context.Context, id ReplicationRecoveryServicesProviderId) 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/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/method_get.go new file mode 100644 index 00000000000..608e93729f9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/method_get.go @@ -0,0 +1,53 @@ +package replicationrecoveryservicesproviders + +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 *RecoveryServicesProvider +} + +// Get ... +func (c ReplicationRecoveryServicesProvidersClient) Get(ctx context.Context, id ReplicationRecoveryServicesProviderId) (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 RecoveryServicesProvider + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/method_list.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/method_list.go new file mode 100644 index 00000000000..9f87fd102aa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/method_list.go @@ -0,0 +1,105 @@ +package replicationrecoveryservicesproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RecoveryServicesProvider +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RecoveryServicesProvider +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ReplicationRecoveryServicesProvidersClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/replicationRecoveryServicesProviders", 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 *[]RecoveryServicesProvider `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationRecoveryServicesProvidersClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, RecoveryServicesProviderOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationRecoveryServicesProvidersClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate RecoveryServicesProviderOperationPredicate) (result ListCompleteResult, err error) { + items := make([]RecoveryServicesProvider, 0) + + resp, err := c.List(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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/method_listbyreplicationfabrics.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/method_listbyreplicationfabrics.go new file mode 100644 index 00000000000..2acfd3b73c2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/method_listbyreplicationfabrics.go @@ -0,0 +1,105 @@ +package replicationrecoveryservicesproviders + +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 ListByReplicationFabricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RecoveryServicesProvider +} + +type ListByReplicationFabricsCompleteResult struct { + LatestHttpResponse *http.Response + Items []RecoveryServicesProvider +} + +type ListByReplicationFabricsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationFabricsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationFabrics ... +func (c ReplicationRecoveryServicesProvidersClient) ListByReplicationFabrics(ctx context.Context, id ReplicationFabricId) (result ListByReplicationFabricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationFabricsCustomPager{}, + Path: fmt.Sprintf("%s/replicationRecoveryServicesProviders", 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 *[]RecoveryServicesProvider `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationFabricsComplete retrieves all the results into a single object +func (c ReplicationRecoveryServicesProvidersClient) ListByReplicationFabricsComplete(ctx context.Context, id ReplicationFabricId) (ListByReplicationFabricsCompleteResult, error) { + return c.ListByReplicationFabricsCompleteMatchingPredicate(ctx, id, RecoveryServicesProviderOperationPredicate{}) +} + +// ListByReplicationFabricsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationRecoveryServicesProvidersClient) ListByReplicationFabricsCompleteMatchingPredicate(ctx context.Context, id ReplicationFabricId, predicate RecoveryServicesProviderOperationPredicate) (result ListByReplicationFabricsCompleteResult, err error) { + items := make([]RecoveryServicesProvider, 0) + + resp, err := c.ListByReplicationFabrics(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 = ListByReplicationFabricsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/method_purge.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/method_purge.go new file mode 100644 index 00000000000..769e022934f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/method_purge.go @@ -0,0 +1,70 @@ +package replicationrecoveryservicesproviders + +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 PurgeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Purge ... +func (c ReplicationRecoveryServicesProvidersClient) Purge(ctx context.Context, id ReplicationRecoveryServicesProviderId) (result PurgeOperationResponse, 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 +} + +// PurgeThenPoll performs Purge then polls until it's completed +func (c ReplicationRecoveryServicesProvidersClient) PurgeThenPoll(ctx context.Context, id ReplicationRecoveryServicesProviderId) error { + result, err := c.Purge(ctx, id) + if err != nil { + return fmt.Errorf("performing Purge: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Purge: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/method_refreshprovider.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/method_refreshprovider.go new file mode 100644 index 00000000000..ccbc812c22a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/method_refreshprovider.go @@ -0,0 +1,71 @@ +package replicationrecoveryservicesproviders + +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 RefreshProviderOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryServicesProvider +} + +// RefreshProvider ... +func (c ReplicationRecoveryServicesProvidersClient) RefreshProvider(ctx context.Context, id ReplicationRecoveryServicesProviderId) (result RefreshProviderOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/refreshProvider", 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 +} + +// RefreshProviderThenPoll performs RefreshProvider then polls until it's completed +func (c ReplicationRecoveryServicesProvidersClient) RefreshProviderThenPoll(ctx context.Context, id ReplicationRecoveryServicesProviderId) error { + result, err := c.RefreshProvider(ctx, id) + if err != nil { + return fmt.Errorf("performing RefreshProvider: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RefreshProvider: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_addrecoveryservicesproviderinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_addrecoveryservicesproviderinput.go new file mode 100644 index 00000000000..2c945e24875 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_addrecoveryservicesproviderinput.go @@ -0,0 +1,8 @@ +package replicationrecoveryservicesproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddRecoveryServicesProviderInput struct { + Properties AddRecoveryServicesProviderInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_addrecoveryservicesproviderinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_addrecoveryservicesproviderinputproperties.go new file mode 100644 index 00000000000..9562bac2653 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_addrecoveryservicesproviderinputproperties.go @@ -0,0 +1,13 @@ +package replicationrecoveryservicesproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddRecoveryServicesProviderInputProperties struct { + AuthenticationIdentityInput IdentityProviderInput `json:"authenticationIdentityInput"` + BiosId *string `json:"biosId,omitempty"` + DataPlaneAuthenticationIdentityInput *IdentityProviderInput `json:"dataPlaneAuthenticationIdentityInput,omitempty"` + MachineId *string `json:"machineId,omitempty"` + MachineName string `json:"machineName"` + ResourceAccessIdentityInput IdentityProviderInput `json:"resourceAccessIdentityInput"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_healtherror.go new file mode 100644 index 00000000000..b0c92df9ee5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationrecoveryservicesproviders + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_identityproviderdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_identityproviderdetails.go new file mode 100644 index 00000000000..ab5ea5efed4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_identityproviderdetails.go @@ -0,0 +1,12 @@ +package replicationrecoveryservicesproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityProviderDetails struct { + AadAuthority *string `json:"aadAuthority,omitempty"` + ApplicationId *string `json:"applicationId,omitempty"` + Audience *string `json:"audience,omitempty"` + ObjectId *string `json:"objectId,omitempty"` + TenantId *string `json:"tenantId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_identityproviderinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_identityproviderinput.go new file mode 100644 index 00000000000..df9e5c5085d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_identityproviderinput.go @@ -0,0 +1,12 @@ +package replicationrecoveryservicesproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityProviderInput struct { + AadAuthority string `json:"aadAuthority"` + ApplicationId string `json:"applicationId"` + Audience string `json:"audience"` + ObjectId string `json:"objectId"` + TenantId string `json:"tenantId"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_innerhealtherror.go new file mode 100644 index 00000000000..3ef08acf21c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationrecoveryservicesproviders + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_recoveryservicesprovider.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_recoveryservicesprovider.go new file mode 100644 index 00000000000..8b870a59529 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_recoveryservicesprovider.go @@ -0,0 +1,12 @@ +package replicationrecoveryservicesproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryServicesProvider struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RecoveryServicesProviderProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_recoveryservicesproviderproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_recoveryservicesproviderproperties.go new file mode 100644 index 00000000000..db54434b901 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_recoveryservicesproviderproperties.go @@ -0,0 +1,57 @@ +package replicationrecoveryservicesproviders + +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 RecoveryServicesProviderProperties struct { + AllowedScenarios *[]string `json:"allowedScenarios,omitempty"` + AuthenticationIdentityDetails *IdentityProviderDetails `json:"authenticationIdentityDetails,omitempty"` + BiosId *string `json:"biosId,omitempty"` + ConnectionStatus *string `json:"connectionStatus,omitempty"` + DataPlaneAuthenticationIdentityDetails *IdentityProviderDetails `json:"dataPlaneAuthenticationIdentityDetails,omitempty"` + DraIdentifier *string `json:"draIdentifier,omitempty"` + FabricFriendlyName *string `json:"fabricFriendlyName,omitempty"` + FabricType *string `json:"fabricType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthErrorDetails *[]HealthError `json:"healthErrorDetails,omitempty"` + LastHeartBeat *string `json:"lastHeartBeat,omitempty"` + MachineId *string `json:"machineId,omitempty"` + MachineName *string `json:"machineName,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + ProviderVersion *string `json:"providerVersion,omitempty"` + ProviderVersionDetails *VersionDetails `json:"providerVersionDetails,omitempty"` + ProviderVersionExpiryDate *string `json:"providerVersionExpiryDate,omitempty"` + ProviderVersionState *string `json:"providerVersionState,omitempty"` + ResourceAccessIdentityDetails *IdentityProviderDetails `json:"resourceAccessIdentityDetails,omitempty"` + ServerVersion *string `json:"serverVersion,omitempty"` +} + +func (o *RecoveryServicesProviderProperties) GetLastHeartBeatAsTime() (*time.Time, error) { + if o.LastHeartBeat == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartBeat, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryServicesProviderProperties) SetLastHeartBeatAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartBeat = &formatted +} + +func (o *RecoveryServicesProviderProperties) GetProviderVersionExpiryDateAsTime() (*time.Time, error) { + if o.ProviderVersionExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ProviderVersionExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryServicesProviderProperties) SetProviderVersionExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ProviderVersionExpiryDate = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_versiondetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_versiondetails.go new file mode 100644 index 00000000000..9a441abb5ca --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/model_versiondetails.go @@ -0,0 +1,28 @@ +package replicationrecoveryservicesproviders + +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 VersionDetails struct { + ExpiryDate *string `json:"expiryDate,omitempty"` + Status *AgentVersionStatus `json:"status,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *VersionDetails) GetExpiryDateAsTime() (*time.Time, error) { + if o.ExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *VersionDetails) SetExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiryDate = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/predicates.go new file mode 100644 index 00000000000..4377b19a42f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/predicates.go @@ -0,0 +1,32 @@ +package replicationrecoveryservicesproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryServicesProviderOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p RecoveryServicesProviderOperationPredicate) Matches(input RecoveryServicesProvider) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/version.go new file mode 100644 index 00000000000..d9960baed0c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationrecoveryservicesproviders/version.go @@ -0,0 +1,10 @@ +package replicationrecoveryservicesproviders + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationrecoveryservicesproviders/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/README.md new file mode 100644 index 00000000000..1bb3fbde019 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/README.md @@ -0,0 +1,99 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings` Documentation + +The `replicationstorageclassificationmappings` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings" +``` + + +### Client Initialization + +```go +client := replicationstorageclassificationmappings.NewReplicationStorageClassificationMappingsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationStorageClassificationMappingsClient.Create` + +```go +ctx := context.TODO() +id := replicationstorageclassificationmappings.NewReplicationStorageClassificationMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationStorageClassificationName", "replicationStorageClassificationMappingName") + +payload := replicationstorageclassificationmappings.StorageClassificationMappingInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationStorageClassificationMappingsClient.Delete` + +```go +ctx := context.TODO() +id := replicationstorageclassificationmappings.NewReplicationStorageClassificationMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationStorageClassificationName", "replicationStorageClassificationMappingName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationStorageClassificationMappingsClient.Get` + +```go +ctx := context.TODO() +id := replicationstorageclassificationmappings.NewReplicationStorageClassificationMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationStorageClassificationName", "replicationStorageClassificationMappingName") + +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: `ReplicationStorageClassificationMappingsClient.List` + +```go +ctx := context.TODO() +id := replicationstorageclassificationmappings.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationStorageClassificationMappingsClient.ListByReplicationStorageClassifications` + +```go +ctx := context.TODO() +id := replicationstorageclassificationmappings.NewReplicationStorageClassificationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationStorageClassificationName") + +// alternatively `client.ListByReplicationStorageClassifications(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationStorageClassificationsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/client.go new file mode 100644 index 00000000000..a92438ccd25 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/client.go @@ -0,0 +1,26 @@ +package replicationstorageclassificationmappings + +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 ReplicationStorageClassificationMappingsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationStorageClassificationMappingsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationStorageClassificationMappingsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationstorageclassificationmappings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationStorageClassificationMappingsClient: %+v", err) + } + + return &ReplicationStorageClassificationMappingsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/id_replicationstorageclassification.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/id_replicationstorageclassification.go new file mode 100644 index 00000000000..6153e2573af --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/id_replicationstorageclassification.go @@ -0,0 +1,148 @@ +package replicationstorageclassificationmappings + +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(&ReplicationStorageClassificationId{}) +} + +var _ resourceids.ResourceId = &ReplicationStorageClassificationId{} + +// ReplicationStorageClassificationId is a struct representing the Resource ID for a Replication Storage Classification +type ReplicationStorageClassificationId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationStorageClassificationName string +} + +// NewReplicationStorageClassificationID returns a new ReplicationStorageClassificationId struct +func NewReplicationStorageClassificationID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationStorageClassificationName string) ReplicationStorageClassificationId { + return ReplicationStorageClassificationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationStorageClassificationName: replicationStorageClassificationName, + } +} + +// ParseReplicationStorageClassificationID parses 'input' into a ReplicationStorageClassificationId +func ParseReplicationStorageClassificationID(input string) (*ReplicationStorageClassificationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationStorageClassificationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationStorageClassificationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationStorageClassificationIDInsensitively parses 'input' case-insensitively into a ReplicationStorageClassificationId +// note: this method should only be used for API response data and not user input +func ParseReplicationStorageClassificationIDInsensitively(input string) (*ReplicationStorageClassificationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationStorageClassificationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationStorageClassificationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationStorageClassificationId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationStorageClassificationName, ok = input.Parsed["replicationStorageClassificationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationStorageClassificationName", input) + } + + return nil +} + +// ValidateReplicationStorageClassificationID checks that 'input' can be parsed as a Replication Storage Classification ID +func ValidateReplicationStorageClassificationID(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 := ParseReplicationStorageClassificationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Storage Classification ID +func (id ReplicationStorageClassificationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationStorageClassifications/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationStorageClassificationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Storage Classification ID +func (id ReplicationStorageClassificationId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationStorageClassifications", "replicationStorageClassifications", "replicationStorageClassifications"), + resourceids.UserSpecifiedSegment("replicationStorageClassificationName", "replicationStorageClassificationName"), + } +} + +// String returns a human-readable description of this Replication Storage Classification ID +func (id ReplicationStorageClassificationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Storage Classification Name: %q", id.ReplicationStorageClassificationName), + } + return fmt.Sprintf("Replication Storage Classification (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/id_replicationstorageclassification_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/id_replicationstorageclassification_test.go new file mode 100644 index 00000000000..93419cf7b07 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/id_replicationstorageclassification_test.go @@ -0,0 +1,372 @@ +package replicationstorageclassificationmappings + +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 = &ReplicationStorageClassificationId{} + +func TestNewReplicationStorageClassificationID(t *testing.T) { + id := NewReplicationStorageClassificationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationStorageClassificationName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationStorageClassificationName != "replicationStorageClassificationName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationStorageClassificationName'", id.ReplicationStorageClassificationName, "replicationStorageClassificationName") + } +} + +func TestFormatReplicationStorageClassificationID(t *testing.T) { + actual := NewReplicationStorageClassificationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationStorageClassificationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationStorageClassificationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationStorageClassificationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName", + Expected: &ReplicationStorageClassificationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationStorageClassificationName: "replicationStorageClassificationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationStorageClassificationID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationStorageClassificationName != v.Expected.ReplicationStorageClassificationName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationName", v.Expected.ReplicationStorageClassificationName, actual.ReplicationStorageClassificationName) + } + + } +} + +func TestParseReplicationStorageClassificationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationStorageClassificationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName", + Expected: &ReplicationStorageClassificationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationStorageClassificationName: "replicationStorageClassificationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNnAmE", + Expected: &ReplicationStorageClassificationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationStorageClassificationName: "rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationStorageClassificationIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationStorageClassificationName != v.Expected.ReplicationStorageClassificationName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationName", v.Expected.ReplicationStorageClassificationName, actual.ReplicationStorageClassificationName) + } + + } +} + +func TestSegmentsForReplicationStorageClassificationId(t *testing.T) { + segments := ReplicationStorageClassificationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationStorageClassificationId 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/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/id_replicationstorageclassificationmapping.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/id_replicationstorageclassificationmapping.go new file mode 100644 index 00000000000..35968166e9f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/id_replicationstorageclassificationmapping.go @@ -0,0 +1,157 @@ +package replicationstorageclassificationmappings + +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(&ReplicationStorageClassificationMappingId{}) +} + +var _ resourceids.ResourceId = &ReplicationStorageClassificationMappingId{} + +// ReplicationStorageClassificationMappingId is a struct representing the Resource ID for a Replication Storage Classification Mapping +type ReplicationStorageClassificationMappingId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationStorageClassificationName string + ReplicationStorageClassificationMappingName string +} + +// NewReplicationStorageClassificationMappingID returns a new ReplicationStorageClassificationMappingId struct +func NewReplicationStorageClassificationMappingID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationStorageClassificationName string, replicationStorageClassificationMappingName string) ReplicationStorageClassificationMappingId { + return ReplicationStorageClassificationMappingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationStorageClassificationName: replicationStorageClassificationName, + ReplicationStorageClassificationMappingName: replicationStorageClassificationMappingName, + } +} + +// ParseReplicationStorageClassificationMappingID parses 'input' into a ReplicationStorageClassificationMappingId +func ParseReplicationStorageClassificationMappingID(input string) (*ReplicationStorageClassificationMappingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationStorageClassificationMappingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationStorageClassificationMappingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationStorageClassificationMappingIDInsensitively parses 'input' case-insensitively into a ReplicationStorageClassificationMappingId +// note: this method should only be used for API response data and not user input +func ParseReplicationStorageClassificationMappingIDInsensitively(input string) (*ReplicationStorageClassificationMappingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationStorageClassificationMappingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationStorageClassificationMappingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationStorageClassificationMappingId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationStorageClassificationName, ok = input.Parsed["replicationStorageClassificationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationStorageClassificationName", input) + } + + if id.ReplicationStorageClassificationMappingName, ok = input.Parsed["replicationStorageClassificationMappingName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationStorageClassificationMappingName", input) + } + + return nil +} + +// ValidateReplicationStorageClassificationMappingID checks that 'input' can be parsed as a Replication Storage Classification Mapping ID +func ValidateReplicationStorageClassificationMappingID(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 := ParseReplicationStorageClassificationMappingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Storage Classification Mapping ID +func (id ReplicationStorageClassificationMappingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationStorageClassifications/%s/replicationStorageClassificationMappings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationStorageClassificationName, id.ReplicationStorageClassificationMappingName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Storage Classification Mapping ID +func (id ReplicationStorageClassificationMappingId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationStorageClassifications", "replicationStorageClassifications", "replicationStorageClassifications"), + resourceids.UserSpecifiedSegment("replicationStorageClassificationName", "replicationStorageClassificationName"), + resourceids.StaticSegment("staticReplicationStorageClassificationMappings", "replicationStorageClassificationMappings", "replicationStorageClassificationMappings"), + resourceids.UserSpecifiedSegment("replicationStorageClassificationMappingName", "replicationStorageClassificationMappingName"), + } +} + +// String returns a human-readable description of this Replication Storage Classification Mapping ID +func (id ReplicationStorageClassificationMappingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Storage Classification Name: %q", id.ReplicationStorageClassificationName), + fmt.Sprintf("Replication Storage Classification Mapping Name: %q", id.ReplicationStorageClassificationMappingName), + } + return fmt.Sprintf("Replication Storage Classification Mapping (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/id_replicationstorageclassificationmapping_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/id_replicationstorageclassificationmapping_test.go new file mode 100644 index 00000000000..83299d4dc83 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/id_replicationstorageclassificationmapping_test.go @@ -0,0 +1,417 @@ +package replicationstorageclassificationmappings + +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 = &ReplicationStorageClassificationMappingId{} + +func TestNewReplicationStorageClassificationMappingID(t *testing.T) { + id := NewReplicationStorageClassificationMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationStorageClassificationName", "replicationStorageClassificationMappingName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationStorageClassificationName != "replicationStorageClassificationName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationStorageClassificationName'", id.ReplicationStorageClassificationName, "replicationStorageClassificationName") + } + + if id.ReplicationStorageClassificationMappingName != "replicationStorageClassificationMappingName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationStorageClassificationMappingName'", id.ReplicationStorageClassificationMappingName, "replicationStorageClassificationMappingName") + } +} + +func TestFormatReplicationStorageClassificationMappingID(t *testing.T) { + actual := NewReplicationStorageClassificationMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationStorageClassificationName", "replicationStorageClassificationMappingName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName/replicationStorageClassificationMappings/replicationStorageClassificationMappingName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationStorageClassificationMappingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationStorageClassificationMappingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName/replicationStorageClassificationMappings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName/replicationStorageClassificationMappings/replicationStorageClassificationMappingName", + Expected: &ReplicationStorageClassificationMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationStorageClassificationName: "replicationStorageClassificationName", + ReplicationStorageClassificationMappingName: "replicationStorageClassificationMappingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName/replicationStorageClassificationMappings/replicationStorageClassificationMappingName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationStorageClassificationMappingID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationStorageClassificationName != v.Expected.ReplicationStorageClassificationName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationName", v.Expected.ReplicationStorageClassificationName, actual.ReplicationStorageClassificationName) + } + + if actual.ReplicationStorageClassificationMappingName != v.Expected.ReplicationStorageClassificationMappingName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationMappingName", v.Expected.ReplicationStorageClassificationMappingName, actual.ReplicationStorageClassificationMappingName) + } + + } +} + +func TestParseReplicationStorageClassificationMappingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationStorageClassificationMappingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName/replicationStorageClassificationMappings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNnAmE/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNmApPiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName/replicationStorageClassificationMappings/replicationStorageClassificationMappingName", + Expected: &ReplicationStorageClassificationMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationStorageClassificationName: "replicationStorageClassificationName", + ReplicationStorageClassificationMappingName: "replicationStorageClassificationMappingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName/replicationStorageClassificationMappings/replicationStorageClassificationMappingName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNnAmE/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNmApPiNgS/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNmApPiNgNaMe", + Expected: &ReplicationStorageClassificationMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationStorageClassificationName: "rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNnAmE", + ReplicationStorageClassificationMappingName: "rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNmApPiNgNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNnAmE/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNmApPiNgS/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNmApPiNgNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationStorageClassificationMappingIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationStorageClassificationName != v.Expected.ReplicationStorageClassificationName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationName", v.Expected.ReplicationStorageClassificationName, actual.ReplicationStorageClassificationName) + } + + if actual.ReplicationStorageClassificationMappingName != v.Expected.ReplicationStorageClassificationMappingName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationMappingName", v.Expected.ReplicationStorageClassificationMappingName, actual.ReplicationStorageClassificationMappingName) + } + + } +} + +func TestSegmentsForReplicationStorageClassificationMappingId(t *testing.T) { + segments := ReplicationStorageClassificationMappingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationStorageClassificationMappingId 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/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/id_vault.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/id_vault.go new file mode 100644 index 00000000000..e792b2e3f57 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/id_vault.go @@ -0,0 +1,130 @@ +package replicationstorageclassificationmappings + +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(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(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 := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/id_vault_test.go new file mode 100644 index 00000000000..fc6942dc1c9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationstorageclassificationmappings + +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 = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId 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/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/method_create.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/method_create.go new file mode 100644 index 00000000000..f295340750d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/method_create.go @@ -0,0 +1,75 @@ +package replicationstorageclassificationmappings + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StorageClassificationMapping +} + +// Create ... +func (c ReplicationStorageClassificationMappingsClient) Create(ctx context.Context, id ReplicationStorageClassificationMappingId, input StorageClassificationMappingInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationStorageClassificationMappingsClient) CreateThenPoll(ctx context.Context, id ReplicationStorageClassificationMappingId, input StorageClassificationMappingInput) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/method_delete.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/method_delete.go new file mode 100644 index 00000000000..cced683f6b0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/method_delete.go @@ -0,0 +1,70 @@ +package replicationstorageclassificationmappings + +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 ReplicationStorageClassificationMappingsClient) Delete(ctx context.Context, id ReplicationStorageClassificationMappingId) (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 ReplicationStorageClassificationMappingsClient) DeleteThenPoll(ctx context.Context, id ReplicationStorageClassificationMappingId) 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/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/method_get.go new file mode 100644 index 00000000000..dfa92e4c832 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/method_get.go @@ -0,0 +1,53 @@ +package replicationstorageclassificationmappings + +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 *StorageClassificationMapping +} + +// Get ... +func (c ReplicationStorageClassificationMappingsClient) Get(ctx context.Context, id ReplicationStorageClassificationMappingId) (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 StorageClassificationMapping + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/method_list.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/method_list.go new file mode 100644 index 00000000000..33b89316ca5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/method_list.go @@ -0,0 +1,105 @@ +package replicationstorageclassificationmappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StorageClassificationMapping +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []StorageClassificationMapping +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ReplicationStorageClassificationMappingsClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/replicationStorageClassificationMappings", 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 *[]StorageClassificationMapping `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationStorageClassificationMappingsClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, StorageClassificationMappingOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationStorageClassificationMappingsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate StorageClassificationMappingOperationPredicate) (result ListCompleteResult, err error) { + items := make([]StorageClassificationMapping, 0) + + resp, err := c.List(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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/method_listbyreplicationstorageclassifications.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/method_listbyreplicationstorageclassifications.go new file mode 100644 index 00000000000..17f056a2737 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/method_listbyreplicationstorageclassifications.go @@ -0,0 +1,105 @@ +package replicationstorageclassificationmappings + +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 ListByReplicationStorageClassificationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StorageClassificationMapping +} + +type ListByReplicationStorageClassificationsCompleteResult struct { + LatestHttpResponse *http.Response + Items []StorageClassificationMapping +} + +type ListByReplicationStorageClassificationsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationStorageClassificationsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationStorageClassifications ... +func (c ReplicationStorageClassificationMappingsClient) ListByReplicationStorageClassifications(ctx context.Context, id ReplicationStorageClassificationId) (result ListByReplicationStorageClassificationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationStorageClassificationsCustomPager{}, + Path: fmt.Sprintf("%s/replicationStorageClassificationMappings", 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 *[]StorageClassificationMapping `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationStorageClassificationsComplete retrieves all the results into a single object +func (c ReplicationStorageClassificationMappingsClient) ListByReplicationStorageClassificationsComplete(ctx context.Context, id ReplicationStorageClassificationId) (ListByReplicationStorageClassificationsCompleteResult, error) { + return c.ListByReplicationStorageClassificationsCompleteMatchingPredicate(ctx, id, StorageClassificationMappingOperationPredicate{}) +} + +// ListByReplicationStorageClassificationsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationStorageClassificationMappingsClient) ListByReplicationStorageClassificationsCompleteMatchingPredicate(ctx context.Context, id ReplicationStorageClassificationId, predicate StorageClassificationMappingOperationPredicate) (result ListByReplicationStorageClassificationsCompleteResult, err error) { + items := make([]StorageClassificationMapping, 0) + + resp, err := c.ListByReplicationStorageClassifications(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 = ListByReplicationStorageClassificationsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/model_storageclassificationmapping.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/model_storageclassificationmapping.go new file mode 100644 index 00000000000..70642e74bca --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/model_storageclassificationmapping.go @@ -0,0 +1,12 @@ +package replicationstorageclassificationmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageClassificationMapping struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StorageClassificationMappingProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/model_storageclassificationmappinginput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/model_storageclassificationmappinginput.go new file mode 100644 index 00000000000..158940ea210 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/model_storageclassificationmappinginput.go @@ -0,0 +1,8 @@ +package replicationstorageclassificationmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageClassificationMappingInput struct { + Properties *StorageMappingInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/model_storageclassificationmappingproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/model_storageclassificationmappingproperties.go new file mode 100644 index 00000000000..0b0d8c58bea --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/model_storageclassificationmappingproperties.go @@ -0,0 +1,8 @@ +package replicationstorageclassificationmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageClassificationMappingProperties struct { + TargetStorageClassificationId *string `json:"targetStorageClassificationId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/model_storagemappinginputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/model_storagemappinginputproperties.go new file mode 100644 index 00000000000..7dc80064316 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/model_storagemappinginputproperties.go @@ -0,0 +1,8 @@ +package replicationstorageclassificationmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageMappingInputProperties struct { + TargetStorageClassificationId *string `json:"targetStorageClassificationId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/predicates.go new file mode 100644 index 00000000000..128f8cd8e3d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/predicates.go @@ -0,0 +1,32 @@ +package replicationstorageclassificationmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageClassificationMappingOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p StorageClassificationMappingOperationPredicate) Matches(input StorageClassificationMapping) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/version.go new file mode 100644 index 00000000000..cdb94960dfc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassificationmappings/version.go @@ -0,0 +1,10 @@ +package replicationstorageclassificationmappings + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationstorageclassificationmappings/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/README.md new file mode 100644 index 00000000000..e246eefcc61 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/README.md @@ -0,0 +1,70 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications` Documentation + +The `replicationstorageclassifications` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications" +``` + + +### Client Initialization + +```go +client := replicationstorageclassifications.NewReplicationStorageClassificationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationStorageClassificationsClient.Get` + +```go +ctx := context.TODO() +id := replicationstorageclassifications.NewReplicationStorageClassificationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationStorageClassificationName") + +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: `ReplicationStorageClassificationsClient.List` + +```go +ctx := context.TODO() +id := replicationstorageclassifications.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationStorageClassificationsClient.ListByReplicationFabrics` + +```go +ctx := context.TODO() +id := replicationstorageclassifications.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +// alternatively `client.ListByReplicationFabrics(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationFabricsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/client.go new file mode 100644 index 00000000000..15f7f47cdd1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/client.go @@ -0,0 +1,26 @@ +package replicationstorageclassifications + +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 ReplicationStorageClassificationsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationStorageClassificationsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationStorageClassificationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationstorageclassifications", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationStorageClassificationsClient: %+v", err) + } + + return &ReplicationStorageClassificationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/id_replicationfabric.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/id_replicationfabric.go new file mode 100644 index 00000000000..e2899f5fecb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/id_replicationfabric.go @@ -0,0 +1,139 @@ +package replicationstorageclassifications + +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(&ReplicationFabricId{}) +} + +var _ resourceids.ResourceId = &ReplicationFabricId{} + +// ReplicationFabricId is a struct representing the Resource ID for a Replication Fabric +type ReplicationFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string +} + +// NewReplicationFabricID returns a new ReplicationFabricId struct +func NewReplicationFabricID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string) ReplicationFabricId { + return ReplicationFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + } +} + +// ParseReplicationFabricID parses 'input' into a ReplicationFabricId +func ParseReplicationFabricID(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationFabricIDInsensitively parses 'input' case-insensitively into a ReplicationFabricId +// note: this method should only be used for API response data and not user input +func ParseReplicationFabricIDInsensitively(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationFabricId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + return nil +} + +// ValidateReplicationFabricID checks that 'input' can be parsed as a Replication Fabric ID +func ValidateReplicationFabricID(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 := ParseReplicationFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Fabric ID +func (id ReplicationFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Fabric ID +func (id ReplicationFabricId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + } +} + +// String returns a human-readable description of this Replication Fabric ID +func (id ReplicationFabricId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + } + return fmt.Sprintf("Replication Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/id_replicationfabric_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/id_replicationfabric_test.go new file mode 100644 index 00000000000..726bd85a5dc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/id_replicationfabric_test.go @@ -0,0 +1,327 @@ +package replicationstorageclassifications + +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 = &ReplicationFabricId{} + +func TestNewReplicationFabricID(t *testing.T) { + id := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } +} + +func TestFormatReplicationFabricID(t *testing.T) { + actual := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestParseReplicationFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestSegmentsForReplicationFabricId(t *testing.T) { + segments := ReplicationFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationFabricId 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/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/id_replicationstorageclassification.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/id_replicationstorageclassification.go new file mode 100644 index 00000000000..8e8996b47e8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/id_replicationstorageclassification.go @@ -0,0 +1,148 @@ +package replicationstorageclassifications + +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(&ReplicationStorageClassificationId{}) +} + +var _ resourceids.ResourceId = &ReplicationStorageClassificationId{} + +// ReplicationStorageClassificationId is a struct representing the Resource ID for a Replication Storage Classification +type ReplicationStorageClassificationId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationStorageClassificationName string +} + +// NewReplicationStorageClassificationID returns a new ReplicationStorageClassificationId struct +func NewReplicationStorageClassificationID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationStorageClassificationName string) ReplicationStorageClassificationId { + return ReplicationStorageClassificationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationStorageClassificationName: replicationStorageClassificationName, + } +} + +// ParseReplicationStorageClassificationID parses 'input' into a ReplicationStorageClassificationId +func ParseReplicationStorageClassificationID(input string) (*ReplicationStorageClassificationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationStorageClassificationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationStorageClassificationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationStorageClassificationIDInsensitively parses 'input' case-insensitively into a ReplicationStorageClassificationId +// note: this method should only be used for API response data and not user input +func ParseReplicationStorageClassificationIDInsensitively(input string) (*ReplicationStorageClassificationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationStorageClassificationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationStorageClassificationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationStorageClassificationId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationStorageClassificationName, ok = input.Parsed["replicationStorageClassificationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationStorageClassificationName", input) + } + + return nil +} + +// ValidateReplicationStorageClassificationID checks that 'input' can be parsed as a Replication Storage Classification ID +func ValidateReplicationStorageClassificationID(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 := ParseReplicationStorageClassificationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Storage Classification ID +func (id ReplicationStorageClassificationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationStorageClassifications/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationStorageClassificationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Storage Classification ID +func (id ReplicationStorageClassificationId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationStorageClassifications", "replicationStorageClassifications", "replicationStorageClassifications"), + resourceids.UserSpecifiedSegment("replicationStorageClassificationName", "replicationStorageClassificationName"), + } +} + +// String returns a human-readable description of this Replication Storage Classification ID +func (id ReplicationStorageClassificationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Storage Classification Name: %q", id.ReplicationStorageClassificationName), + } + return fmt.Sprintf("Replication Storage Classification (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/id_replicationstorageclassification_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/id_replicationstorageclassification_test.go new file mode 100644 index 00000000000..e66a6025f8c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/id_replicationstorageclassification_test.go @@ -0,0 +1,372 @@ +package replicationstorageclassifications + +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 = &ReplicationStorageClassificationId{} + +func TestNewReplicationStorageClassificationID(t *testing.T) { + id := NewReplicationStorageClassificationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationStorageClassificationName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationStorageClassificationName != "replicationStorageClassificationName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationStorageClassificationName'", id.ReplicationStorageClassificationName, "replicationStorageClassificationName") + } +} + +func TestFormatReplicationStorageClassificationID(t *testing.T) { + actual := NewReplicationStorageClassificationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationStorageClassificationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationStorageClassificationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationStorageClassificationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName", + Expected: &ReplicationStorageClassificationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationStorageClassificationName: "replicationStorageClassificationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationStorageClassificationID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationStorageClassificationName != v.Expected.ReplicationStorageClassificationName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationName", v.Expected.ReplicationStorageClassificationName, actual.ReplicationStorageClassificationName) + } + + } +} + +func TestParseReplicationStorageClassificationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationStorageClassificationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName", + Expected: &ReplicationStorageClassificationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationStorageClassificationName: "replicationStorageClassificationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNnAmE", + Expected: &ReplicationStorageClassificationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationStorageClassificationName: "rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationStorageClassificationIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationStorageClassificationName != v.Expected.ReplicationStorageClassificationName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationName", v.Expected.ReplicationStorageClassificationName, actual.ReplicationStorageClassificationName) + } + + } +} + +func TestSegmentsForReplicationStorageClassificationId(t *testing.T) { + segments := ReplicationStorageClassificationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationStorageClassificationId 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/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/id_vault.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/id_vault.go new file mode 100644 index 00000000000..e6e8ef1f8a7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/id_vault.go @@ -0,0 +1,130 @@ +package replicationstorageclassifications + +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(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(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 := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/id_vault_test.go new file mode 100644 index 00000000000..f166541032d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationstorageclassifications + +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 = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId 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/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/method_get.go new file mode 100644 index 00000000000..1a516c62385 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/method_get.go @@ -0,0 +1,53 @@ +package replicationstorageclassifications + +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 *StorageClassification +} + +// Get ... +func (c ReplicationStorageClassificationsClient) Get(ctx context.Context, id ReplicationStorageClassificationId) (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 StorageClassification + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/method_list.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/method_list.go new file mode 100644 index 00000000000..a2739887ea5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/method_list.go @@ -0,0 +1,105 @@ +package replicationstorageclassifications + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StorageClassification +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []StorageClassification +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ReplicationStorageClassificationsClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/replicationStorageClassifications", 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 *[]StorageClassification `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationStorageClassificationsClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, StorageClassificationOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationStorageClassificationsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate StorageClassificationOperationPredicate) (result ListCompleteResult, err error) { + items := make([]StorageClassification, 0) + + resp, err := c.List(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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/method_listbyreplicationfabrics.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/method_listbyreplicationfabrics.go new file mode 100644 index 00000000000..8d47b1ec523 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/method_listbyreplicationfabrics.go @@ -0,0 +1,105 @@ +package replicationstorageclassifications + +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 ListByReplicationFabricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StorageClassification +} + +type ListByReplicationFabricsCompleteResult struct { + LatestHttpResponse *http.Response + Items []StorageClassification +} + +type ListByReplicationFabricsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationFabricsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationFabrics ... +func (c ReplicationStorageClassificationsClient) ListByReplicationFabrics(ctx context.Context, id ReplicationFabricId) (result ListByReplicationFabricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationFabricsCustomPager{}, + Path: fmt.Sprintf("%s/replicationStorageClassifications", 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 *[]StorageClassification `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationFabricsComplete retrieves all the results into a single object +func (c ReplicationStorageClassificationsClient) ListByReplicationFabricsComplete(ctx context.Context, id ReplicationFabricId) (ListByReplicationFabricsCompleteResult, error) { + return c.ListByReplicationFabricsCompleteMatchingPredicate(ctx, id, StorageClassificationOperationPredicate{}) +} + +// ListByReplicationFabricsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationStorageClassificationsClient) ListByReplicationFabricsCompleteMatchingPredicate(ctx context.Context, id ReplicationFabricId, predicate StorageClassificationOperationPredicate) (result ListByReplicationFabricsCompleteResult, err error) { + items := make([]StorageClassification, 0) + + resp, err := c.ListByReplicationFabrics(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 = ListByReplicationFabricsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/model_storageclassification.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/model_storageclassification.go new file mode 100644 index 00000000000..dfe018bfb1c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/model_storageclassification.go @@ -0,0 +1,12 @@ +package replicationstorageclassifications + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageClassification struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StorageClassificationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/model_storageclassificationproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/model_storageclassificationproperties.go new file mode 100644 index 00000000000..1d077061afd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/model_storageclassificationproperties.go @@ -0,0 +1,8 @@ +package replicationstorageclassifications + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageClassificationProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/predicates.go new file mode 100644 index 00000000000..6fae7a2f37c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/predicates.go @@ -0,0 +1,32 @@ +package replicationstorageclassifications + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageClassificationOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p StorageClassificationOperationPredicate) Matches(input StorageClassification) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/version.go new file mode 100644 index 00000000000..41fcacb551d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationstorageclassifications/version.go @@ -0,0 +1,10 @@ +package replicationstorageclassifications + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationstorageclassifications/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/README.md new file mode 100644 index 00000000000..a07972b0ca3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/README.md @@ -0,0 +1,48 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth` Documentation + +The `replicationvaulthealth` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth" +``` + + +### Client Initialization + +```go +client := replicationvaulthealth.NewReplicationVaultHealthClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationVaultHealthClient.Get` + +```go +ctx := context.TODO() +id := replicationvaulthealth.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +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: `ReplicationVaultHealthClient.Refresh` + +```go +ctx := context.TODO() +id := replicationvaulthealth.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +if err := client.RefreshThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/client.go new file mode 100644 index 00000000000..65b02d6236f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/client.go @@ -0,0 +1,26 @@ +package replicationvaulthealth + +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 ReplicationVaultHealthClient struct { + Client *resourcemanager.Client +} + +func NewReplicationVaultHealthClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationVaultHealthClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationvaulthealth", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationVaultHealthClient: %+v", err) + } + + return &ReplicationVaultHealthClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/constants.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/constants.go new file mode 100644 index 00000000000..037b2d3c9ae --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/constants.go @@ -0,0 +1,166 @@ +package replicationvaulthealth + +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 HealthErrorCategory string + +const ( + HealthErrorCategoryAgentAutoUpdateArtifactDeleted HealthErrorCategory = "AgentAutoUpdateArtifactDeleted" + HealthErrorCategoryAgentAutoUpdateInfra HealthErrorCategory = "AgentAutoUpdateInfra" + HealthErrorCategoryAgentAutoUpdateRunAsAccount HealthErrorCategory = "AgentAutoUpdateRunAsAccount" + HealthErrorCategoryAgentAutoUpdateRunAsAccountExpired HealthErrorCategory = "AgentAutoUpdateRunAsAccountExpired" + HealthErrorCategoryAgentAutoUpdateRunAsAccountExpiry HealthErrorCategory = "AgentAutoUpdateRunAsAccountExpiry" + HealthErrorCategoryConfiguration HealthErrorCategory = "Configuration" + HealthErrorCategoryFabricInfrastructure HealthErrorCategory = "FabricInfrastructure" + HealthErrorCategoryNone HealthErrorCategory = "None" + HealthErrorCategoryReplication HealthErrorCategory = "Replication" + HealthErrorCategoryTestFailover HealthErrorCategory = "TestFailover" + HealthErrorCategoryVersionExpiry HealthErrorCategory = "VersionExpiry" +) + +func PossibleValuesForHealthErrorCategory() []string { + return []string{ + string(HealthErrorCategoryAgentAutoUpdateArtifactDeleted), + string(HealthErrorCategoryAgentAutoUpdateInfra), + string(HealthErrorCategoryAgentAutoUpdateRunAsAccount), + string(HealthErrorCategoryAgentAutoUpdateRunAsAccountExpired), + string(HealthErrorCategoryAgentAutoUpdateRunAsAccountExpiry), + string(HealthErrorCategoryConfiguration), + string(HealthErrorCategoryFabricInfrastructure), + string(HealthErrorCategoryNone), + string(HealthErrorCategoryReplication), + string(HealthErrorCategoryTestFailover), + string(HealthErrorCategoryVersionExpiry), + } +} + +func (s *HealthErrorCategory) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCategory(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCategory(input string) (*HealthErrorCategory, error) { + vals := map[string]HealthErrorCategory{ + "agentautoupdateartifactdeleted": HealthErrorCategoryAgentAutoUpdateArtifactDeleted, + "agentautoupdateinfra": HealthErrorCategoryAgentAutoUpdateInfra, + "agentautoupdaterunasaccount": HealthErrorCategoryAgentAutoUpdateRunAsAccount, + "agentautoupdaterunasaccountexpired": HealthErrorCategoryAgentAutoUpdateRunAsAccountExpired, + "agentautoupdaterunasaccountexpiry": HealthErrorCategoryAgentAutoUpdateRunAsAccountExpiry, + "configuration": HealthErrorCategoryConfiguration, + "fabricinfrastructure": HealthErrorCategoryFabricInfrastructure, + "none": HealthErrorCategoryNone, + "replication": HealthErrorCategoryReplication, + "testfailover": HealthErrorCategoryTestFailover, + "versionexpiry": HealthErrorCategoryVersionExpiry, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCategory(input) + return &out, nil +} + +type HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} + +type Severity string + +const ( + SeverityError Severity = "Error" + SeverityInfo Severity = "Info" + SeverityNONE Severity = "NONE" + SeverityWarning Severity = "Warning" +) + +func PossibleValuesForSeverity() []string { + return []string{ + string(SeverityError), + string(SeverityInfo), + string(SeverityNONE), + string(SeverityWarning), + } +} + +func (s *Severity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSeverity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSeverity(input string) (*Severity, error) { + vals := map[string]Severity{ + "error": SeverityError, + "info": SeverityInfo, + "none": SeverityNONE, + "warning": SeverityWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Severity(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/id_vault.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/id_vault.go new file mode 100644 index 00000000000..bfec839dc80 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/id_vault.go @@ -0,0 +1,130 @@ +package replicationvaulthealth + +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(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(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 := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/id_vault_test.go new file mode 100644 index 00000000000..1eed0241695 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationvaulthealth + +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 = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId 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/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/method_get.go new file mode 100644 index 00000000000..99edaf64697 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/method_get.go @@ -0,0 +1,54 @@ +package replicationvaulthealth + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VaultHealthDetails +} + +// Get ... +func (c ReplicationVaultHealthClient) Get(ctx context.Context, id VaultId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationVaultHealth", 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 VaultHealthDetails + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/method_refresh.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/method_refresh.go new file mode 100644 index 00000000000..17fd7e306a1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/method_refresh.go @@ -0,0 +1,71 @@ +package replicationvaulthealth + +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 RefreshOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VaultHealthDetails +} + +// Refresh ... +func (c ReplicationVaultHealthClient) Refresh(ctx context.Context, id VaultId) (result RefreshOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/replicationVaultHealth/default/refresh", 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 +} + +// RefreshThenPoll performs Refresh then polls until it's completed +func (c ReplicationVaultHealthClient) RefreshThenPoll(ctx context.Context, id VaultId) error { + result, err := c.Refresh(ctx, id) + if err != nil { + return fmt.Errorf("performing Refresh: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Refresh: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/model_healtherror.go new file mode 100644 index 00000000000..a1cded61cd6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationvaulthealth + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/model_healtherrorsummary.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/model_healtherrorsummary.go new file mode 100644 index 00000000000..7a99b52ddd8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/model_healtherrorsummary.go @@ -0,0 +1,14 @@ +package replicationvaulthealth + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HealthErrorSummary struct { + AffectedResourceCorrelationIds *[]string `json:"affectedResourceCorrelationIds,omitempty"` + AffectedResourceSubtype *string `json:"affectedResourceSubtype,omitempty"` + AffectedResourceType *string `json:"affectedResourceType,omitempty"` + Category *HealthErrorCategory `json:"category,omitempty"` + Severity *Severity `json:"severity,omitempty"` + SummaryCode *string `json:"summaryCode,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/model_innerhealtherror.go new file mode 100644 index 00000000000..f01babb170f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationvaulthealth + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/model_resourcehealthsummary.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/model_resourcehealthsummary.go new file mode 100644 index 00000000000..6238fa00867 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/model_resourcehealthsummary.go @@ -0,0 +1,10 @@ +package replicationvaulthealth + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceHealthSummary struct { + CategorizedResourceCounts *map[string]int64 `json:"categorizedResourceCounts,omitempty"` + Issues *[]HealthErrorSummary `json:"issues,omitempty"` + ResourceCount *int64 `json:"resourceCount,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/model_vaulthealthdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/model_vaulthealthdetails.go new file mode 100644 index 00000000000..2c0736a7902 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/model_vaulthealthdetails.go @@ -0,0 +1,12 @@ +package replicationvaulthealth + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultHealthDetails struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VaultHealthProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/model_vaulthealthproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/model_vaulthealthproperties.go new file mode 100644 index 00000000000..d17dd6d82bc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/model_vaulthealthproperties.go @@ -0,0 +1,11 @@ +package replicationvaulthealth + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultHealthProperties struct { + ContainersHealth *ResourceHealthSummary `json:"containersHealth,omitempty"` + FabricsHealth *ResourceHealthSummary `json:"fabricsHealth,omitempty"` + ProtectedItemsHealth *ResourceHealthSummary `json:"protectedItemsHealth,omitempty"` + VaultErrors *[]HealthError `json:"vaultErrors,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/version.go new file mode 100644 index 00000000000..cd031b79e1d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaulthealth/version.go @@ -0,0 +1,10 @@ +package replicationvaulthealth + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationvaulthealth/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/README.md new file mode 100644 index 00000000000..bdabc3de0cb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/README.md @@ -0,0 +1,70 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting` Documentation + +The `replicationvaultsetting` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting" +``` + + +### Client Initialization + +```go +client := replicationvaultsetting.NewReplicationVaultSettingClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationVaultSettingClient.Create` + +```go +ctx := context.TODO() +id := replicationvaultsetting.NewReplicationVaultSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationVaultSettingName") + +payload := replicationvaultsetting.VaultSettingCreationInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationVaultSettingClient.Get` + +```go +ctx := context.TODO() +id := replicationvaultsetting.NewReplicationVaultSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationVaultSettingName") + +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: `ReplicationVaultSettingClient.List` + +```go +ctx := context.TODO() +id := replicationvaultsetting.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/client.go new file mode 100644 index 00000000000..614fa0058cc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/client.go @@ -0,0 +1,26 @@ +package replicationvaultsetting + +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 ReplicationVaultSettingClient struct { + Client *resourcemanager.Client +} + +func NewReplicationVaultSettingClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationVaultSettingClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationvaultsetting", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationVaultSettingClient: %+v", err) + } + + return &ReplicationVaultSettingClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/id_replicationvaultsetting.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/id_replicationvaultsetting.go new file mode 100644 index 00000000000..ecf9719a633 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/id_replicationvaultsetting.go @@ -0,0 +1,139 @@ +package replicationvaultsetting + +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(&ReplicationVaultSettingId{}) +} + +var _ resourceids.ResourceId = &ReplicationVaultSettingId{} + +// ReplicationVaultSettingId is a struct representing the Resource ID for a Replication Vault Setting +type ReplicationVaultSettingId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationVaultSettingName string +} + +// NewReplicationVaultSettingID returns a new ReplicationVaultSettingId struct +func NewReplicationVaultSettingID(subscriptionId string, resourceGroupName string, vaultName string, replicationVaultSettingName string) ReplicationVaultSettingId { + return ReplicationVaultSettingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationVaultSettingName: replicationVaultSettingName, + } +} + +// ParseReplicationVaultSettingID parses 'input' into a ReplicationVaultSettingId +func ParseReplicationVaultSettingID(input string) (*ReplicationVaultSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationVaultSettingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationVaultSettingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationVaultSettingIDInsensitively parses 'input' case-insensitively into a ReplicationVaultSettingId +// note: this method should only be used for API response data and not user input +func ParseReplicationVaultSettingIDInsensitively(input string) (*ReplicationVaultSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationVaultSettingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationVaultSettingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationVaultSettingId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationVaultSettingName, ok = input.Parsed["replicationVaultSettingName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationVaultSettingName", input) + } + + return nil +} + +// ValidateReplicationVaultSettingID checks that 'input' can be parsed as a Replication Vault Setting ID +func ValidateReplicationVaultSettingID(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 := ParseReplicationVaultSettingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Vault Setting ID +func (id ReplicationVaultSettingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationVaultSettings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationVaultSettingName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Vault Setting ID +func (id ReplicationVaultSettingId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationVaultSettings", "replicationVaultSettings", "replicationVaultSettings"), + resourceids.UserSpecifiedSegment("replicationVaultSettingName", "replicationVaultSettingName"), + } +} + +// String returns a human-readable description of this Replication Vault Setting ID +func (id ReplicationVaultSettingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Vault Setting Name: %q", id.ReplicationVaultSettingName), + } + return fmt.Sprintf("Replication Vault Setting (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/id_replicationvaultsetting_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/id_replicationvaultsetting_test.go new file mode 100644 index 00000000000..bf6d3aeb9ce --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/id_replicationvaultsetting_test.go @@ -0,0 +1,327 @@ +package replicationvaultsetting + +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 = &ReplicationVaultSettingId{} + +func TestNewReplicationVaultSettingID(t *testing.T) { + id := NewReplicationVaultSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationVaultSettingName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationVaultSettingName != "replicationVaultSettingName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationVaultSettingName'", id.ReplicationVaultSettingName, "replicationVaultSettingName") + } +} + +func TestFormatReplicationVaultSettingID(t *testing.T) { + actual := NewReplicationVaultSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationVaultSettingName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationVaultSettings/replicationVaultSettingName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationVaultSettingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationVaultSettingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationVaultSettings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationVaultSettings/replicationVaultSettingName", + Expected: &ReplicationVaultSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationVaultSettingName: "replicationVaultSettingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationVaultSettings/replicationVaultSettingName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationVaultSettingID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationVaultSettingName != v.Expected.ReplicationVaultSettingName { + t.Fatalf("Expected %q but got %q for ReplicationVaultSettingName", v.Expected.ReplicationVaultSettingName, actual.ReplicationVaultSettingName) + } + + } +} + +func TestParseReplicationVaultSettingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationVaultSettingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationVaultSettings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnVaUlTsEtTiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationVaultSettings/replicationVaultSettingName", + Expected: &ReplicationVaultSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationVaultSettingName: "replicationVaultSettingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationVaultSettings/replicationVaultSettingName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnVaUlTsEtTiNgS/rEpLiCaTiOnVaUlTsEtTiNgNaMe", + Expected: &ReplicationVaultSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationVaultSettingName: "rEpLiCaTiOnVaUlTsEtTiNgNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnVaUlTsEtTiNgS/rEpLiCaTiOnVaUlTsEtTiNgNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationVaultSettingIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationVaultSettingName != v.Expected.ReplicationVaultSettingName { + t.Fatalf("Expected %q but got %q for ReplicationVaultSettingName", v.Expected.ReplicationVaultSettingName, actual.ReplicationVaultSettingName) + } + + } +} + +func TestSegmentsForReplicationVaultSettingId(t *testing.T) { + segments := ReplicationVaultSettingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationVaultSettingId 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/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/id_vault.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/id_vault.go new file mode 100644 index 00000000000..26d5327d79b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/id_vault.go @@ -0,0 +1,130 @@ +package replicationvaultsetting + +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(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(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 := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/id_vault_test.go new file mode 100644 index 00000000000..db40ac61c76 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationvaultsetting + +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 = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId 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/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/method_create.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/method_create.go new file mode 100644 index 00000000000..2207eda514a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/method_create.go @@ -0,0 +1,74 @@ +package replicationvaultsetting + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VaultSetting +} + +// Create ... +func (c ReplicationVaultSettingClient) Create(ctx context.Context, id ReplicationVaultSettingId, input VaultSettingCreationInput) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationVaultSettingClient) CreateThenPoll(ctx context.Context, id ReplicationVaultSettingId, input VaultSettingCreationInput) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/method_get.go new file mode 100644 index 00000000000..1780e8632e3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/method_get.go @@ -0,0 +1,53 @@ +package replicationvaultsetting + +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 *VaultSetting +} + +// Get ... +func (c ReplicationVaultSettingClient) Get(ctx context.Context, id ReplicationVaultSettingId) (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 VaultSetting + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/method_list.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/method_list.go new file mode 100644 index 00000000000..8887bc084fc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/method_list.go @@ -0,0 +1,105 @@ +package replicationvaultsetting + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VaultSetting +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []VaultSetting +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ReplicationVaultSettingClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/replicationVaultSettings", 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 *[]VaultSetting `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationVaultSettingClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, VaultSettingOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationVaultSettingClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate VaultSettingOperationPredicate) (result ListCompleteResult, err error) { + items := make([]VaultSetting, 0) + + resp, err := c.List(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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/model_vaultsetting.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/model_vaultsetting.go new file mode 100644 index 00000000000..da949586ad3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/model_vaultsetting.go @@ -0,0 +1,12 @@ +package replicationvaultsetting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultSetting struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VaultSettingProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/model_vaultsettingcreationinput.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/model_vaultsettingcreationinput.go new file mode 100644 index 00000000000..ea6dddb61aa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/model_vaultsettingcreationinput.go @@ -0,0 +1,8 @@ +package replicationvaultsetting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultSettingCreationInput struct { + Properties VaultSettingCreationInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/model_vaultsettingcreationinputproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/model_vaultsettingcreationinputproperties.go new file mode 100644 index 00000000000..d7654ac5546 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/model_vaultsettingcreationinputproperties.go @@ -0,0 +1,9 @@ +package replicationvaultsetting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultSettingCreationInputProperties struct { + MigrationSolutionId *string `json:"migrationSolutionId,omitempty"` + VMwareToAzureProviderType *string `json:"vmwareToAzureProviderType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/model_vaultsettingproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/model_vaultsettingproperties.go new file mode 100644 index 00000000000..c90471f30f5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/model_vaultsettingproperties.go @@ -0,0 +1,9 @@ +package replicationvaultsetting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultSettingProperties struct { + MigrationSolutionId *string `json:"migrationSolutionId,omitempty"` + VMwareToAzureProviderType *string `json:"vmwareToAzureProviderType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/predicates.go new file mode 100644 index 00000000000..8e5065553c1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/predicates.go @@ -0,0 +1,32 @@ +package replicationvaultsetting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultSettingOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p VaultSettingOperationPredicate) Matches(input VaultSetting) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/version.go new file mode 100644 index 00000000000..8758eef0655 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvaultsetting/version.go @@ -0,0 +1,10 @@ +package replicationvaultsetting + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationvaultsetting/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/README.md new file mode 100644 index 00000000000..83e17818c0c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/README.md @@ -0,0 +1,116 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters` Documentation + +The `replicationvcenters` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/replicationvcenters" +``` + + +### Client Initialization + +```go +client := replicationvcenters.NewReplicationvCentersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationvCentersClient.Create` + +```go +ctx := context.TODO() +id := replicationvcenters.NewReplicationvCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationvCenterName") + +payload := replicationvcenters.AddVCenterRequest{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationvCentersClient.Delete` + +```go +ctx := context.TODO() +id := replicationvcenters.NewReplicationvCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationvCenterName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationvCentersClient.Get` + +```go +ctx := context.TODO() +id := replicationvcenters.NewReplicationvCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationvCenterName") + +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: `ReplicationvCentersClient.List` + +```go +ctx := context.TODO() +id := replicationvcenters.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationvCentersClient.ListByReplicationFabrics` + +```go +ctx := context.TODO() +id := replicationvcenters.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +// alternatively `client.ListByReplicationFabrics(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationFabricsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationvCentersClient.Update` + +```go +ctx := context.TODO() +id := replicationvcenters.NewReplicationvCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationvCenterName") + +payload := replicationvcenters.UpdateVCenterRequest{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/client.go new file mode 100644 index 00000000000..57e9dd9ecaa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/client.go @@ -0,0 +1,26 @@ +package replicationvcenters + +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 ReplicationvCentersClient struct { + Client *resourcemanager.Client +} + +func NewReplicationvCentersClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationvCentersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationvcenters", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationvCentersClient: %+v", err) + } + + return &ReplicationvCentersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/constants.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/constants.go new file mode 100644 index 00000000000..5eb916fd9d8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/constants.go @@ -0,0 +1,51 @@ +package replicationvcenters + +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 HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/id_replicationfabric.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/id_replicationfabric.go new file mode 100644 index 00000000000..02266219cb8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/id_replicationfabric.go @@ -0,0 +1,139 @@ +package replicationvcenters + +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(&ReplicationFabricId{}) +} + +var _ resourceids.ResourceId = &ReplicationFabricId{} + +// ReplicationFabricId is a struct representing the Resource ID for a Replication Fabric +type ReplicationFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string +} + +// NewReplicationFabricID returns a new ReplicationFabricId struct +func NewReplicationFabricID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string) ReplicationFabricId { + return ReplicationFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + } +} + +// ParseReplicationFabricID parses 'input' into a ReplicationFabricId +func ParseReplicationFabricID(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationFabricIDInsensitively parses 'input' case-insensitively into a ReplicationFabricId +// note: this method should only be used for API response data and not user input +func ParseReplicationFabricIDInsensitively(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationFabricId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + return nil +} + +// ValidateReplicationFabricID checks that 'input' can be parsed as a Replication Fabric ID +func ValidateReplicationFabricID(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 := ParseReplicationFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Fabric ID +func (id ReplicationFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Fabric ID +func (id ReplicationFabricId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + } +} + +// String returns a human-readable description of this Replication Fabric ID +func (id ReplicationFabricId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + } + return fmt.Sprintf("Replication Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/id_replicationfabric_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/id_replicationfabric_test.go new file mode 100644 index 00000000000..34ad51f05fd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/id_replicationfabric_test.go @@ -0,0 +1,327 @@ +package replicationvcenters + +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 = &ReplicationFabricId{} + +func TestNewReplicationFabricID(t *testing.T) { + id := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } +} + +func TestFormatReplicationFabricID(t *testing.T) { + actual := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestParseReplicationFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestSegmentsForReplicationFabricId(t *testing.T) { + segments := ReplicationFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationFabricId 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/recoveryservicessiterecovery/2024-10-01/replicationvcenters/id_replicationvcenter.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/id_replicationvcenter.go new file mode 100644 index 00000000000..0737f2b9eb7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/id_replicationvcenter.go @@ -0,0 +1,148 @@ +package replicationvcenters + +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(&ReplicationvCenterId{}) +} + +var _ resourceids.ResourceId = &ReplicationvCenterId{} + +// ReplicationvCenterId is a struct representing the Resource ID for a Replicationv Center +type ReplicationvCenterId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationvCenterName string +} + +// NewReplicationvCenterID returns a new ReplicationvCenterId struct +func NewReplicationvCenterID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationvCenterName string) ReplicationvCenterId { + return ReplicationvCenterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationvCenterName: replicationvCenterName, + } +} + +// ParseReplicationvCenterID parses 'input' into a ReplicationvCenterId +func ParseReplicationvCenterID(input string) (*ReplicationvCenterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationvCenterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationvCenterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationvCenterIDInsensitively parses 'input' case-insensitively into a ReplicationvCenterId +// note: this method should only be used for API response data and not user input +func ParseReplicationvCenterIDInsensitively(input string) (*ReplicationvCenterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationvCenterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationvCenterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationvCenterId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationvCenterName, ok = input.Parsed["replicationvCenterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationvCenterName", input) + } + + return nil +} + +// ValidateReplicationvCenterID checks that 'input' can be parsed as a Replicationv Center ID +func ValidateReplicationvCenterID(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 := ParseReplicationvCenterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replicationv Center ID +func (id ReplicationvCenterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationvCenters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationvCenterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replicationv Center ID +func (id ReplicationvCenterId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationvCenters", "replicationvCenters", "replicationvCenters"), + resourceids.UserSpecifiedSegment("replicationvCenterName", "replicationvCenterName"), + } +} + +// String returns a human-readable description of this Replicationv Center ID +func (id ReplicationvCenterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replicationv Center Name: %q", id.ReplicationvCenterName), + } + return fmt.Sprintf("Replicationv Center (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/id_replicationvcenter_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/id_replicationvcenter_test.go new file mode 100644 index 00000000000..9825c94a29a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/id_replicationvcenter_test.go @@ -0,0 +1,372 @@ +package replicationvcenters + +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 = &ReplicationvCenterId{} + +func TestNewReplicationvCenterID(t *testing.T) { + id := NewReplicationvCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationvCenterName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationvCenterName != "replicationvCenterName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationvCenterName'", id.ReplicationvCenterName, "replicationvCenterName") + } +} + +func TestFormatReplicationvCenterID(t *testing.T) { + actual := NewReplicationvCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationvCenterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationvCenters/replicationvCenterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationvCenterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationvCenterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationvCenters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationvCenters/replicationvCenterName", + Expected: &ReplicationvCenterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationvCenterName: "replicationvCenterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationvCenters/replicationvCenterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationvCenterID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationvCenterName != v.Expected.ReplicationvCenterName { + t.Fatalf("Expected %q but got %q for ReplicationvCenterName", v.Expected.ReplicationvCenterName, actual.ReplicationvCenterName) + } + + } +} + +func TestParseReplicationvCenterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationvCenterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationvCenters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnVcEnTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationvCenters/replicationvCenterName", + Expected: &ReplicationvCenterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationvCenterName: "replicationvCenterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationvCenters/replicationvCenterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnVcEnTeRs/rEpLiCaTiOnVcEnTeRnAmE", + Expected: &ReplicationvCenterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationvCenterName: "rEpLiCaTiOnVcEnTeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnVcEnTeRs/rEpLiCaTiOnVcEnTeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationvCenterIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationvCenterName != v.Expected.ReplicationvCenterName { + t.Fatalf("Expected %q but got %q for ReplicationvCenterName", v.Expected.ReplicationvCenterName, actual.ReplicationvCenterName) + } + + } +} + +func TestSegmentsForReplicationvCenterId(t *testing.T) { + segments := ReplicationvCenterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationvCenterId 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/recoveryservicessiterecovery/2024-10-01/replicationvcenters/id_vault.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/id_vault.go new file mode 100644 index 00000000000..e37ff91d564 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/id_vault.go @@ -0,0 +1,130 @@ +package replicationvcenters + +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(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(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 := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/id_vault_test.go new file mode 100644 index 00000000000..d474d05200f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationvcenters + +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 = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId 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/recoveryservicessiterecovery/2024-10-01/replicationvcenters/method_create.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/method_create.go new file mode 100644 index 00000000000..b08a9b622c7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/method_create.go @@ -0,0 +1,75 @@ +package replicationvcenters + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VCenter +} + +// Create ... +func (c ReplicationvCentersClient) Create(ctx context.Context, id ReplicationvCenterId, input AddVCenterRequest) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationvCentersClient) CreateThenPoll(ctx context.Context, id ReplicationvCenterId, input AddVCenterRequest) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/method_delete.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/method_delete.go new file mode 100644 index 00000000000..67f5d8e7a5d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/method_delete.go @@ -0,0 +1,70 @@ +package replicationvcenters + +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 ReplicationvCentersClient) Delete(ctx context.Context, id ReplicationvCenterId) (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 ReplicationvCentersClient) DeleteThenPoll(ctx context.Context, id ReplicationvCenterId) 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/recoveryservicessiterecovery/2024-10-01/replicationvcenters/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/method_get.go new file mode 100644 index 00000000000..624c667672c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/method_get.go @@ -0,0 +1,53 @@ +package replicationvcenters + +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 *VCenter +} + +// Get ... +func (c ReplicationvCentersClient) Get(ctx context.Context, id ReplicationvCenterId) (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 VCenter + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/method_list.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/method_list.go new file mode 100644 index 00000000000..f92559a8f20 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/method_list.go @@ -0,0 +1,105 @@ +package replicationvcenters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VCenter +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []VCenter +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ReplicationvCentersClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/replicationvCenters", 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 *[]VCenter `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReplicationvCentersClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, VCenterOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationvCentersClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate VCenterOperationPredicate) (result ListCompleteResult, err error) { + items := make([]VCenter, 0) + + resp, err := c.List(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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/method_listbyreplicationfabrics.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/method_listbyreplicationfabrics.go new file mode 100644 index 00000000000..2c99a1a6fea --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/method_listbyreplicationfabrics.go @@ -0,0 +1,105 @@ +package replicationvcenters + +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 ListByReplicationFabricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VCenter +} + +type ListByReplicationFabricsCompleteResult struct { + LatestHttpResponse *http.Response + Items []VCenter +} + +type ListByReplicationFabricsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationFabricsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationFabrics ... +func (c ReplicationvCentersClient) ListByReplicationFabrics(ctx context.Context, id ReplicationFabricId) (result ListByReplicationFabricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationFabricsCustomPager{}, + Path: fmt.Sprintf("%s/replicationvCenters", 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 *[]VCenter `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationFabricsComplete retrieves all the results into a single object +func (c ReplicationvCentersClient) ListByReplicationFabricsComplete(ctx context.Context, id ReplicationFabricId) (ListByReplicationFabricsCompleteResult, error) { + return c.ListByReplicationFabricsCompleteMatchingPredicate(ctx, id, VCenterOperationPredicate{}) +} + +// ListByReplicationFabricsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationvCentersClient) ListByReplicationFabricsCompleteMatchingPredicate(ctx context.Context, id ReplicationFabricId, predicate VCenterOperationPredicate) (result ListByReplicationFabricsCompleteResult, err error) { + items := make([]VCenter, 0) + + resp, err := c.ListByReplicationFabrics(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 = ListByReplicationFabricsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/method_update.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/method_update.go new file mode 100644 index 00000000000..8b93d0669a9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/method_update.go @@ -0,0 +1,75 @@ +package replicationvcenters + +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 *VCenter +} + +// Update ... +func (c ReplicationvCentersClient) Update(ctx context.Context, id ReplicationvCenterId, input UpdateVCenterRequest) (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 ReplicationvCentersClient) UpdateThenPoll(ctx context.Context, id ReplicationvCenterId, input UpdateVCenterRequest) 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/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_addvcenterrequest.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_addvcenterrequest.go new file mode 100644 index 00000000000..8bc14e86c5c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_addvcenterrequest.go @@ -0,0 +1,8 @@ +package replicationvcenters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddVCenterRequest struct { + Properties *AddVCenterRequestProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_addvcenterrequestproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_addvcenterrequestproperties.go new file mode 100644 index 00000000000..3904def79d8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_addvcenterrequestproperties.go @@ -0,0 +1,12 @@ +package replicationvcenters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddVCenterRequestProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Port *string `json:"port,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_healtherror.go new file mode 100644 index 00000000000..915bd6578cf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationvcenters + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_innerhealtherror.go new file mode 100644 index 00000000000..5ed6fc2fe05 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationvcenters + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_updatevcenterrequest.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_updatevcenterrequest.go new file mode 100644 index 00000000000..c9ab295622d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_updatevcenterrequest.go @@ -0,0 +1,8 @@ +package replicationvcenters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateVCenterRequest struct { + Properties *UpdateVCenterRequestProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_updatevcenterrequestproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_updatevcenterrequestproperties.go new file mode 100644 index 00000000000..9c02f563369 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_updatevcenterrequestproperties.go @@ -0,0 +1,12 @@ +package replicationvcenters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateVCenterRequestProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Port *string `json:"port,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_vcenter.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_vcenter.go new file mode 100644 index 00000000000..5f8c2b26c1e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_vcenter.go @@ -0,0 +1,12 @@ +package replicationvcenters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VCenter struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VCenterProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_vcenterproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_vcenterproperties.go new file mode 100644 index 00000000000..9f4d3394f62 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/model_vcenterproperties.go @@ -0,0 +1,36 @@ +package replicationvcenters + +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 VCenterProperties struct { + DiscoveryStatus *string `json:"discoveryStatus,omitempty"` + FabricArmResourceName *string `json:"fabricArmResourceName,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InfrastructureId *string `json:"infrastructureId,omitempty"` + InternalId *string `json:"internalId,omitempty"` + LastHeartbeat *string `json:"lastHeartbeat,omitempty"` + Port *string `json:"port,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` +} + +func (o *VCenterProperties) GetLastHeartbeatAsTime() (*time.Time, error) { + if o.LastHeartbeat == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeat, "2006-01-02T15:04:05Z07:00") +} + +func (o *VCenterProperties) SetLastHeartbeatAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeat = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/predicates.go new file mode 100644 index 00000000000..604db32ccd0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/predicates.go @@ -0,0 +1,32 @@ +package replicationvcenters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VCenterOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p VCenterOperationPredicate) Matches(input VCenter) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/version.go new file mode 100644 index 00000000000..edaea7ae145 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/replicationvcenters/version.go @@ -0,0 +1,10 @@ +package replicationvcenters + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationvcenters/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/README.md new file mode 100644 index 00000000000..ffb593bd6b1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems` Documentation + +The `supportedoperatingsystems` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems" +``` + + +### Client Initialization + +```go +client := supportedoperatingsystems.NewSupportedOperatingSystemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SupportedOperatingSystemsClient.Get` + +```go +ctx := context.TODO() +id := supportedoperatingsystems.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +read, err := client.Get(ctx, id, supportedoperatingsystems.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/client.go new file mode 100644 index 00000000000..b895d9b8fd4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/client.go @@ -0,0 +1,26 @@ +package supportedoperatingsystems + +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 SupportedOperatingSystemsClient struct { + Client *resourcemanager.Client +} + +func NewSupportedOperatingSystemsClientWithBaseURI(sdkApi sdkEnv.Api) (*SupportedOperatingSystemsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "supportedoperatingsystems", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SupportedOperatingSystemsClient: %+v", err) + } + + return &SupportedOperatingSystemsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/id_vault.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/id_vault.go new file mode 100644 index 00000000000..2577775d89c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/id_vault.go @@ -0,0 +1,130 @@ +package supportedoperatingsystems + +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(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(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 := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/id_vault_test.go new file mode 100644 index 00000000000..84334cd878a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/id_vault_test.go @@ -0,0 +1,282 @@ +package supportedoperatingsystems + +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 = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId 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/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/method_get.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/method_get.go new file mode 100644 index 00000000000..a3839b3d736 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/method_get.go @@ -0,0 +1,83 @@ +package supportedoperatingsystems + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SupportedOperatingSystems +} + +type GetOperationOptions struct { + InstanceType *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.InstanceType != nil { + out.Append("instanceType", fmt.Sprintf("%v", *o.InstanceType)) + } + return &out +} + +// Get ... +func (c SupportedOperatingSystemsClient) Get(ctx context.Context, id VaultId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/replicationSupportedOperatingSystems", 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 SupportedOperatingSystems + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/model_osversionwrapper.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/model_osversionwrapper.go new file mode 100644 index 00000000000..af334b23ea8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/model_osversionwrapper.go @@ -0,0 +1,9 @@ +package supportedoperatingsystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OSVersionWrapper struct { + ServicePack *string `json:"servicePack,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/model_supportedoperatingsystems.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/model_supportedoperatingsystems.go new file mode 100644 index 00000000000..2d7bee64192 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/model_supportedoperatingsystems.go @@ -0,0 +1,12 @@ +package supportedoperatingsystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportedOperatingSystems struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SupportedOSProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/model_supportedosdetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/model_supportedosdetails.go new file mode 100644 index 00000000000..b89ec6cfe3a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/model_supportedosdetails.go @@ -0,0 +1,10 @@ +package supportedoperatingsystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportedOSDetails struct { + OsName *string `json:"osName,omitempty"` + OsType *string `json:"osType,omitempty"` + OsVersions *[]OSVersionWrapper `json:"osVersions,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/model_supportedosproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/model_supportedosproperties.go new file mode 100644 index 00000000000..ee9acfc9a81 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/model_supportedosproperties.go @@ -0,0 +1,8 @@ +package supportedoperatingsystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportedOSProperties struct { + SupportedOsList *[]SupportedOSProperty `json:"supportedOsList,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/model_supportedosproperty.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/model_supportedosproperty.go new file mode 100644 index 00000000000..e9f60b43c0b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/model_supportedosproperty.go @@ -0,0 +1,9 @@ +package supportedoperatingsystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportedOSProperty struct { + InstanceType *string `json:"instanceType,omitempty"` + SupportedOs *[]SupportedOSDetails `json:"supportedOs,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/version.go new file mode 100644 index 00000000000..cb0cb95094d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/supportedoperatingsystems/version.go @@ -0,0 +1,10 @@ +package supportedoperatingsystems + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/supportedoperatingsystems/2024-10-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/README.md b/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/README.md new file mode 100644 index 00000000000..60452dee05c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes` Documentation + +The `targetcomputesizes` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2024-10-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/recoveryservicessiterecovery/2024-10-01/targetcomputesizes" +``` + + +### Client Initialization + +```go +client := targetcomputesizes.NewTargetComputeSizesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `TargetComputeSizesClient.ListByReplicationProtectedItems` + +```go +ctx := context.TODO() +id := targetcomputesizes.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +// alternatively `client.ListByReplicationProtectedItems(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationProtectedItemsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/client.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/client.go new file mode 100644 index 00000000000..9e8a8315990 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/client.go @@ -0,0 +1,26 @@ +package targetcomputesizes + +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 TargetComputeSizesClient struct { + Client *resourcemanager.Client +} + +func NewTargetComputeSizesClientWithBaseURI(sdkApi sdkEnv.Api) (*TargetComputeSizesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "targetcomputesizes", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TargetComputeSizesClient: %+v", err) + } + + return &TargetComputeSizesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/id_replicationprotecteditem.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/id_replicationprotecteditem.go new file mode 100644 index 00000000000..980d5cc9c99 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/id_replicationprotecteditem.go @@ -0,0 +1,157 @@ +package targetcomputesizes + +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(&ReplicationProtectedItemId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectedItemId{} + +// ReplicationProtectedItemId is a struct representing the Resource ID for a Replication Protected Item +type ReplicationProtectedItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectedItemName string +} + +// NewReplicationProtectedItemID returns a new ReplicationProtectedItemId struct +func NewReplicationProtectedItemID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectedItemName string) ReplicationProtectedItemId { + return ReplicationProtectedItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectedItemName: replicationProtectedItemName, + } +} + +// ParseReplicationProtectedItemID parses 'input' into a ReplicationProtectedItemId +func ParseReplicationProtectedItemID(input string) (*ReplicationProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectedItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectedItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectedItemIDInsensitively parses 'input' case-insensitively into a ReplicationProtectedItemId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectedItemIDInsensitively(input string) (*ReplicationProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectedItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectedItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectedItemId) 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.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectedItemName, ok = input.Parsed["replicationProtectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectedItemName", input) + } + + return nil +} + +// ValidateReplicationProtectedItemID checks that 'input' can be parsed as a Replication Protected Item ID +func ValidateReplicationProtectedItemID(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 := ParseReplicationProtectedItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protected Item ID +func (id ReplicationProtectedItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectedItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectedItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protected Item ID +func (id ReplicationProtectedItemId) 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("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationProtectedItems", "replicationProtectedItems", "replicationProtectedItems"), + resourceids.UserSpecifiedSegment("replicationProtectedItemName", "replicationProtectedItemName"), + } +} + +// String returns a human-readable description of this Replication Protected Item ID +func (id ReplicationProtectedItemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protected Item Name: %q", id.ReplicationProtectedItemName), + } + return fmt.Sprintf("Replication Protected Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/id_replicationprotecteditem_test.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/id_replicationprotecteditem_test.go new file mode 100644 index 00000000000..79746b3b3a0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/id_replicationprotecteditem_test.go @@ -0,0 +1,417 @@ +package targetcomputesizes + +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 = &ReplicationProtectedItemId{} + +func TestNewReplicationProtectedItemID(t *testing.T) { + id := NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + + 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.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationProtectedItemName != "replicationProtectedItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectedItemName'", id.ReplicationProtectedItemName, "replicationProtectedItemName") + } +} + +func TestFormatReplicationProtectedItemID(t *testing.T) { + actual := NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectedItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectedItemName: "replicationProtectedItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectedItemID(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + } +} + +func TestParseReplicationProtectedItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectedItemName: "replicationProtectedItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMnAmE", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationProtectedItemName: "rEpLiCaTiOnPrOtEcTeDiTeMnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectedItemIDInsensitively(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.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + } +} + +func TestSegmentsForReplicationProtectedItemId(t *testing.T) { + segments := ReplicationProtectedItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectedItemId 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/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/method_listbyreplicationprotecteditems.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/method_listbyreplicationprotecteditems.go new file mode 100644 index 00000000000..2bff64e44bb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/method_listbyreplicationprotecteditems.go @@ -0,0 +1,105 @@ +package targetcomputesizes + +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 ListByReplicationProtectedItemsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TargetComputeSize +} + +type ListByReplicationProtectedItemsCompleteResult struct { + LatestHttpResponse *http.Response + Items []TargetComputeSize +} + +type ListByReplicationProtectedItemsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationProtectedItemsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationProtectedItems ... +func (c TargetComputeSizesClient) ListByReplicationProtectedItems(ctx context.Context, id ReplicationProtectedItemId) (result ListByReplicationProtectedItemsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationProtectedItemsCustomPager{}, + Path: fmt.Sprintf("%s/targetComputeSizes", 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 *[]TargetComputeSize `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationProtectedItemsComplete retrieves all the results into a single object +func (c TargetComputeSizesClient) ListByReplicationProtectedItemsComplete(ctx context.Context, id ReplicationProtectedItemId) (ListByReplicationProtectedItemsCompleteResult, error) { + return c.ListByReplicationProtectedItemsCompleteMatchingPredicate(ctx, id, TargetComputeSizeOperationPredicate{}) +} + +// ListByReplicationProtectedItemsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TargetComputeSizesClient) ListByReplicationProtectedItemsCompleteMatchingPredicate(ctx context.Context, id ReplicationProtectedItemId, predicate TargetComputeSizeOperationPredicate) (result ListByReplicationProtectedItemsCompleteResult, err error) { + items := make([]TargetComputeSize, 0) + + resp, err := c.ListByReplicationProtectedItems(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 = ListByReplicationProtectedItemsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/model_computesizeerrordetails.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/model_computesizeerrordetails.go new file mode 100644 index 00000000000..f16abf36733 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/model_computesizeerrordetails.go @@ -0,0 +1,9 @@ +package targetcomputesizes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeSizeErrorDetails struct { + Message *string `json:"message,omitempty"` + Severity *string `json:"severity,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/model_targetcomputesize.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/model_targetcomputesize.go new file mode 100644 index 00000000000..532ef19b568 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/model_targetcomputesize.go @@ -0,0 +1,11 @@ +package targetcomputesizes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetComputeSize struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *TargetComputeSizeProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/model_targetcomputesizeproperties.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/model_targetcomputesizeproperties.go new file mode 100644 index 00000000000..474a614fb31 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/model_targetcomputesizeproperties.go @@ -0,0 +1,17 @@ +package targetcomputesizes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetComputeSizeProperties struct { + CpuCoresCount *int64 `json:"cpuCoresCount,omitempty"` + Errors *[]ComputeSizeErrorDetails `json:"errors,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HighIopsSupported *string `json:"highIopsSupported,omitempty"` + HyperVGenerations *[]string `json:"hyperVGenerations,omitempty"` + MaxDataDiskCount *int64 `json:"maxDataDiskCount,omitempty"` + MaxNicsCount *int64 `json:"maxNicsCount,omitempty"` + MemoryInGB *float64 `json:"memoryInGB,omitempty"` + Name *string `json:"name,omitempty"` + VCPUsAvailable *int64 `json:"vCPUsAvailable,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/predicates.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/predicates.go new file mode 100644 index 00000000000..e884ca4906e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/predicates.go @@ -0,0 +1,27 @@ +package targetcomputesizes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetComputeSizeOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p TargetComputeSizeOperationPredicate) Matches(input TargetComputeSize) 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/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/version.go b/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/version.go new file mode 100644 index 00000000000..e86df60aff3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2024-10-01/targetcomputesizes/version.go @@ -0,0 +1,10 @@ +package targetcomputesizes + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/targetcomputesizes/2024-10-01" +} diff --git a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstance.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstance.go index 6ca7eaa18d8..cf396291910 100644 --- a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstance.go +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_sapvirtualinstance.go @@ -9,12 +9,12 @@ import ( // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type SAPVirtualInstance struct { - Id *string `json:"id,omitempty"` - Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` - Location string `json:"location"` - Name *string `json:"name,omitempty"` - Properties *SAPVirtualInstanceProperties `json:"properties,omitempty"` - SystemData *systemdata.SystemData `json:"systemData,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.UserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SAPVirtualInstanceProperties `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/workloads/2024-09-01/sapvirtualinstances/model_updatesapvirtualinstancerequest.go b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_updatesapvirtualinstancerequest.go index 95da3bf4f6e..43442dde884 100644 --- a/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_updatesapvirtualinstancerequest.go +++ b/resource-manager/workloads/2024-09-01/sapvirtualinstances/model_updatesapvirtualinstancerequest.go @@ -8,7 +8,7 @@ import ( // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type UpdateSAPVirtualInstanceRequest struct { - Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` - Properties *UpdateSAPVirtualInstanceProperties `json:"properties,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` + Identity *identity.UserAssignedMap `json:"identity,omitempty"` + Properties *UpdateSAPVirtualInstanceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` }