From c731419b3320c70874bfbb2535bf7841a594faf2 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Thu, 26 Mar 2026 08:37:49 -0600 Subject: [PATCH 01/25] `cosmos` client changes --- internal/services/cosmos/client/client.go | 69 ++++++----------------- 1 file changed, 18 insertions(+), 51 deletions(-) diff --git a/internal/services/cosmos/client/client.go b/internal/services/cosmos/client/client.go index a2da051bd050..756d9d13e5ee 100644 --- a/internal/services/cosmos/client/client.go +++ b/internal/services/cosmos/client/client.go @@ -6,11 +6,12 @@ package client import ( "fmt" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb" // nolint: staticcheck "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2022-05-15/sqldedicatedgateway" "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2022-11-15/mongorbacs" "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2023-04-15/managedcassandras" "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables" "github.com/hashicorp/go-azure-sdk/resource-manager/postgresqlhsc/2022-11-08/clusters" "github.com/hashicorp/go-azure-sdk/resource-manager/postgresqlhsc/2022-11-08/configurations" "github.com/hashicorp/go-azure-sdk/resource-manager/postgresqlhsc/2022-11-08/firewallrules" @@ -25,19 +26,10 @@ type Client struct { FirewallRulesClient *firewallrules.FirewallRulesClient ManagedCassandraClient *managedcassandras.ManagedCassandrasClient MongoRBACClient *mongorbacs.MongorbacsClient + RbacsClient *rbacs.RbacsClient + RestorablesClient *restorables.RestorablesClient RolesClient *roles.RolesClient SqlDedicatedGatewayClient *sqldedicatedgateway.SqlDedicatedGatewayClient - - // Track 1 - CassandraClient *documentdb.CassandraResourcesClient - DatabaseClient *documentdb.DatabaseAccountsClient - GremlinClient *documentdb.GremlinResourcesClient - MongoDbClient *documentdb.MongoDBResourcesClient - NotebookWorkspaceClient *documentdb.NotebookWorkspacesClient - RestorableDatabaseAccountsClient *documentdb.RestorableDatabaseAccountsClient - SqlClient *documentdb.SQLResourcesClient - SqlResourceClient *documentdb.SQLResourcesClient - TableClient *documentdb.TableResourcesClient } func NewClient(o *common.ClientOptions) (*Client, error) { @@ -77,46 +69,30 @@ func NewClient(o *common.ClientOptions) (*Client, error) { } o.Configure(mongorbacsClient.Client, o.Authorizers.ResourceManager) + rbacsClient, err := rbacs.NewRbacsClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building RBACs client: %+v", err) + } + o.Configure(rbacsClient.Client, o.Authorizers.ResourceManager) + rolesClient, err := roles.NewRolesClientWithBaseURI(o.Environment.ResourceManager) if err != nil { return nil, fmt.Errorf("building Roles client: %+v", err) } o.Configure(rolesClient.Client, o.Authorizers.ResourceManager) + restorablesClient, err := restorables.NewRestorablesClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Restorables client: %+v", err) + } + o.Configure(restorablesClient.Client, o.Authorizers.ResourceManager) + sqlDedicatedGatewayClient, err := sqldedicatedgateway.NewSqlDedicatedGatewayClientWithBaseURI(o.Environment.ResourceManager) if err != nil { return nil, fmt.Errorf("building Sql Dedicated Gateway client: %+v", err) } o.Configure(sqlDedicatedGatewayClient.Client, o.Authorizers.ResourceManager) - // Track 1 - cassandraClient := documentdb.NewCassandraResourcesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&cassandraClient.Client, o.ResourceManagerAuthorizer) - - databaseClient := documentdb.NewDatabaseAccountsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&databaseClient.Client, o.ResourceManagerAuthorizer) - - gremlinClient := documentdb.NewGremlinResourcesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&gremlinClient.Client, o.ResourceManagerAuthorizer) - - mongoDbClient := documentdb.NewMongoDBResourcesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&mongoDbClient.Client, o.ResourceManagerAuthorizer) - - notebookWorkspaceClient := documentdb.NewNotebookWorkspacesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(¬ebookWorkspaceClient.Client, o.ResourceManagerAuthorizer) - - restorableDatabaseAccountsClient := documentdb.NewRestorableDatabaseAccountsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&restorableDatabaseAccountsClient.Client, o.ResourceManagerAuthorizer) - - sqlClient := documentdb.NewSQLResourcesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&sqlClient.Client, o.ResourceManagerAuthorizer) - - sqlResourceClient := documentdb.NewSQLResourcesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&sqlResourceClient.Client, o.ResourceManagerAuthorizer) - - tableClient := documentdb.NewTableResourcesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&tableClient.Client, o.ResourceManagerAuthorizer) - return &Client{ ManagedCassandraClient: managedCassandraClient, ClustersClient: clustersClient, @@ -124,18 +100,9 @@ func NewClient(o *common.ClientOptions) (*Client, error) { CosmosDBClient: cosmosdbClient, FirewallRulesClient: firewallRulesClient, MongoRBACClient: mongorbacsClient, + RbacsClient: rbacsClient, + RestorablesClient: restorablesClient, RolesClient: rolesClient, SqlDedicatedGatewayClient: sqlDedicatedGatewayClient, - - // Track 1 - CassandraClient: &cassandraClient, - DatabaseClient: &databaseClient, - GremlinClient: &gremlinClient, - MongoDbClient: &mongoDbClient, - NotebookWorkspaceClient: ¬ebookWorkspaceClient, - RestorableDatabaseAccountsClient: &restorableDatabaseAccountsClient, - SqlClient: &sqlClient, - SqlResourceClient: &sqlResourceClient, - TableClient: &tableClient, }, nil } From f30689b161d781dc87488b3e2c05fc191cb690ae Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:18:07 -0600 Subject: [PATCH 02/25] `azurerm_cosmosdb_account` - remove `azure-sdk-for-go` clients --- internal/services/cosmos/cosmosdb.go | 21 ++++++++++++------- .../cosmos/cosmosdb_account_resource.go | 6 +++--- .../cosmos/cosmosdb_account_resource_test.go | 9 ++++---- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/internal/services/cosmos/cosmosdb.go b/internal/services/cosmos/cosmosdb.go index ebd41d9fc627..2a770f7a167e 100644 --- a/internal/services/cosmos/cosmosdb.go +++ b/internal/services/cosmos/cosmosdb.go @@ -1,13 +1,18 @@ package cosmos -import "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb" // nolint: staticcheck - -func isServerlessCapacityMode(accResp documentdb.DatabaseAccountGetResults) bool { - if props := accResp.DatabaseAccountGetProperties; props != nil && props.Capabilities != nil { - for _, v := range *props.Capabilities { - if v.Name != nil && *v.Name == "EnableServerless" { - return true - } +import ( + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" +) + +func isServerlessCapacityMode(input *cosmosdb.DatabaseAccountGetResults) bool { + if input == nil || input.Properties == nil || input.Properties.Capabilities == nil { + return false + } + + for _, v := range *input.Properties.Capabilities { + if pointer.From(v.Name) == "EnableServerless" { + return true } } diff --git a/internal/services/cosmos/cosmosdb_account_resource.go b/internal/services/cosmos/cosmosdb_account_resource.go index 00e6a4347718..7d71bc0143a3 100644 --- a/internal/services/cosmos/cosmosdb_account_resource.go +++ b/internal/services/cosmos/cosmosdb_account_resource.go @@ -22,6 +22,7 @@ import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" @@ -30,7 +31,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/common" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/migration" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -180,7 +180,7 @@ func resourceCosmosDbAccount() *pluginsdk.Resource { ), Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.DatabaseAccountID(id) + _, err := cosmosdb.ParseDatabaseAccountID(id) return err }), @@ -591,7 +591,7 @@ func resourceCosmosDbAccount() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.RestorableDatabaseAccountID, + ValidateFunc: restorables.ValidateRestorableDatabaseAccountID, }, "restore_timestamp_in_utc": { diff --git a/internal/services/cosmos/cosmosdb_account_resource_test.go b/internal/services/cosmos/cosmosdb_account_resource_test.go index 281b9e489802..97d0e1b8c5b3 100644 --- a/internal/services/cosmos/cosmosdb_account_resource_test.go +++ b/internal/services/cosmos/cosmosdb_account_resource_test.go @@ -19,7 +19,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/features" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) @@ -1461,17 +1460,17 @@ func TestAccCosmosDBAccount_withoutMaxAgeInSeconds(t *testing.T) { } func (r CosmosDBAccountResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.DatabaseAccountID(state.ID) + id, err := cosmosdb.ParseDatabaseAccountID(state.ID) if err != nil { return nil, err } - resp, err := clients.Cosmos.DatabaseClient.Get(ctx, id.ResourceGroup, id.Name) + resp, err := clients.Cosmos.CosmosDBClient.DatabaseAccountsGet(ctx, *id) if err != nil { - return nil, fmt.Errorf("reading Cosmos Database (%s): %+v", id.String(), err) + return nil, fmt.Errorf("retrieving %s: %+v", id, err) } - return pointer.To(resp.ID != nil), nil + return pointer.To(resp.Model != nil), nil } func (CosmosDBAccountResource) basic(data acceptance.TestData, kind cosmosdb.DatabaseAccountKind, consistency cosmosdb.DefaultConsistencyLevel) string { From e71067f0a1d1c68dc10170c0a42e7374bd3f28c0 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:19:06 -0600 Subject: [PATCH 03/25] `azurerm_cosmosdb_cassandra_keyspace` - migrate to `go-azure-sdk` --- .../cosmosdb_cassandra_keyspace_resource.go | 161 +++++++----------- ...smosdb_cassandra_keyspace_resource_test.go | 38 ++++- 2 files changed, 92 insertions(+), 107 deletions(-) diff --git a/internal/services/cosmos/cosmosdb_cassandra_keyspace_resource.go b/internal/services/cosmos/cosmosdb_cassandra_keyspace_resource.go index 49061af96291..c9cecc507eb4 100644 --- a/internal/services/cosmos/cosmosdb_cassandra_keyspace_resource.go +++ b/internal/services/cosmos/cosmosdb_cassandra_keyspace_resource.go @@ -5,21 +5,19 @@ package cosmos import ( "fmt" - "log" "time" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/common" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/migration" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceCosmosDbCassandraKeyspace() *pluginsdk.Resource { @@ -30,7 +28,7 @@ func resourceCosmosDbCassandraKeyspace() *pluginsdk.Resource { Delete: resourceCosmosDbCassandraKeyspaceDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.CassandraKeyspaceID(id) + _, err := cosmosdb.ParseCassandraKeyspaceID(id) return err }), @@ -76,52 +74,42 @@ func resourceCosmosDbCassandraKeyspace() *pluginsdk.Resource { } func resourceCosmosDbCassandraKeyspaceCreate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.CassandraClient - subscriptionId := meta.(*clients.Client).Account.SubscriptionId + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - id := parse.NewCassandraKeyspaceID(subscriptionId, d.Get("resource_group_name").(string), d.Get("account_name").(string), d.Get("name").(string)) + id := cosmosdb.NewCassandraKeyspaceID(meta.(*clients.Client).Account.SubscriptionId, d.Get("resource_group_name").(string), d.Get("account_name").(string), d.Get("name").(string)) - existing, err := client.GetCassandraKeyspace(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name) - if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { + existing, err := client.CassandraResourcesGetCassandraKeyspace(ctx, id) + if !response.WasNotFound(existing.HttpResponse) { + if err != nil { return fmt.Errorf("checking for presence of creating %s: %+v", id, err) } - } else { - if existing.ID == nil && *existing.ID == "" { - return fmt.Errorf("generating import ID for %s", id) - } - - return tf.ImportAsExistsError("azurerm_cosmosdb_cassandra_keyspace", *existing.ID) + return tf.ImportAsExistsError("azurerm_cosmosdb_cassandra_keyspace", id.ID()) } - db := documentdb.CassandraKeyspaceCreateUpdateParameters{ - CassandraKeyspaceCreateUpdateProperties: &documentdb.CassandraKeyspaceCreateUpdateProperties{ - Resource: &documentdb.CassandraKeyspaceResource{ - ID: &id.Name, + db := cosmosdb.CassandraKeyspaceCreateUpdateParameters{ + Properties: cosmosdb.CassandraKeyspaceCreateUpdateProperties{ + Options: &cosmosdb.CreateUpdateOptions{}, + Resource: cosmosdb.CassandraKeyspaceResource{ + Id: id.CassandraKeyspaceName, }, - Options: &documentdb.CreateUpdateOptions{}, }, } - if throughput, hasThroughput := d.GetOk("throughput"); hasThroughput { + if throughput, ok := d.GetOk("throughput"); ok { if throughput != 0 { - db.Options.Throughput = common.ConvertThroughputFromResourceDataLegacy(throughput) + db.Properties.Options.Throughput = common.ConvertThroughputFromResourceData(throughput) } } - if _, hasAutoscaleSettings := d.GetOk("autoscale_settings"); hasAutoscaleSettings { - db.Options.AutoscaleSettings = common.ExpandCosmosDbAutoscaleSettingsLegacy(d) + if _, ok := d.GetOk("autoscale_settings"); ok { + db.Properties.Options.AutoScaleSettings = common.ExpandCosmosDbAutoscaleSettings(d) } - future, err := client.CreateUpdateCassandraKeyspace(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name, db) - if err != nil { - return fmt.Errorf("issuing create/update request for %s: %+v", id, err) - } - - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting on create/update future for %s: %+v", id, err) + if err := client.CassandraResourcesCreateUpdateCassandraKeyspaceThenPoll(ctx, id, db); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) } d.SetId(id.ID()) @@ -130,50 +118,27 @@ func resourceCosmosDbCassandraKeyspaceCreate(d *pluginsdk.ResourceData, meta int } func resourceCosmosDbCassandraKeyspaceUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.CassandraClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.CassandraKeyspaceID(d.Id()) + id, err := cosmosdb.ParseCassandraKeyspaceID(d.Id()) if err != nil { return err } - err = common.CheckForChangeFromAutoscaleAndManualThroughput(d) - if err != nil { - return fmt.Errorf("updating Cosmos Cassandra Keyspace %q (Account: %q) - %+v", id.Name, id.DatabaseAccountName, err) - } - - db := documentdb.CassandraKeyspaceCreateUpdateParameters{ - CassandraKeyspaceCreateUpdateProperties: &documentdb.CassandraKeyspaceCreateUpdateProperties{ - Resource: &documentdb.CassandraKeyspaceResource{ - ID: &id.Name, - }, - Options: &documentdb.CreateUpdateOptions{}, - }, - } - - future, err := client.CreateUpdateCassandraKeyspace(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name, db) - if err != nil { - return fmt.Errorf("issuing create/update request for Cosmos Cassandra Keyspace %q (Account: %q): %+v", id.ResourceGroup, id.DatabaseAccountName, err) + if err := common.CheckForChangeFromAutoscaleAndManualThroughput(d); err != nil { + return fmt.Errorf("checking `autoscale_settings` and `throughput` for %s: %w", id, err) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting on create/update future for Cosmos Cassandra Keyspace %q (Account: %q): %+v", id.ResourceGroup, id.DatabaseAccountName, err) + if _, err := client.CassandraResourcesGetCassandraKeyspace(ctx, *id); err != nil { + return fmt.Errorf("retrieving %s: %w", id, err) } if common.HasThroughputChange(d) { - throughputParameters := common.ExpandCosmosDBThroughputSettingsUpdateParametersLegacy(d) - throughputFuture, err := client.UpdateCassandraKeyspaceThroughput(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name, *throughputParameters) - if err != nil { - if response.WasNotFound(throughputFuture.Response()) { - return fmt.Errorf("setting Throughput for Cosmos Cassandra Keyspace %q (Account: %q): %+v - "+ - "If the collection has not been created with an initial throughput, you cannot configure it later", id.Name, id.DatabaseAccountName, err) - } - } - - if err = throughputFuture.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting on ThroughputUpdate future for Cosmos Cassandra Keyspace %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) + if err := client.CassandraResourcesUpdateCassandraKeyspaceThroughputThenPoll(ctx, *id, common.ExpandCosmosDBThroughputSettingsUpdateParameters(d)); err != nil { + return fmt.Errorf("setting Throughput for %s: %+v - If the collection has not been created with an initial throughput, you cannot configure it later", id, err) } } @@ -181,79 +146,73 @@ func resourceCosmosDbCassandraKeyspaceUpdate(d *pluginsdk.ResourceData, meta int } func resourceCosmosDbCassandraKeyspaceRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.CassandraClient - accountClient := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.CassandraKeyspaceID(d.Id()) + id, err := cosmosdb.ParseCassandraKeyspaceID(d.Id()) if err != nil { return err } - resp, err := client.GetCassandraKeyspace(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name) + resp, err := client.CassandraResourcesGetCassandraKeyspace(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[INFO] Error reading Cosmos Cassandra Keyspace %q (Account: %q) - removing from state", id.Name, id.DatabaseAccountName) + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("reading Cosmos Cassandra Keyspace %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } - d.Set("resource_group_name", id.ResourceGroup) + d.Set("resource_group_name", id.ResourceGroupName) d.Set("account_name", id.DatabaseAccountName) - if props := resp.CassandraKeyspaceGetProperties; props != nil { - if res := props.Resource; res != nil { - d.Set("name", res.ID) + + if resp.Model != nil { + if props := resp.Model.Properties; props != nil { + if res := props.Resource; res != nil { + d.Set("name", res.Id) + } } } - accResp, err := accountClient.Get(ctx, id.ResourceGroup, id.DatabaseAccountName) + databaseAccountID := cosmosdb.NewDatabaseAccountID(id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName) + accResp, err := client.DatabaseAccountsGet(ctx, databaseAccountID) if err != nil { - return fmt.Errorf("reading Cosmos Account %q : %+v", id.DatabaseAccountName, err) - } - if accResp.ID == nil || *accResp.ID == "" { - return fmt.Errorf("cosmosDB Account %q (Resource Group %q) ID is empty or nil", id.DatabaseAccountName, id.ResourceGroup) + return fmt.Errorf("retrieving %s: %+v", databaseAccountID, err) } - if !isServerlessCapacityMode(accResp) { - throughputResp, err := client.GetCassandraKeyspaceThroughput(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name) + if !isServerlessCapacityMode(accResp.Model) { + throughputResp, err := client.CassandraResourcesGetCassandraKeyspaceThroughput(ctx, *id) if err != nil { - if !utils.ResponseWasNotFound(throughputResp.Response) { - return fmt.Errorf("reading Throughput on Cosmos Cassandra Keyspace %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) - } else { - d.Set("throughput", nil) - d.Set("autoscale_settings", nil) + if !response.WasNotFound(throughputResp.HttpResponse) { + return fmt.Errorf("retrieving Throughput for %s: %+v", id, err) } + + d.Set("throughput", nil) + d.Set("autoscale_settings", nil) } else { - common.SetResourceDataThroughputFromResponseLegacy(throughputResp, d) + common.SetResourceDataThroughputFromResponse(pointer.From(throughputResp.Model), d) } } + return nil } func resourceCosmosDbCassandraKeyspaceDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.CassandraClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.CassandraKeyspaceID(d.Id()) + id, err := cosmosdb.ParseCassandraKeyspaceID(d.Id()) if err != nil { return err } - future, err := client.DeleteCassandraKeyspace(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name) - if err != nil { - if !response.WasNotFound(future.Response()) { - return fmt.Errorf("deleting Cosmos Cassandra Keyspace %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) - } - } - - err = future.WaitForCompletionRef(ctx, client.Client) - if err != nil { - return fmt.Errorf("waiting on delete future for Cosmos Cassandra Keyspace %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) + if err := client.CassandraResourcesDeleteCassandraKeyspaceThenPoll(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", id, err) } return nil diff --git a/internal/services/cosmos/cosmosdb_cassandra_keyspace_resource_test.go b/internal/services/cosmos/cosmosdb_cassandra_keyspace_resource_test.go index 1393eea04958..878670555e45 100644 --- a/internal/services/cosmos/cosmosdb_cassandra_keyspace_resource_test.go +++ b/internal/services/cosmos/cosmosdb_cassandra_keyspace_resource_test.go @@ -13,7 +13,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) @@ -34,6 +33,21 @@ func TestAccCosmosDbCassandraKeyspace_basic(t *testing.T) { }) } +func TestAccCosmosDbCassandraKeyspace_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_cosmosdb_cassandra_keyspace", "test") + r := CosmosDbCassandraKeyspaceResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeAggregateTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.RequiresImportErrorStep(r.requiresImport), + }) +} + func TestAccCosmosDbCassandraKeyspace_complete(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_cosmosdb_cassandra_keyspace", "test") r := CosmosDbCassandraKeyspaceResource{} @@ -121,18 +135,18 @@ func TestAccCosmosDbCassandraKeyspace_serverless(t *testing.T) { }) } -func (t CosmosDbCassandraKeyspaceResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.CassandraKeyspaceID(state.ID) +func (r CosmosDbCassandraKeyspaceResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := cosmosdb.ParseCassandraKeyspaceID(state.ID) if err != nil { return nil, err } - resp, err := clients.Cosmos.CassandraClient.GetCassandraKeyspace(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name) + resp, err := clients.Cosmos.CosmosDBClient.CassandraResourcesGetCassandraKeyspace(ctx, *id) if err != nil { - return nil, fmt.Errorf("reading Cosmos Cassandra Keyspace (%s): %+v", id.String(), err) + return nil, fmt.Errorf("retrieving %s: %+v", id, err) } - return pointer.To(resp.ID != nil), nil + return pointer.To(resp.Model != nil), nil } func (CosmosDbCassandraKeyspaceResource) basic(data acceptance.TestData) string { @@ -147,6 +161,18 @@ resource "azurerm_cosmosdb_cassandra_keyspace" "test" { `, CosmosDBAccountResource{}.capabilities(data, cosmosdb.DatabaseAccountKindGlobalDocumentDB, []string{"EnableCassandra"}), data.RandomInteger) } +func (r CosmosDbCassandraKeyspaceResource) requiresImport(data acceptance.TestData) string { + return fmt.Sprintf(` +%[1]s + +resource "azurerm_cosmosdb_cassandra_keyspace" "import" { + name = azurerm_cosmosdb_cassandra_keyspace.test.name + resource_group_name = azurerm_cosmosdb_cassandra_keyspace.test.resource_group_name + account_name = azurerm_cosmosdb_cassandra_keyspace.test.account_name +} +`, r.basic(data), data.RandomInteger) +} + func (CosmosDbCassandraKeyspaceResource) throughput(data acceptance.TestData, throughput int) string { return fmt.Sprintf(` %[1]s From 6c9ae04b004b88dda6c3e6ceb99d8192c9068554 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:20:46 -0600 Subject: [PATCH 04/25] `azurerm_cosmosdb_cassandra_table` - migrate to `go-azure-sdk` --- .../cosmosdb_cassandra_table_resource.go | 230 ++++++++---------- .../cosmosdb_cassandra_table_resource_test.go | 10 +- 2 files changed, 104 insertions(+), 136 deletions(-) diff --git a/internal/services/cosmos/cosmosdb_cassandra_table_resource.go b/internal/services/cosmos/cosmosdb_cassandra_table_resource.go index 930d7d78918e..be92b434b73b 100644 --- a/internal/services/cosmos/cosmosdb_cassandra_table_resource.go +++ b/internal/services/cosmos/cosmosdb_cassandra_table_resource.go @@ -5,22 +5,19 @@ package cosmos import ( "fmt" - "log" "math" "time" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb" // nolint: staticcheck "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/common" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceCosmosDbCassandraTable() *pluginsdk.Resource { @@ -31,7 +28,7 @@ func resourceCosmosDbCassandraTable() *pluginsdk.Resource { Delete: resourceCosmosDbCassandraTableDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.CassandraTableID(id) + _, err := cosmosdb.ParseCassandraKeyspaceTableID(id) return err }), @@ -54,7 +51,7 @@ func resourceCosmosDbCassandraTable() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.CassandraKeyspaceID, + ValidateFunc: cosmosdb.ValidateCassandraKeyspaceID, }, "default_ttl": { @@ -88,126 +85,117 @@ func resourceCosmosDbCassandraTable() *pluginsdk.Resource { } func resourceCosmosDbCassandraTableCreate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.CassandraClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - name := d.Get("name").(string) - keyspaceId, err := parse.CassandraKeyspaceID(d.Get("cassandra_keyspace_id").(string)) + keyspaceId, err := cosmosdb.ParseCassandraKeyspaceID(d.Get("cassandra_keyspace_id").(string)) if err != nil { - return fmt.Errorf("parsing Cassandra Keyspace ID: %+v", err) + return err } - account := keyspaceId.DatabaseAccountName - keyspace := keyspaceId.Name - resourceGroup := keyspaceId.ResourceGroup - subscriptionId := meta.(*clients.Client).Account.SubscriptionId - id := parse.NewCassandraTableID(subscriptionId, resourceGroup, account, keyspace, name) - existing, err := client.GetCassandraTable(ctx, resourceGroup, account, keyspace, name) - if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { + id := cosmosdb.NewCassandraKeyspaceTableID(meta.(*clients.Client).Account.SubscriptionId, keyspaceId.ResourceGroupName, keyspaceId.DatabaseAccountName, keyspaceId.CassandraKeyspaceName, d.Get("name").(string)) + + existing, err := client.CassandraResourcesGetCassandraTable(ctx, id) + if !response.WasNotFound(existing.HttpResponse) { + if err != nil { return fmt.Errorf("checking for presence of existing %+v: %+v", id, err) } - } else { - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_cosmosdb_cassandra_table", id.ID()) - } + return tf.ImportAsExistsError("azurerm_cosmosdb_cassandra_table", id.ID()) } - table := documentdb.CassandraTableCreateUpdateParameters{ - CassandraTableCreateUpdateProperties: &documentdb.CassandraTableCreateUpdateProperties{ - Resource: &documentdb.CassandraTableResource{ - ID: &name, + table := cosmosdb.CassandraTableCreateUpdateParameters{ + Properties: cosmosdb.CassandraTableCreateUpdateProperties{ + Options: &cosmosdb.CreateUpdateOptions{}, + Resource: cosmosdb.CassandraTableResource{ + Id: id.TableName, + Schema: expandTableSchema(d), }, - Options: &documentdb.CreateUpdateOptions{}, }, } - table.Resource.Schema = expandTableSchema(d) - - if defaultTTL, hasTTL := d.GetOk("default_ttl"); hasTTL { - table.Resource.DefaultTTL = pointer.To(int32(defaultTTL.(int))) + if defaultTTL, ok := d.GetOk("default_ttl"); ok { + table.Properties.Resource.DefaultTtl = pointer.To(int64(defaultTTL.(int))) } if analyticalTTL, ok := d.GetOk("analytical_storage_ttl"); ok { - table.Resource.AnalyticalStorageTTL = pointer.To(int32(analyticalTTL.(int))) + table.Properties.Resource.AnalyticalStorageTtl = pointer.To(int64(analyticalTTL.(int))) } if throughput, hasThroughput := d.GetOk("throughput"); hasThroughput { if throughput != 0 { - table.Options.Throughput = common.ConvertThroughputFromResourceDataLegacy(throughput) + table.Properties.Options.Throughput = common.ConvertThroughputFromResourceData(throughput) } } if _, hasAutoscaleSettings := d.GetOk("autoscale_settings"); hasAutoscaleSettings { - table.Options.AutoscaleSettings = common.ExpandCosmosDbAutoscaleSettingsLegacy(d) + table.Properties.Options.AutoScaleSettings = common.ExpandCosmosDbAutoscaleSettings(d) } - future, err := client.CreateUpdateCassandraTable(ctx, resourceGroup, account, keyspace, name, table) - if err != nil { + if err := client.CassandraResourcesCreateUpdateCassandraTableThenPoll(ctx, id, table); err != nil { return fmt.Errorf("creating %s: %+v", id, err) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for creation of %s: %+v", id, err) - } - d.SetId(id.ID()) return resourceCosmosDbCassandraTableRead(d, meta) } func resourceCosmosDbCassandraTableUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.CassandraClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.CassandraTableID(d.Id()) + id, err := cosmosdb.ParseCassandraKeyspaceTableID(d.Id()) if err != nil { return err } - err = common.CheckForChangeFromAutoscaleAndManualThroughput(d) - if err != nil { - return fmt.Errorf("updating %s: %+v", *id, err) + if err := common.CheckForChangeFromAutoscaleAndManualThroughput(d); err != nil { + return fmt.Errorf("checking `autoscale_settings` and `throughput` for %s: %w", id, err) } - table := documentdb.CassandraTableCreateUpdateParameters{ - CassandraTableCreateUpdateProperties: &documentdb.CassandraTableCreateUpdateProperties{ - Resource: &documentdb.CassandraTableResource{ - ID: &id.TableName, - }, - Options: &documentdb.CreateUpdateOptions{}, - }, + existing, err := client.CassandraResourcesGetCassandraTable(ctx, *id) + if err != nil { + return fmt.Errorf("retrieving %s: %w", id, err) } - table.Resource.Schema = expandTableSchema(d) + if existing.Model == nil { + return fmt.Errorf("retrieving %s: model was nil", id) + } - if defaultTTL, hasTTL := d.GetOk("default_ttl"); hasTTL { - table.Resource.DefaultTTL = pointer.To(int32(defaultTTL.(int))) + if existing.Model.Properties == nil { + return fmt.Errorf("retrieving %s: properties was nil", id) } - future, err := client.CreateUpdateCassandraTable(ctx, id.ResourceGroup, id.DatabaseAccountName, id.CassandraKeyspaceName, id.TableName, table) - if err != nil { - return fmt.Errorf("updating %s: %+v", *id, err) + if existing.Model.Properties.Resource == nil { + return fmt.Errorf("retrieving %s: resource was nil", id) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for update of %s: %+v", *id, err) + table := cosmosdb.CassandraTableCreateUpdateParameters{ + Properties: cosmosdb.CassandraTableCreateUpdateProperties{ + Resource: cosmosdb.CassandraTableResource{ + Id: id.TableName, + Schema: existing.Model.Properties.Resource.Schema, + DefaultTtl: existing.Model.Properties.Resource.DefaultTtl, + }, + Options: &cosmosdb.CreateUpdateOptions{}, + }, } - if common.HasThroughputChange(d) { - throughputParameters := common.ExpandCosmosDBThroughputSettingsUpdateParametersLegacy(d) - throughputFuture, err := client.UpdateCassandraTableThroughput(ctx, id.ResourceGroup, id.DatabaseAccountName, id.CassandraKeyspaceName, id.TableName, *throughputParameters) - if err != nil { - if response.WasNotFound(throughputFuture.Response()) { - return fmt.Errorf("setting Throughput for %s: %+v - "+ - "If the collection has not been created with an initial throughput, you cannot configure it later", *id, err) - } + if d.HasChange("default_ttl") { + table.Properties.Resource.DefaultTtl = pointer.To(int64(d.Get("default_ttl").(int))) + + if err := client.CassandraResourcesCreateUpdateCassandraTableThenPoll(ctx, *id, table); err != nil { + return fmt.Errorf("updating %s: %+v", *id, err) } + } - if err = throughputFuture.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("updating Throughput for %s: %+v", *id, err) + if common.HasThroughputChange(d) { + if err := client.CassandraResourcesUpdateCassandraTableThroughputThenPoll(ctx, *id, common.ExpandCosmosDBThroughputSettingsUpdateParameters(d)); err != nil { + return fmt.Errorf("setting Throughput for %s: %+v - If the collection has not been created with an initial throughput, you cannot configure it later", id, err) } } @@ -215,21 +203,19 @@ func resourceCosmosDbCassandraTableUpdate(d *pluginsdk.ResourceData, meta interf } func resourceCosmosDbCassandraTableRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.CassandraClient - accountClient := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) - subscriptionId := meta.(*clients.Client).Account.SubscriptionId defer cancel() - id, err := parse.CassandraTableID(d.Id()) + id, err := cosmosdb.ParseCassandraKeyspaceTableID(d.Id()) if err != nil { return err } - resp, err := client.GetCassandraTable(ctx, id.ResourceGroup, id.DatabaseAccountName, id.CassandraKeyspaceName, id.TableName) + resp, err := client.CassandraResourcesGetCassandraTable(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[INFO] %s was not found - removing from state", *id) + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } @@ -237,78 +223,60 @@ func resourceCosmosDbCassandraTableRead(d *pluginsdk.ResourceData, meta interfac return fmt.Errorf("retrieving %s: %+v", *id, err) } - keyspaceId := parse.NewCassandraKeyspaceID(subscriptionId, id.ResourceGroup, id.DatabaseAccountName, id.CassandraKeyspaceName) - - d.Set("cassandra_keyspace_id", keyspaceId.ID()) - if props := resp.CassandraTableGetProperties; props != nil { - if res := props.Resource; res != nil { - d.Set("name", res.ID) + d.Set("cassandra_keyspace_id", cosmosdb.NewCassandraKeyspaceID(id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.CassandraKeyspaceName).ID()) + d.Set("name", id.TableName) - if defaultTTL := res.DefaultTTL; defaultTTL != nil { - d.Set("default_ttl", defaultTTL) - } - - var analyticalTTL int - if res.AnalyticalStorageTTL != nil { - analyticalTTL = int(*res.AnalyticalStorageTTL) - } - d.Set("analytical_storage_ttl", analyticalTTL) - - if schema := res.Schema; schema != nil { - d.Set("schema", flattenTableSchema(schema)) + if respModel := resp.Model; respModel != nil { + if props := respModel.Properties; props != nil { + if res := props.Resource; res != nil { + d.Set("default_ttl", res.DefaultTtl) + d.Set("analytical_storage_ttl", pointer.From(res.AnalyticalStorageTtl)) + d.Set("schema", flattenTableSchema(res.Schema)) } } } - accResp, err := accountClient.Get(ctx, id.ResourceGroup, id.DatabaseAccountName) + + databaseAccountID := cosmosdb.NewDatabaseAccountID(id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName) + accResp, err := client.DatabaseAccountsGet(ctx, databaseAccountID) if err != nil { - return fmt.Errorf("reading Cosmos Account %q : %+v", id.DatabaseAccountName, err) - } - if accResp.ID == nil || *accResp.ID == "" { - return fmt.Errorf("cosmosDB Account %q (Resource Group %q) ID is empty or nil", id.DatabaseAccountName, id.ResourceGroup) + return fmt.Errorf("retrieving %s: %+v", databaseAccountID, err) } - if !isServerlessCapacityMode(accResp) { - throughputResp, err := client.GetCassandraTableThroughput(ctx, id.ResourceGroup, id.DatabaseAccountName, id.CassandraKeyspaceName, id.TableName) + if !isServerlessCapacityMode(accResp.Model) { + throughputResp, err := client.CassandraResourcesGetCassandraTableThroughput(ctx, *id) if err != nil { - if !utils.ResponseWasNotFound(throughputResp.Response) { + if !response.WasNotFound(throughputResp.HttpResponse) { return fmt.Errorf("retrieving Throughput for %s: %+v", *id, err) } else { d.Set("throughput", nil) d.Set("autoscale_settings", nil) } } else { - common.SetResourceDataThroughputFromResponseLegacy(throughputResp, d) + common.SetResourceDataThroughputFromResponse(pointer.From(throughputResp.Model), d) } } return nil } func resourceCosmosDbCassandraTableDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.CassandraClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.CassandraTableID(d.Id()) + id, err := cosmosdb.ParseCassandraKeyspaceTableID(d.Id()) if err != nil { return err } - future, err := client.DeleteCassandraTable(ctx, id.ResourceGroup, id.DatabaseAccountName, id.CassandraKeyspaceName, id.TableName) - if err != nil { - if !response.WasNotFound(future.Response()) { - return fmt.Errorf("deleting %s: %+v", *id, err) - } - } - - err = future.WaitForCompletionRef(ctx, client.Client) - if err != nil { - return fmt.Errorf("waiting for deletion of %s: %+v", *id, err) + if err := client.CassandraResourcesDeleteCassandraTableThenPoll(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) } return nil } -func expandTableSchema(d *pluginsdk.ResourceData) *documentdb.CassandraSchema { +func expandTableSchema(d *pluginsdk.ResourceData) *cosmosdb.CassandraSchema { i := d.Get("schema").([]interface{}) if len(i) == 0 || i[0] == nil { @@ -316,7 +284,7 @@ func expandTableSchema(d *pluginsdk.ResourceData) *documentdb.CassandraSchema { } input := i[0].(map[string]interface{}) - cassandraSchema := documentdb.CassandraSchema{} + cassandraSchema := cosmosdb.CassandraSchema{} if v, ok := input["column"].([]interface{}); ok { cassandraSchema.Columns = expandTableSchemaColumns(v) @@ -333,11 +301,11 @@ func expandTableSchema(d *pluginsdk.ResourceData) *documentdb.CassandraSchema { return &cassandraSchema } -func expandTableSchemaColumns(input []interface{}) *[]documentdb.Column { - columns := make([]documentdb.Column, 0) +func expandTableSchemaColumns(input []interface{}) *[]cosmosdb.Column { + columns := make([]cosmosdb.Column, 0) for _, col := range input { data := col.(map[string]interface{}) - column := documentdb.Column{ + column := cosmosdb.Column{ Name: pointer.To(data["name"].(string)), Type: pointer.To(data["type"].(string)), } @@ -347,11 +315,11 @@ func expandTableSchemaColumns(input []interface{}) *[]documentdb.Column { return &columns } -func expandTableSchemaPartitionKeys(input []interface{}) *[]documentdb.CassandraPartitionKey { - keys := make([]documentdb.CassandraPartitionKey, 0) +func expandTableSchemaPartitionKeys(input []interface{}) *[]cosmosdb.CassandraPartitionKey { + keys := make([]cosmosdb.CassandraPartitionKey, 0) for _, key := range input { data := key.(map[string]interface{}) - k := documentdb.CassandraPartitionKey{ + k := cosmosdb.CassandraPartitionKey{ Name: pointer.To(data["name"].(string)), } keys = append(keys, k) @@ -360,11 +328,11 @@ func expandTableSchemaPartitionKeys(input []interface{}) *[]documentdb.Cassandra return &keys } -func expandTableSchemaClusterKeys(input []interface{}) *[]documentdb.ClusterKey { - keys := make([]documentdb.ClusterKey, 0) +func expandTableSchemaClusterKeys(input []interface{}) *[]cosmosdb.ClusterKey { + keys := make([]cosmosdb.ClusterKey, 0) for _, key := range input { data := key.(map[string]interface{}) - k := documentdb.ClusterKey{ + k := cosmosdb.ClusterKey{ Name: pointer.To(data["name"].(string)), OrderBy: pointer.To(data["order_by"].(string)), } @@ -374,7 +342,7 @@ func expandTableSchemaClusterKeys(input []interface{}) *[]documentdb.ClusterKey return &keys } -func flattenTableSchema(input *documentdb.CassandraSchema) []interface{} { +func flattenTableSchema(input *cosmosdb.CassandraSchema) []interface{} { results := make([]interface{}, 0) if input == nil { return results @@ -389,7 +357,7 @@ func flattenTableSchema(input *documentdb.CassandraSchema) []interface{} { return results } -func flattenTableSchemaColumns(input *[]documentdb.Column) []interface{} { +func flattenTableSchemaColumns(input *[]cosmosdb.Column) []interface{} { if input == nil { return nil } @@ -414,7 +382,7 @@ func flattenTableSchemaColumns(input *[]documentdb.Column) []interface{} { return columns } -func flattenTableSchemaPartitionKeys(input *[]documentdb.CassandraPartitionKey) []interface{} { +func flattenTableSchemaPartitionKeys(input *[]cosmosdb.CassandraPartitionKey) []interface{} { if input == nil { return nil } @@ -434,7 +402,7 @@ func flattenTableSchemaPartitionKeys(input *[]documentdb.CassandraPartitionKey) return keys } -func flattenTableSchemaClusterKeys(input *[]documentdb.ClusterKey) []interface{} { +func flattenTableSchemaClusterKeys(input *[]cosmosdb.ClusterKey) []interface{} { if input == nil { return nil } diff --git a/internal/services/cosmos/cosmosdb_cassandra_table_resource_test.go b/internal/services/cosmos/cosmosdb_cassandra_table_resource_test.go index 70fde8393848..4b791d8d0f44 100644 --- a/internal/services/cosmos/cosmosdb_cassandra_table_resource_test.go +++ b/internal/services/cosmos/cosmosdb_cassandra_table_resource_test.go @@ -9,27 +9,27 @@ import ( "testing" "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) type CosmosDBCassandraTableResource struct{} func (t CosmosDBCassandraTableResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.CassandraTableID(state.ID) + id, err := cosmosdb.ParseCassandraKeyspaceTableID(state.ID) if err != nil { return nil, err } - resp, err := clients.Cosmos.CassandraClient.GetCassandraTable(ctx, id.ResourceGroup, id.DatabaseAccountName, id.CassandraKeyspaceName, id.TableName) + resp, err := clients.Cosmos.CosmosDBClient.CassandraResourcesGetCassandraTable(ctx, *id) if err != nil { - return nil, fmt.Errorf("reading Cosmos Cassandra Table (%s): %+v", id.String(), err) + return nil, fmt.Errorf("retrieving %s: %+v", id, err) } - return pointer.To(resp.ID != nil), nil + return pointer.To(resp.Model != nil), nil } func TestAccCosmosDbCassandraTable_basic(t *testing.T) { From c82804481227a77d5de7bf932d6d4d7e71e7c16a Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:22:32 -0600 Subject: [PATCH 05/25] `azurerm_cosmosdb_gremlin_database` - migrate to `go-azure-sdk` --- .../cosmosdb_gremlin_database_resource.go | 50 ++++++------------- ...cosmosdb_gremlin_database_resource_test.go | 2 +- 2 files changed, 15 insertions(+), 37 deletions(-) diff --git a/internal/services/cosmos/cosmosdb_gremlin_database_resource.go b/internal/services/cosmos/cosmosdb_gremlin_database_resource.go index bf1b166926c0..91912b31e43f 100644 --- a/internal/services/cosmos/cosmosdb_gremlin_database_resource.go +++ b/internal/services/cosmos/cosmosdb_gremlin_database_resource.go @@ -5,7 +5,6 @@ package cosmos import ( "fmt" - "log" "time" "github.com/hashicorp/go-azure-helpers/lang/response" @@ -15,7 +14,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/common" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/migration" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -29,7 +27,7 @@ func resourceCosmosGremlinDatabase() *pluginsdk.Resource { Delete: resourceCosmosGremlinDatabaseDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.GremlinDatabaseID(id) + _, err := cosmosdb.ParseGremlinDatabaseID(id) return err }), @@ -76,11 +74,11 @@ func resourceCosmosGremlinDatabase() *pluginsdk.Resource { func resourceCosmosGremlinDatabaseCreate(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).Cosmos.CosmosDBClient - subscriptionId := meta.(*clients.Client).Account.SubscriptionId + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - id := cosmosdb.NewGremlinDatabaseID(subscriptionId, d.Get("resource_group_name").(string), d.Get("account_name").(string), d.Get("name").(string)) + id := cosmosdb.NewGremlinDatabaseID(meta.(*clients.Client).Account.SubscriptionId, d.Get("resource_group_name").(string), d.Get("account_name").(string), d.Get("name").(string)) existing, err := client.GremlinResourcesGetGremlinDatabase(ctx, id) if err != nil { @@ -133,7 +131,7 @@ func resourceCosmosGremlinDatabaseUpdate(d *pluginsdk.ResourceData, meta interfa err = common.CheckForChangeFromAutoscaleAndManualThroughput(d) if err != nil { - return fmt.Errorf("updating Cosmos Gremlin Database %q (Account: %q) - %+v", id.GremlinDatabaseName, id.DatabaseAccountName, err) + return fmt.Errorf("checking `autoscale_settings` and `throughput` for %s: %w", id, err) } db := cosmosdb.GremlinDatabaseCreateUpdateParameters{ @@ -151,30 +149,16 @@ func resourceCosmosGremlinDatabaseUpdate(d *pluginsdk.ResourceData, meta interfa } if common.HasThroughputChange(d) { - throughputParameters := common.ExpandCosmosDBThroughputSettingsUpdateParameters(d) - throughputFuture, err := client.GremlinResourcesUpdateGremlinDatabaseThroughput(ctx, *id, *throughputParameters) - if err != nil { - if response.WasNotFound(throughputFuture.HttpResponse) { - return fmt.Errorf("setting Throughput for Cosmos Gremlin Database %q (Account: %q): %+v - "+ - "If the collection has not been created with and initial throughput, you cannot configure it later", id.GremlinDatabaseName, id.DatabaseAccountName, err) - } - } - - if err := throughputFuture.Poller.PollUntilDone(ctx); err != nil { - return fmt.Errorf("waiting on ThroughputUpdate future for Cosmos Gremlin Database %q (Account: %q, Database %q): %+v", id.GremlinDatabaseName, id.DatabaseAccountName, id.GremlinDatabaseName, err) + if err := client.GremlinResourcesUpdateGremlinDatabaseThroughputThenPoll(ctx, *id, common.ExpandCosmosDBThroughputSettingsUpdateParameters(d)); err != nil { + return fmt.Errorf("setting Throughput for %s: %+v - If the collection has not been created with and initial throughput, you cannot configure it later", id, err) } } - if _, err = client.GremlinResourcesGetGremlinDatabase(ctx, *id); err != nil { - return fmt.Errorf("making get request for Cosmos Gremlin Database %q (Account: %q): %+v", id.GremlinDatabaseName, id.DatabaseAccountName, err) - } - return resourceCosmosGremlinDatabaseRead(d, meta) } func resourceCosmosGremlinDatabaseRead(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).Cosmos.CosmosDBClient - accClient := meta.(*clients.Client).Cosmos.DatabaseClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -186,34 +170,28 @@ func resourceCosmosGremlinDatabaseRead(d *pluginsdk.ResourceData, meta interface resp, err := client.GremlinResourcesGetGremlinDatabase(ctx, *id) if err != nil { if response.WasNotFound(resp.HttpResponse) { - log.Printf("[INFO] Error reading %q - removing from state", id) d.SetId("") return nil } - return fmt.Errorf("reading %q: %+v", id, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } d.Set("resource_group_name", id.ResourceGroupName) d.Set("account_name", id.DatabaseAccountName) - if model := resp.Model; model != nil { - if props := model.Properties; props != nil { - if res := props.Resource; res != nil { - d.Set("name", res.Id) - } - } - } + d.Set("name", id.GremlinDatabaseName) - accResp, err := accClient.Get(ctx, id.ResourceGroupName, id.DatabaseAccountName) + databaseAccountID := cosmosdb.NewDatabaseAccountID(id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName) + accResp, err := client.DatabaseAccountsGet(ctx, databaseAccountID) if err != nil { - return fmt.Errorf("reading Cosmos Account %q : %+v", id.DatabaseAccountName, err) + return fmt.Errorf("retrieving %s: %+v", databaseAccountID, err) } - if !isServerlessCapacityMode(accResp) { + if !isServerlessCapacityMode(accResp.Model) { throughputResp, err := client.GremlinResourcesGetGremlinDatabaseThroughput(ctx, *id) if err != nil { if !response.WasNotFound(throughputResp.HttpResponse) { - return fmt.Errorf("reading Throughput on Cosmos Gremlin Database %q (Account: %q): %+v", id.GremlinDatabaseName, id.DatabaseAccountName, err) + return fmt.Errorf("retrieving Throughput for %s: %+v", id, err) } else { d.Set("throughput", nil) d.Set("autoscale_settings", nil) @@ -238,7 +216,7 @@ func resourceCosmosGremlinDatabaseDelete(d *pluginsdk.ResourceData, meta interfa err = client.GremlinResourcesDeleteGremlinDatabaseThenPoll(ctx, *id) if err != nil { - return fmt.Errorf("deleting Cosmos Gremlin Database %q (Account: %q): %+v", id.GremlinDatabaseName, id.DatabaseAccountName, err) + return fmt.Errorf("deleting %s: %+v", id, err) } return nil diff --git a/internal/services/cosmos/cosmosdb_gremlin_database_resource_test.go b/internal/services/cosmos/cosmosdb_gremlin_database_resource_test.go index 8c88fa2410bb..15e0787853e4 100644 --- a/internal/services/cosmos/cosmosdb_gremlin_database_resource_test.go +++ b/internal/services/cosmos/cosmosdb_gremlin_database_resource_test.go @@ -130,7 +130,7 @@ func (t CosmosGremlinDatabaseResource) Exists(ctx context.Context, clients *clie resp, err := clients.Cosmos.CosmosDBClient.GremlinResourcesGetGremlinDatabase(ctx, *id) if err != nil { - return nil, fmt.Errorf("reading Cosmos Gremlin Database (%s): %+v", id.String(), err) + return nil, fmt.Errorf("retrieving %s: %+v", id, err) } return pointer.To(resp.Model != nil), nil From ee3df82dfb3fe96abe7fb69466c589a39c75b8a4 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:24:41 -0600 Subject: [PATCH 06/25] `azurerm_cosmosdb_gremlin_graph` - migrate to `go-azure-sdk` --- .../cosmos/cosmosdb_gremlin_graph_resource.go | 40 ++++++++----------- .../cosmosdb_gremlin_graph_resource_test.go | 2 +- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/internal/services/cosmos/cosmosdb_gremlin_graph_resource.go b/internal/services/cosmos/cosmosdb_gremlin_graph_resource.go index bc4aedf5af69..5c9adb6d9b3b 100644 --- a/internal/services/cosmos/cosmosdb_gremlin_graph_resource.go +++ b/internal/services/cosmos/cosmosdb_gremlin_graph_resource.go @@ -6,7 +6,6 @@ package cosmos import ( "context" "fmt" - "log" "math" "strings" "time" @@ -19,7 +18,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/common" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/migration" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -35,7 +33,7 @@ func resourceCosmosDbGremlinGraph() *pluginsdk.Resource { Delete: resourceCosmosDbGremlinGraphDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.GremlinGraphID(id) + _, err := cosmosdb.ParseGraphID(id) return err }), @@ -285,7 +283,7 @@ func resourceCosmosDbGremlinGraphUpdate(d *pluginsdk.ResourceData, meta interfac err = common.CheckForChangeFromAutoscaleAndManualThroughput(d) if err != nil { - return fmt.Errorf("updating Cosmos Gremlin Graph %q (Account: %q, Database: %q): %+v", id.GraphName, id.DatabaseAccountName, id.GremlinDatabaseName, err) + return fmt.Errorf("checking `autoscale_settings` and `throughput` for %s: %w", id, err) } partitionkeypaths := d.Get("partition_key_path").(string) @@ -332,11 +330,8 @@ func resourceCosmosDbGremlinGraphUpdate(d *pluginsdk.ResourceData, meta interfac } if common.HasThroughputChange(d) { - throughputParameters := common.ExpandCosmosDBThroughputSettingsUpdateParameters(d) - err = client.GremlinResourcesUpdateGremlinGraphThroughputThenPoll(ctx, *id, *throughputParameters) - if err != nil { - return fmt.Errorf("setting Throughput for Cosmos Gremlin Graph %q (Account: %q, Database: %q): %+v - "+ - "If the graph has not been created with an initial throughput, you cannot configure it later", id.GraphName, id.DatabaseAccountName, id.GremlinDatabaseName, err) + if err := client.GremlinResourcesUpdateGremlinGraphThroughputThenPoll(ctx, *id, common.ExpandCosmosDBThroughputSettingsUpdateParameters(d)); err != nil { + return fmt.Errorf("setting Throughput for %s: %+v - If the graph has not been created with an initial throughput, you cannot configure it later", id, err) } } @@ -345,7 +340,6 @@ func resourceCosmosDbGremlinGraphUpdate(d *pluginsdk.ResourceData, meta interfac func resourceCosmosDbGremlinGraphRead(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).Cosmos.CosmosDBClient - accountClient := meta.(*clients.Client).Cosmos.DatabaseClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -357,12 +351,11 @@ func resourceCosmosDbGremlinGraphRead(d *pluginsdk.ResourceData, meta interface{ resp, err := client.GremlinResourcesGetGremlinGraph(ctx, *id) if err != nil { if response.WasNotFound(resp.HttpResponse) { - log.Printf("[INFO] Error reading %q - removing from state", id) d.SetId("") return nil } - return fmt.Errorf("reading %q: %+v", id, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } d.Set("name", id.GraphName) @@ -375,11 +368,10 @@ func resourceCosmosDbGremlinGraphRead(d *pluginsdk.ResourceData, meta interface{ if props := graphProperties.Resource; props != nil { if pk := props.PartitionKey; pk != nil { if paths := pk.Paths; paths != nil { - if len(*paths) > 1 { - return fmt.Errorf("reading PartitionKey Paths, more than 1 returned") - } else if len(*paths) == 1 { - d.Set("partition_key_path", (*paths)[0]) + if l := len(*paths); l > 1 { + return fmt.Errorf("retrieving `partition_key_path`, expected at most 1 path, got %d paths", l) } + d.Set("partition_key_path", (*paths)[0]) } if version := pk.Version; version != nil { @@ -415,19 +407,18 @@ func resourceCosmosDbGremlinGraphRead(d *pluginsdk.ResourceData, meta interface{ } } } - accResp, err := accountClient.Get(ctx, id.ResourceGroupName, id.DatabaseAccountName) + + databaseAccountID := cosmosdb.NewDatabaseAccountID(id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName) + accResp, err := client.DatabaseAccountsGet(ctx, databaseAccountID) if err != nil { - return fmt.Errorf("reading Cosmos Account %q : %+v", id.DatabaseAccountName, err) - } - if accResp.ID == nil || *accResp.ID == "" { - return fmt.Errorf("cosmosDB Account %q (Resource Group %q) ID is empty or nil", id.DatabaseAccountName, id.ResourceGroupName) + return fmt.Errorf("retrieving %s: %+v", databaseAccountID, err) } - if !isServerlessCapacityMode(accResp) { + if !isServerlessCapacityMode(accResp.Model) { throughputResp, err := client.GremlinResourcesGetGremlinGraphThroughput(ctx, *id) if err != nil { if !response.WasNotFound(throughputResp.HttpResponse) { - return fmt.Errorf("reading Throughput on Gremlin Graph %q (Account: %q, Database: %q) ID: %v", id.GraphName, id.DatabaseAccountName, id.GremlinDatabaseName, err) + return fmt.Errorf("retrieving Throughput for %s: %v", id, err) } else { d.Set("throughput", nil) d.Set("autoscale_settings", nil) @@ -441,6 +432,7 @@ func resourceCosmosDbGremlinGraphRead(d *pluginsdk.ResourceData, meta interface{ func resourceCosmosDbGremlinGraphDelete(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() @@ -451,7 +443,7 @@ func resourceCosmosDbGremlinGraphDelete(d *pluginsdk.ResourceData, meta interfac err = client.GremlinResourcesDeleteGremlinGraphThenPoll(ctx, *id) if err != nil { - return fmt.Errorf("deleting Cosmos Gremlin Graph %q (Account: %q): %+v", id.GremlinDatabaseName, id.GraphName, err) + return fmt.Errorf("deleting %s: %+v", id, err) } return nil diff --git a/internal/services/cosmos/cosmosdb_gremlin_graph_resource_test.go b/internal/services/cosmos/cosmosdb_gremlin_graph_resource_test.go index 89d1a790ce90..51ee0bd62787 100644 --- a/internal/services/cosmos/cosmosdb_gremlin_graph_resource_test.go +++ b/internal/services/cosmos/cosmosdb_gremlin_graph_resource_test.go @@ -221,7 +221,7 @@ func (t CosmosGremlinGraphResource) Exists(ctx context.Context, clients *clients resp, err := clients.Cosmos.CosmosDBClient.GremlinResourcesGetGremlinGraph(ctx, *id) if err != nil { - return nil, fmt.Errorf("reading Cosmos Gremlin Graph (%s): %+v", id.String(), err) + return nil, fmt.Errorf("retrieving %s: %+v", id, err) } return pointer.To(resp.Model != nil), nil From bd20d18fd2e9412ea541344dc34254db3aafe0f1 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:26:34 -0600 Subject: [PATCH 07/25] `azurerm_cosmosdb_mongo_collection` - migrate to `go-azure-sdk` --- .../cosmosdb_mongo_collection_resource.go | 274 +++++++++--------- ...cosmosdb_mongo_collection_resource_test.go | 9 +- 2 files changed, 136 insertions(+), 147 deletions(-) diff --git a/internal/services/cosmos/cosmosdb_mongo_collection_resource.go b/internal/services/cosmos/cosmosdb_mongo_collection_resource.go index df02f349ad94..edfab2832114 100644 --- a/internal/services/cosmos/cosmosdb_mongo_collection_resource.go +++ b/internal/services/cosmos/cosmosdb_mongo_collection_resource.go @@ -5,19 +5,17 @@ package cosmos import ( "fmt" - "log" "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb" // nolint: staticcheck "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/common" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/migration" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -33,7 +31,7 @@ func resourceCosmosDbMongoCollection() *pluginsdk.Resource { Delete: resourceCosmosDbMongoCollectionDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.MongodbCollectionID(id) + _, err := cosmosdb.ParseMongodbDatabaseCollectionID(id) return err }), @@ -149,24 +147,19 @@ func resourceCosmosDbMongoCollection() *pluginsdk.Resource { } func resourceCosmosDbMongoCollectionCreate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.MongoDbClient - subscriptionId := meta.(*clients.Client).Account.SubscriptionId - ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) + client := meta.(*clients.Client).Cosmos.CosmosDBClient + + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - id := parse.NewMongodbCollectionID(subscriptionId, d.Get("resource_group_name").(string), d.Get("account_name").(string), d.Get("database_name").(string), d.Get("name").(string)) + id := cosmosdb.NewMongodbDatabaseCollectionID(meta.(*clients.Client).Account.SubscriptionId, d.Get("resource_group_name").(string), d.Get("account_name").(string), d.Get("database_name").(string), d.Get("name").(string)) - existing, err := client.GetMongoDBCollection(ctx, id.ResourceGroup, id.DatabaseAccountName, id.MongodbDatabaseName, id.CollectionName) - if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { + existing, err := client.MongoDBResourcesGetMongoDBCollection(ctx, id) + if !response.WasNotFound(existing.HttpResponse) { + if err != nil { return fmt.Errorf("checking for presence of %s: %+v", id, err) } - } else { - if existing.ID == nil && *existing.ID == "" { - return fmt.Errorf("generating import ID for %s", id) - } - - return tf.ImportAsExistsError("azurerm_cosmosdb_mongo_collection", *existing.ID) + return tf.ImportAsExistsError("azurerm_cosmosdb_mongo_collection", id.ID()) } var ttl *int @@ -179,43 +172,38 @@ func resourceCosmosDbMongoCollectionCreate(d *pluginsdk.ResourceData, meta inter return fmt.Errorf("index with '_id' key is required") } - db := documentdb.MongoDBCollectionCreateUpdateParameters{ - MongoDBCollectionCreateUpdateProperties: &documentdb.MongoDBCollectionCreateUpdateProperties{ - Resource: &documentdb.MongoDBCollectionResource{ - ID: &id.CollectionName, + db := cosmosdb.MongoDBCollectionCreateUpdateParameters{ + Properties: cosmosdb.MongoDBCollectionCreateUpdateProperties{ + Resource: cosmosdb.MongoDBCollectionResource{ + Id: id.CollectionName, Indexes: indexes, }, - Options: &documentdb.CreateUpdateOptions{}, + Options: &cosmosdb.CreateUpdateOptions{}, }, } if analyticalStorageTTL, ok := d.GetOk("analytical_storage_ttl"); ok { - db.Resource.AnalyticalStorageTTL = pointer.To(int32(analyticalStorageTTL.(int))) + db.Properties.Resource.AnalyticalStorageTtl = pointer.To(int64(analyticalStorageTTL.(int))) } if throughput, hasThroughput := d.GetOk("throughput"); hasThroughput { if throughput != 0 { - db.Options.Throughput = common.ConvertThroughputFromResourceDataLegacy(throughput) + db.Properties.Options.Throughput = common.ConvertThroughputFromResourceData(throughput) } } if _, hasAutoscaleSettings := d.GetOk("autoscale_settings"); hasAutoscaleSettings { - db.Options.AutoscaleSettings = common.ExpandCosmosDbAutoscaleSettingsLegacy(d) + db.Properties.Options.AutoScaleSettings = common.ExpandCosmosDbAutoscaleSettings(d) } if shardKey := d.Get("shard_key").(string); shardKey != "" { - db.Resource.ShardKey = map[string]*string{ - shardKey: pointer.To("Hash"), // looks like only hash is supported for now - } - } - - future, err := client.CreateUpdateMongoDBCollection(ctx, id.ResourceGroup, id.DatabaseAccountName, id.MongodbDatabaseName, id.CollectionName, db) - if err != nil { - return fmt.Errorf("issuing create/update request for %s: %+v", id, err) + db.Properties.Resource.ShardKey = pointer.To(map[string]string{ + shardKey: "Hash", // looks like only hash is supported for now + }) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting on create/update future for %s: %+v", id, err) + if err := client.MongoDBResourcesCreateUpdateMongoDBCollectionThenPoll(ctx, id, db); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) } d.SetId(id.ID()) @@ -224,70 +212,73 @@ func resourceCosmosDbMongoCollectionCreate(d *pluginsdk.ResourceData, meta inter } func resourceCosmosDbMongoCollectionUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.MongoDbClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.MongodbCollectionID(d.Id()) + id, err := cosmosdb.ParseMongodbDatabaseCollectionID(d.Id()) if err != nil { return err } - err = common.CheckForChangeFromAutoscaleAndManualThroughput(d) + if err := common.CheckForChangeFromAutoscaleAndManualThroughput(d); err != nil { + return fmt.Errorf("checking `autoscale_settings` and `throughput` for %s: %w", id, err) + } + + existing, err := client.MongoDBResourcesGetMongoDBCollection(ctx, *id) if err != nil { - return fmt.Errorf("updating Cosmos Mongo Collection %q (Account: %q, Database: %q): %+v", id.CollectionName, id.DatabaseAccountName, id.MongodbDatabaseName, err) + return fmt.Errorf("retrieving %s: %w", id, err) } - var ttl *int - if v, ok := d.GetOk("default_ttl_seconds"); ok { - ttl = pointer.To(v.(int)) + if existing.Model == nil { + return fmt.Errorf("retrieving %s: model was nil", id) } - indexes, hasIdKey := expandCosmosMongoCollectionIndex(d.Get("index").(*pluginsdk.Set).List(), ttl) - if !hasIdKey { - return fmt.Errorf("index with '_id' key is required") + if existing.Model.Properties == nil { + return fmt.Errorf("retrieving %s: properties was nil", id) } - db := documentdb.MongoDBCollectionCreateUpdateParameters{ - MongoDBCollectionCreateUpdateProperties: &documentdb.MongoDBCollectionCreateUpdateProperties{ - Resource: &documentdb.MongoDBCollectionResource{ - ID: &id.CollectionName, - Indexes: indexes, + if existing.Model.Properties.Resource == nil { + return fmt.Errorf("retrieving %s: resource was nil", id) + } + + db := cosmosdb.MongoDBCollectionCreateUpdateParameters{ + Properties: cosmosdb.MongoDBCollectionCreateUpdateProperties{ + Resource: cosmosdb.MongoDBCollectionResource{ + Id: id.CollectionName, + Indexes: existing.Model.Properties.Resource.Indexes, + ShardKey: existing.Model.Properties.Resource.ShardKey, }, - Options: &documentdb.CreateUpdateOptions{}, + Options: &cosmosdb.CreateUpdateOptions{}, }, } - if analyticalStorageTTL, ok := d.GetOk("analytical_storage_ttl"); ok { - db.Resource.AnalyticalStorageTTL = pointer.To(int32(analyticalStorageTTL.(int))) - } + if d.HasChanges("default_ttl_seconds", "index") { + var ttl *int + if v, ok := d.GetOk("default_ttl_seconds"); ok { + ttl = pointer.To(v.(int)) + } - if shardKey := d.Get("shard_key").(string); shardKey != "" { - db.Resource.ShardKey = map[string]*string{ - shardKey: pointer.To("Hash"), // looks like only hash is supported for now + indexes, hasIdKey := expandCosmosMongoCollectionIndex(d.Get("index").(*pluginsdk.Set).List(), ttl) + if !hasIdKey { + return fmt.Errorf("index with '_id' key is required") } + db.Properties.Resource.Indexes = indexes } - future, err := client.CreateUpdateMongoDBCollection(ctx, id.ResourceGroup, id.DatabaseAccountName, id.MongodbDatabaseName, id.CollectionName, db) - if err != nil { - return fmt.Errorf("issuing create/update request for Cosmos Mongo Collection %q (Account: %q, Database: %q): %+v", id.CollectionName, id.DatabaseAccountName, id.MongodbDatabaseName, err) + if d.HasChange("analytical_storage_ttl") { + if analyticalStorageTTL, ok := d.GetOk("analytical_storage_ttl"); ok { + db.Properties.Resource.AnalyticalStorageTtl = pointer.To(int64(analyticalStorageTTL.(int))) + } } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting on create/update future for Cosmos Mongo Collection %q (Account: %q, Database: %q): %+v", id.CollectionName, id.DatabaseAccountName, id.MongodbDatabaseName, err) + if err := client.MongoDBResourcesCreateUpdateMongoDBCollectionThenPoll(ctx, *id, db); err != nil { + return fmt.Errorf("updating %s: %+v", id, err) } if common.HasThroughputChange(d) { - throughputParameters := common.ExpandCosmosDBThroughputSettingsUpdateParametersLegacy(d) - throughputFuture, err := client.UpdateMongoDBCollectionThroughput(ctx, id.ResourceGroup, id.DatabaseAccountName, id.MongodbDatabaseName, id.CollectionName, *throughputParameters) - if err != nil { - if response.WasNotFound(throughputFuture.Response()) { - return fmt.Errorf("setting Throughput for Cosmos MongoDB Collection %q (Account: %q, Database: %q): %+v - if the collection has not been created with an initial throughput, you cannot configure it later", id.CollectionName, id.DatabaseAccountName, id.MongodbDatabaseName, err) - } - } - - if err = throughputFuture.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting on ThroughputUpdate future for Cosmos Mongo Collection %q (Account: %q, Database: %q): %+v", id.CollectionName, id.DatabaseAccountName, id.MongodbDatabaseName, err) + if err := client.MongoDBResourcesUpdateMongoDBCollectionThroughputThenPoll(ctx, *id, common.ExpandCosmosDBThroughputSettingsUpdateParameters(d)); err != nil { + return fmt.Errorf("setting Throughput for %s: %+v - if the collection has not been created with an initial throughput, you cannot configure it later", id, err) } } @@ -295,90 +286,96 @@ func resourceCosmosDbMongoCollectionUpdate(d *pluginsdk.ResourceData, meta inter } func resourceCosmosDbMongoCollectionRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.MongoDbClient - accClient := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.MongodbCollectionID(d.Id()) + id, err := cosmosdb.ParseMongodbDatabaseCollectionID(d.Id()) if err != nil { return err } - resp, err := client.GetMongoDBCollection(ctx, id.ResourceGroup, id.DatabaseAccountName, id.MongodbDatabaseName, id.CollectionName) + resp, err := client.MongoDBResourcesGetMongoDBCollection(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[INFO] Error reading Cosmos Mongo Collection %q (Account: %q, Database: %q)", id.CollectionName, id.DatabaseAccountName, id.MongodbDatabaseName) + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("reading Cosmos Mongo Collection %q (Account: %q, Database: %q): %+v", id.CollectionName, id.DatabaseAccountName, id.MongodbDatabaseName, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } - d.Set("resource_group_name", id.ResourceGroup) + d.Set("resource_group_name", id.ResourceGroupName) d.Set("account_name", id.DatabaseAccountName) d.Set("database_name", id.MongodbDatabaseName) + d.Set("name", id.MongodbDatabaseName) - accResp, err := accClient.Get(ctx, id.ResourceGroup, id.DatabaseAccountName) + databaseAccountID := cosmosdb.NewDatabaseAccountID(id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName) + accResp, err := client.DatabaseAccountsGet(ctx, databaseAccountID) if err != nil { - return fmt.Errorf("reading Cosmos Account %q : %+v", id.DatabaseAccountName, err) + return fmt.Errorf("retrieving %s: %+v", databaseAccountID, err) } - if props := resp.MongoDBCollectionGetProperties; props != nil { - if res := props.Resource; res != nil { - d.Set("name", res.ID) - // you can only have one - if len(res.ShardKey) > 2 { - return fmt.Errorf("unexpected number of shard keys: %d", len(res.ShardKey)) - } + if resp.Model != nil { + if props := resp.Model.Properties; props != nil { + if res := props.Resource; res != nil { - for k := range res.ShardKey { - d.Set("shard_key", k) - } - accountIsVersion36 := false - if accProps := accResp.DatabaseAccountGetProperties; accProps != nil { - if capabilities := accProps.Capabilities; capabilities != nil { - for _, v := range *capabilities { - if v.Name != nil && *v.Name == "EnableMongo" { - accountIsVersion36 = true + // you can only have one + if l := len(pointer.From(res.ShardKey)); l > 2 { + return fmt.Errorf("unexpected number of shard keys: %d", l) + } + + for k := range pointer.From(res.ShardKey) { + d.Set("shard_key", k) + } + + accountIsVersion36 := false + if accResp.Model != nil { + if accProps := accResp.Model.Properties; accProps != nil { + if capabilities := accProps.Capabilities; capabilities != nil { + for _, v := range *capabilities { + if pointer.From(v.Name) == "EnableMongo" { + accountIsVersion36 = true + } + } } } } - } - indexes, systemIndexes, ttl := flattenCosmosMongoCollectionIndex(res.Indexes, accountIsVersion36) - // In fact, the Azure API does not return `ExpireAfterSeconds` aka `default_ttl_seconds` when `default_ttl_seconds` is not set in tf the config. - // When "default_ttl_seconds" is set to nil, it will be set to 0 in state file. 0 is invalid value for `default_ttl_seconds` and could not pass tf validation. - // So when `default_ttl_seconds` is not set in tf config, we should not set the value of `default_ttl_seconds` but keep null in the state file. - if ttl != nil { - if err := d.Set("default_ttl_seconds", ttl); err != nil { - return fmt.Errorf("failed to set `default_ttl_seconds`: %+v", err) + indexes, systemIndexes, ttl := flattenCosmosMongoCollectionIndex(res.Indexes, accountIsVersion36) + // In fact, the Azure API does not return `ExpireAfterSeconds` aka `default_ttl_seconds` when `default_ttl_seconds` is not set in tf the config. + // When "default_ttl_seconds" is set to nil, it will be set to 0 in state file. 0 is invalid value for `default_ttl_seconds` and could not pass tf validation. + // So when `default_ttl_seconds` is not set in tf config, we should not set the value of `default_ttl_seconds` but keep null in the state file. + if ttl != nil { + if err := d.Set("default_ttl_seconds", ttl); err != nil { + return fmt.Errorf("setting `default_ttl_seconds`: %+v", err) + } + } + if err := d.Set("index", indexes); err != nil { + return fmt.Errorf("setting `index`: %+v", err) + } + if err := d.Set("system_indexes", systemIndexes); err != nil { + return fmt.Errorf("setting `system_indexes`: %+v", err) } - } - if err := d.Set("index", indexes); err != nil { - return fmt.Errorf("failed to set `index`: %+v", err) - } - if err := d.Set("system_indexes", systemIndexes); err != nil { - return fmt.Errorf("failed to set `system_indexes`: %+v", err) - } - d.Set("analytical_storage_ttl", res.AnalyticalStorageTTL) + d.Set("analytical_storage_ttl", res.AnalyticalStorageTtl) + } } } // if the cosmos account is serverless calling the get throughput api would yield an error - if !isServerlessCapacityMode(accResp) { - throughputResp, err := client.GetMongoDBCollectionThroughput(ctx, id.ResourceGroup, id.DatabaseAccountName, id.MongodbDatabaseName, id.CollectionName) + if !isServerlessCapacityMode(accResp.Model) { + throughputResp, err := client.MongoDBResourcesGetMongoDBCollectionThroughput(ctx, *id) if err != nil { - if !utils.ResponseWasNotFound(throughputResp.Response) { - return fmt.Errorf("reading Throughput on Cosmos Mongo Collection %q (Account: %q, Database: %q): %+v", id.CollectionName, id.DatabaseAccountName, id.MongodbDatabaseName, err) + if !response.WasNotFound(throughputResp.HttpResponse) { + return fmt.Errorf("retrieving Throughput for %s: %+v", id, err) } else { d.Set("throughput", nil) d.Set("autoscale_settings", nil) } } else { - common.SetResourceDataThroughputFromResponseLegacy(throughputResp, d) + common.SetResourceDataThroughputFromResponse(pointer.From(throughputResp.Model), d) } } @@ -386,32 +383,25 @@ func resourceCosmosDbMongoCollectionRead(d *pluginsdk.ResourceData, meta interfa } func resourceCosmosDbMongoCollectionDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.MongoDbClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.MongodbCollectionID(d.Id()) + id, err := cosmosdb.ParseMongodbDatabaseCollectionID(d.Id()) if err != nil { return err } - future, err := client.DeleteMongoDBCollection(ctx, id.ResourceGroup, id.DatabaseAccountName, id.MongodbDatabaseName, id.CollectionName) - if err != nil { - if !response.WasNotFound(future.Response()) { - return fmt.Errorf("deleting Cosmos Mongo Collection %q (Account: %q, Database: %q): %+v", id.CollectionName, id.DatabaseAccountName, id.MongodbDatabaseName, err) - } - } - - err = future.WaitForCompletionRef(ctx, client.Client) - if err != nil { - return fmt.Errorf("waiting on delete future for Cosmos Mongo Collection %q (Account: %q, Database: %q): %+v", id.CollectionName, id.DatabaseAccountName, id.MongodbDatabaseName, err) + if err := client.MongoDBResourcesDeleteMongoDBCollectionThenPoll(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", id, err) } return nil } -func expandCosmosMongoCollectionIndex(indexes []interface{}, defaultTtl *int) (*[]documentdb.MongoIndex, bool) { - results := make([]documentdb.MongoIndex, 0) +func expandCosmosMongoCollectionIndex(indexes []interface{}, defaultTtl *int) (*[]cosmosdb.MongoIndex, bool) { + results := make([]cosmosdb.MongoIndex, 0) hasIdKey := false @@ -426,11 +416,11 @@ func expandCosmosMongoCollectionIndex(indexes []interface{}, defaultTtl *int) (* } } - results = append(results, documentdb.MongoIndex{ - Key: &documentdb.MongoIndexKeys{ + results = append(results, cosmosdb.MongoIndex{ + Key: &cosmosdb.MongoIndexKeys{ Keys: utils.ExpandStringSlice(index["keys"].([]interface{})), }, - Options: &documentdb.MongoIndexOptions{ + Options: &cosmosdb.MongoIndexOptions{ Unique: pointer.To(index["unique"].(bool)), }, }) @@ -438,12 +428,12 @@ func expandCosmosMongoCollectionIndex(indexes []interface{}, defaultTtl *int) (* } if defaultTtl != nil { - results = append(results, documentdb.MongoIndex{ - Key: &documentdb.MongoIndexKeys{ + results = append(results, cosmosdb.MongoIndex{ + Key: &cosmosdb.MongoIndexKeys{ Keys: &[]string{"_ts"}, }, - Options: &documentdb.MongoIndexOptions{ - ExpireAfterSeconds: pointer.To(int32(*defaultTtl)), + Options: &cosmosdb.MongoIndexOptions{ + ExpireAfterSeconds: pointer.To(int64(*defaultTtl)), }, }) } @@ -451,10 +441,10 @@ func expandCosmosMongoCollectionIndex(indexes []interface{}, defaultTtl *int) (* return &results, hasIdKey } -func flattenCosmosMongoCollectionIndex(input *[]documentdb.MongoIndex, accountIsVersion36 bool) (*[]map[string]interface{}, *[]map[string]interface{}, *int32) { +func flattenCosmosMongoCollectionIndex(input *[]cosmosdb.MongoIndex, accountIsVersion36 bool) (*[]map[string]interface{}, *[]map[string]interface{}, *int64) { indexes := make([]map[string]interface{}, 0) systemIndexes := make([]map[string]interface{}, 0) - var ttl *int32 + var ttl *int64 if input == nil { return &indexes, &systemIndexes, ttl } diff --git a/internal/services/cosmos/cosmosdb_mongo_collection_resource_test.go b/internal/services/cosmos/cosmosdb_mongo_collection_resource_test.go index 0227b99fb932..38590e826a5d 100644 --- a/internal/services/cosmos/cosmosdb_mongo_collection_resource_test.go +++ b/internal/services/cosmos/cosmosdb_mongo_collection_resource_test.go @@ -13,7 +13,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) @@ -233,17 +232,17 @@ func TestAccCosmosDbMongoCollection_autoscaleWithoutShareKey(t *testing.T) { } func (t CosmosMongoCollectionResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.MongodbCollectionID(state.ID) + id, err := cosmosdb.ParseMongodbDatabaseCollectionID(state.ID) if err != nil { return nil, err } - resp, err := clients.Cosmos.MongoDbClient.GetMongoDBCollection(ctx, id.ResourceGroup, id.DatabaseAccountName, id.MongodbDatabaseName, id.CollectionName) + resp, err := clients.Cosmos.CosmosDBClient.MongoDBResourcesGetMongoDBCollection(ctx, *id) if err != nil { - return nil, fmt.Errorf("reading %s: %+v", *id, err) + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) } - return pointer.To(resp.ID != nil), nil + return pointer.To(resp.Model != nil), nil } func (CosmosMongoCollectionResource) basic(data acceptance.TestData) string { From 22dd5d0949843660585d320e3ba99555e32efb4a Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:27:51 -0600 Subject: [PATCH 08/25] `azurerm_cosmosdb_mongo_database` - migrate to `go-azure-sdk` --- .../cosmosdb_mongo_database_data_source.go | 25 +-- .../cosmosdb_mongo_database_resource.go | 156 ++++++------------ .../cosmosdb_mongo_database_resource_test.go | 9 +- 3 files changed, 69 insertions(+), 121 deletions(-) diff --git a/internal/services/cosmos/cosmosdb_mongo_database_data_source.go b/internal/services/cosmos/cosmosdb_mongo_database_data_source.go index 0b6ab1a3ddc3..d616641469cf 100644 --- a/internal/services/cosmos/cosmosdb_mongo_database_data_source.go +++ b/internal/services/cosmos/cosmosdb_mongo_database_data_source.go @@ -7,15 +7,14 @@ import ( "fmt" "time" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/validate" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceCosmosDbMongoDatabase() *pluginsdk.Resource { @@ -47,25 +46,29 @@ func dataSourceCosmosDbMongoDatabase() *pluginsdk.Resource { } func dataSourceCosmosDbMongoDatabaseRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.MongoDbClient - subscriptionId := meta.(*clients.Client).Account.SubscriptionId + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id := parse.NewMongodbDatabaseID(subscriptionId, d.Get("resource_group_name").(string), d.Get("account_name").(string), d.Get("name").(string)) + id := cosmosdb.NewMongodbDatabaseID(meta.(*clients.Client).Account.SubscriptionId, d.Get("resource_group_name").(string), d.Get("account_name").(string), d.Get("name").(string)) - resp, err := client.GetMongoDBDatabase(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name) + resp, err := client.MongoDBResourcesGetMongoDBDatabase(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { return fmt.Errorf("%s was not found", id) } return fmt.Errorf("retrieving %s: %+v", id, err) } d.SetId(id.ID()) - d.Set("name", id.Name) + d.Set("name", id.MongodbDatabaseName) d.Set("account_name", id.DatabaseAccountName) - d.Set("resource_group_name", id.ResourceGroup) + d.Set("resource_group_name", id.ResourceGroupName) + + if resp.Model != nil { + d.Set("tags", resp.Model.Tags) + } - return tags.FlattenAndSet(d, resp.Tags) + return nil } diff --git a/internal/services/cosmos/cosmosdb_mongo_database_resource.go b/internal/services/cosmos/cosmosdb_mongo_database_resource.go index d6293421c016..53b3c0dca2ee 100644 --- a/internal/services/cosmos/cosmosdb_mongo_database_resource.go +++ b/internal/services/cosmos/cosmosdb_mongo_database_resource.go @@ -5,21 +5,19 @@ package cosmos import ( "fmt" - "log" "time" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/common" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/migration" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceCosmosDbMongoDatabase() *pluginsdk.Resource { @@ -30,7 +28,7 @@ func resourceCosmosDbMongoDatabase() *pluginsdk.Resource { Delete: resourceCosmosDbMongoDatabaseDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.MongodbDatabaseID(id) + _, err := cosmosdb.ParseMongodbDatabaseID(id) return err }), @@ -76,52 +74,42 @@ func resourceCosmosDbMongoDatabase() *pluginsdk.Resource { } func resourceCosmosDbMongoDatabaseCreate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.MongoDbClient - subscriptionId := meta.(*clients.Client).Account.SubscriptionId + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - id := parse.NewMongodbDatabaseID(subscriptionId, d.Get("resource_group_name").(string), d.Get("account_name").(string), d.Get("name").(string)) + id := cosmosdb.NewMongodbDatabaseID(meta.(*clients.Client).Account.SubscriptionId, d.Get("resource_group_name").(string), d.Get("account_name").(string), d.Get("name").(string)) - existing, err := client.GetMongoDBDatabase(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name) - if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { + existing, err := client.MongoDBResourcesGetMongoDBDatabase(ctx, id) + if !response.WasNotFound(existing.HttpResponse) { + if err != nil { return fmt.Errorf("checking for presence of %s: %+v", id, err) } - } else { - if existing.ID == nil && *existing.ID == "" { - return fmt.Errorf("generating import ID for %s", id) - } - - return tf.ImportAsExistsError("azurerm_cosmosdb_mongo_database", *existing.ID) + return tf.ImportAsExistsError("azurerm_cosmosdb_mongo_database", id.ID()) } - db := documentdb.MongoDBDatabaseCreateUpdateParameters{ - MongoDBDatabaseCreateUpdateProperties: &documentdb.MongoDBDatabaseCreateUpdateProperties{ - Resource: &documentdb.MongoDBDatabaseResource{ - ID: &id.Name, + db := cosmosdb.MongoDBDatabaseCreateUpdateParameters{ + Properties: cosmosdb.MongoDBDatabaseCreateUpdateProperties{ + Resource: cosmosdb.MongoDBDatabaseResource{ + Id: id.MongodbDatabaseName, }, - Options: &documentdb.CreateUpdateOptions{}, + Options: &cosmosdb.CreateUpdateOptions{}, }, } - if throughput, hasThroughput := d.GetOk("throughput"); hasThroughput { + if throughput, ok := d.GetOk("throughput"); ok { if throughput != 0 { - db.Options.Throughput = common.ConvertThroughputFromResourceDataLegacy(throughput) + db.Properties.Options.Throughput = common.ConvertThroughputFromResourceData(throughput) } } - if _, hasAutoscaleSettings := d.GetOk("autoscale_settings"); hasAutoscaleSettings { - db.Options.AutoscaleSettings = common.ExpandCosmosDbAutoscaleSettingsLegacy(d) + if _, ok := d.GetOk("autoscale_settings"); ok { + db.Properties.Options.AutoScaleSettings = common.ExpandCosmosDbAutoscaleSettings(d) } - future, err := client.CreateUpdateMongoDBDatabase(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name, db) - if err != nil { - return fmt.Errorf("issuing create/update request for %s: %+v", id, err) - } - - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting on create/update for %s: %+v", id, err) + if err := client.MongoDBResourcesCreateUpdateMongoDBDatabaseThenPoll(ctx, id, db); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) } d.SetId(id.ID()) @@ -130,111 +118,76 @@ func resourceCosmosDbMongoDatabaseCreate(d *pluginsdk.ResourceData, meta interfa } func resourceCosmosDbMongoDatabaseUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.MongoDbClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.MongodbDatabaseID(d.Id()) + id, err := cosmosdb.ParseMongodbDatabaseID(d.Id()) if err != nil { return err } - err = common.CheckForChangeFromAutoscaleAndManualThroughput(d) - if err != nil { - return fmt.Errorf("updating Cosmos Mongo Database %q (Account: %q) - %+v", id.Name, id.DatabaseAccountName, err) - } - - db := documentdb.MongoDBDatabaseCreateUpdateParameters{ - MongoDBDatabaseCreateUpdateProperties: &documentdb.MongoDBDatabaseCreateUpdateProperties{ - Resource: &documentdb.MongoDBDatabaseResource{ - ID: &id.Name, - }, - Options: &documentdb.CreateUpdateOptions{}, - }, - } - - future, err := client.CreateUpdateMongoDBDatabase(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name, db) - if err != nil { - return fmt.Errorf("issuing create/update request for Cosmos Mongo Database %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) + if err := common.CheckForChangeFromAutoscaleAndManualThroughput(d); err != nil { + return fmt.Errorf("checking `autoscale_settings` and `throughput` for %s: %w", id, err) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting on create/update future for Cosmos Mongo Database %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) + if _, err := client.MongoDBResourcesGetMongoDBDatabase(ctx, *id); err != nil { + return fmt.Errorf("retrieving %s: %w", id, err) } if common.HasThroughputChange(d) { - throughputParameters := common.ExpandCosmosDBThroughputSettingsUpdateParametersLegacy(d) - throughputFuture, err := client.UpdateMongoDBDatabaseThroughput(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name, *throughputParameters) - if err != nil { - if response.WasNotFound(throughputFuture.Response()) { - return fmt.Errorf("setting Throughput for Cosmos MongoDB Database %q (Account: %q): %+v - "+ - "If the collection has not been created with an initial throughput, you cannot configure it later", id.Name, id.DatabaseAccountName, err) - } - } - - if err = throughputFuture.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting on ThroughputUpdate future for Cosmos Mongo Database %q (Account: %q, Database %q): %+v", id.Name, id.DatabaseAccountName, id.Name, err) + if err := client.MongoDBResourcesUpdateMongoDBDatabaseThroughputThenPoll(ctx, *id, common.ExpandCosmosDBThroughputSettingsUpdateParameters(d)); err != nil { + return fmt.Errorf("setting Throughput for %s: %+v - If the collection has not been created with an initial throughput, you cannot configure it later", id, err) } } - if _, err = client.GetMongoDBDatabase(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name); err != nil { - return fmt.Errorf("making get request for Cosmos Mongo Database %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) - } - return resourceCosmosDbMongoDatabaseRead(d, meta) } func resourceCosmosDbMongoDatabaseRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.MongoDbClient - accountClient := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.MongodbDatabaseID(d.Id()) + id, err := cosmosdb.ParseMongodbDatabaseID(d.Id()) if err != nil { return err } - resp, err := client.GetMongoDBDatabase(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name) + resp, err := client.MongoDBResourcesGetMongoDBDatabase(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[INFO] Error reading Cosmos Mongo Database %q (Account: %q) - removing from state", id.Name, id.DatabaseAccountName) + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("reading Cosmos Mongo Database %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } - d.Set("resource_group_name", id.ResourceGroup) + d.Set("resource_group_name", id.ResourceGroupName) d.Set("account_name", id.DatabaseAccountName) - if props := resp.MongoDBDatabaseGetProperties; props != nil { - if res := props.Resource; res != nil { - d.Set("name", res.ID) - } - } + d.Set("name", id.MongodbDatabaseName) - accResp, err := accountClient.Get(ctx, id.ResourceGroup, id.DatabaseAccountName) + databaseAccountID := cosmosdb.NewDatabaseAccountID(id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName) + accResp, err := client.DatabaseAccountsGet(ctx, databaseAccountID) if err != nil { - return fmt.Errorf("reading CosmosDB Account %q (Resource Group %q): %+v", id.DatabaseAccountName, id.ResourceGroup, err) - } - - if accResp.ID == nil || *accResp.ID == "" { - return fmt.Errorf("cosmosDB Account %q (Resource Group %q) ID is empty or nil", id.DatabaseAccountName, id.ResourceGroup) + return fmt.Errorf("retrieving %s: %+v", databaseAccountID, err) } // if the cosmos account is serverless calling the get throughput api would yield an error - if !isServerlessCapacityMode(accResp) { - throughputResp, err := client.GetMongoDBDatabaseThroughput(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name) + if !isServerlessCapacityMode(accResp.Model) { + throughputResp, err := client.MongoDBResourcesGetMongoDBDatabaseThroughput(ctx, *id) if err != nil { - if !utils.ResponseWasNotFound(throughputResp.Response) { - return fmt.Errorf("reading Throughput on Cosmos Mongo Database %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) + if !response.WasNotFound(throughputResp.HttpResponse) { + return fmt.Errorf("retrieving %s: %+v", id, err) } else { d.Set("throughput", nil) d.Set("autoscale_settings", nil) } } else { - common.SetResourceDataThroughputFromResponseLegacy(throughputResp, d) + common.SetResourceDataThroughputFromResponse(pointer.From(throughputResp.Model), d) } } @@ -242,25 +195,18 @@ func resourceCosmosDbMongoDatabaseRead(d *pluginsdk.ResourceData, meta interface } func resourceCosmosDbMongoDatabaseDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.MongoDbClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.MongodbDatabaseID(d.Id()) + id, err := cosmosdb.ParseMongodbDatabaseID(d.Id()) if err != nil { return err } - future, err := client.DeleteMongoDBDatabase(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name) - if err != nil { - if !response.WasNotFound(future.Response()) { - return fmt.Errorf("deleting Cosmos Mongo Database %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) - } - } - - err = future.WaitForCompletionRef(ctx, client.Client) - if err != nil { - return fmt.Errorf("waiting on delete future for Cosmos Mongo Database %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) + if err := client.MongoDBResourcesDeleteMongoDBDatabaseThenPoll(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", id, err) } return nil diff --git a/internal/services/cosmos/cosmosdb_mongo_database_resource_test.go b/internal/services/cosmos/cosmosdb_mongo_database_resource_test.go index 2f3c198c8735..2ebf6ad9b19d 100644 --- a/internal/services/cosmos/cosmosdb_mongo_database_resource_test.go +++ b/internal/services/cosmos/cosmosdb_mongo_database_resource_test.go @@ -13,7 +13,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) @@ -100,17 +99,17 @@ func TestAccCosmosDbMongoDatabase_serverless(t *testing.T) { } func (t CosmosMongoDatabaseResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.MongodbDatabaseID(state.ID) + id, err := cosmosdb.ParseMongodbDatabaseID(state.ID) if err != nil { return nil, err } - resp, err := clients.Cosmos.MongoDbClient.GetMongoDBDatabase(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name) + resp, err := clients.Cosmos.CosmosDBClient.MongoDBResourcesGetMongoDBDatabase(ctx, *id) if err != nil { - return nil, fmt.Errorf("reading Cosmos Mongo Database (%s): %+v", id.String(), err) + return nil, fmt.Errorf("retrieving %s: %+v", id, err) } - return pointer.To(resp.ID != nil), nil + return pointer.To(resp.Model != nil), nil } func (CosmosMongoDatabaseResource) basic(data acceptance.TestData) string { From 2386f0c1e82f96ad9434b619f0b2800b404db784 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:29:41 -0600 Subject: [PATCH 09/25] `azurerm_cosmosdb_mongo_role_definition` - migrate to `go-azure-sdk` --- ...cosmosdb_mongo_role_definition_resource.go | 22 +++++++++---------- ...sdb_mongo_role_definition_resource_test.go | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/services/cosmos/cosmosdb_mongo_role_definition_resource.go b/internal/services/cosmos/cosmosdb_mongo_role_definition_resource.go index d0a7fc79dfe1..764c0ff228cf 100644 --- a/internal/services/cosmos/cosmosdb_mongo_role_definition_resource.go +++ b/internal/services/cosmos/cosmosdb_mongo_role_definition_resource.go @@ -11,9 +11,9 @@ import ( "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2022-11-15/mongorbacs" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -58,7 +58,7 @@ func (r CosmosDbMongoRoleDefinitionResource) Arguments() map[string]*pluginsdk.S Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.MongodbDatabaseID, + ValidateFunc: cosmosdb.ValidateMongodbDatabaseID, }, "role_name": { @@ -131,13 +131,13 @@ func (r CosmosDbMongoRoleDefinitionResource) Create() sdk.ResourceFunc { } client := metadata.Client.Cosmos.MongoRBACClient - databaseId, err := parse.MongodbDatabaseID(model.CosmosMongoDatabaseId) + databaseId, err := cosmosdb.ParseMongodbDatabaseID(model.CosmosMongoDatabaseId) if err != nil { return err } - mongoRoleDefinitionId := fmt.Sprintf("%s.%s", databaseId.Name, model.RoleName) - id := mongorbacs.NewMongodbRoleDefinitionID(databaseId.SubscriptionId, databaseId.ResourceGroup, databaseId.DatabaseAccountName, mongoRoleDefinitionId) + mongoRoleDefinitionId := fmt.Sprintf("%s.%s", databaseId.MongodbDatabaseName, model.RoleName) + id := mongorbacs.NewMongodbRoleDefinitionID(databaseId.SubscriptionId, databaseId.ResourceGroupName, databaseId.DatabaseAccountName, mongoRoleDefinitionId) locks.ByName(id.DatabaseAccountName, CosmosDbAccountResourceName) defer locks.UnlockByName(id.DatabaseAccountName, CosmosDbAccountResourceName) @@ -154,8 +154,8 @@ func (r CosmosDbMongoRoleDefinitionResource) Create() sdk.ResourceFunc { roleType := mongorbacs.MongoRoleDefinitionTypeCustomRole parameters := mongorbacs.MongoRoleDefinitionCreateUpdateParameters{ Properties: &mongorbacs.MongoRoleDefinitionResource{ - DatabaseName: pointer.To(databaseId.Name), - Roles: expandInheritedRoles(model.InheritedRoleNames, databaseId.Name), + DatabaseName: pointer.To(databaseId.MongodbDatabaseName), + Roles: expandInheritedRoles(model.InheritedRoleNames, databaseId.MongodbDatabaseName), RoleName: pointer.To(model.RoleName), Privileges: expandPrivilege(model.Privileges), Type: pointer.To(roleType), @@ -201,7 +201,7 @@ func (r CosmosDbMongoRoleDefinitionResource) Update() sdk.ResourceFunc { return fmt.Errorf("retrieving %s: properties was nil", id) } - databaseId, err := parse.MongodbDatabaseID(model.CosmosMongoDatabaseId) + databaseId, err := cosmosdb.ParseMongodbDatabaseID(model.CosmosMongoDatabaseId) if err != nil { return err } @@ -209,9 +209,9 @@ func (r CosmosDbMongoRoleDefinitionResource) Update() sdk.ResourceFunc { roleType := mongorbacs.MongoRoleDefinitionTypeCustomRole parameters := mongorbacs.MongoRoleDefinitionCreateUpdateParameters{ Properties: &mongorbacs.MongoRoleDefinitionResource{ - DatabaseName: pointer.To(databaseId.Name), + DatabaseName: pointer.To(databaseId.MongodbDatabaseName), RoleName: pointer.To(model.RoleName), - Roles: expandInheritedRoles(model.InheritedRoleNames, databaseId.Name), + Roles: expandInheritedRoles(model.InheritedRoleNames, databaseId.MongodbDatabaseName), Privileges: expandPrivilege(model.Privileges), Type: pointer.To(roleType), }, @@ -250,7 +250,7 @@ func (r CosmosDbMongoRoleDefinitionResource) Read() sdk.ResourceFunc { if model := resp.Model; model != nil { if properties := model.Properties; properties != nil { - databaseId := parse.NewMongodbDatabaseID(id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, *properties.DatabaseName) + databaseId := cosmosdb.NewMongodbDatabaseID(id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, *properties.DatabaseName) state.CosmosMongoDatabaseId = databaseId.ID() state.RoleName = pointer.From(properties.RoleName) diff --git a/internal/services/cosmos/cosmosdb_mongo_role_definition_resource_test.go b/internal/services/cosmos/cosmosdb_mongo_role_definition_resource_test.go index ace4f3b9fae6..a9d283011150 100644 --- a/internal/services/cosmos/cosmosdb_mongo_role_definition_resource_test.go +++ b/internal/services/cosmos/cosmosdb_mongo_role_definition_resource_test.go @@ -93,7 +93,7 @@ func (r CosmosMongoRoleDefinitionResource) Exists(ctx context.Context, clients * resp, err := clients.Cosmos.MongoRBACClient.MongoDBResourcesGetMongoRoleDefinition(ctx, *id) if err != nil { - return nil, fmt.Errorf("reading %q: %+v", id, err) + return nil, fmt.Errorf("retrieving %s: %+v", id, err) } return pointer.To(resp.Model != nil), nil From 1bb4d942edf605dbbaccdda4057115177dcc3013 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:30:35 -0600 Subject: [PATCH 10/25] `azurerm_cosmosdb_mongo_user_definition` - migrate to `go-azure-sdk` --- ...cosmosdb_mongo_user_definition_resource.go | 21 +++++++++---------- ...sdb_mongo_user_definition_resource_test.go | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/internal/services/cosmos/cosmosdb_mongo_user_definition_resource.go b/internal/services/cosmos/cosmosdb_mongo_user_definition_resource.go index f7f761119e5b..ab85bea62513 100644 --- a/internal/services/cosmos/cosmosdb_mongo_user_definition_resource.go +++ b/internal/services/cosmos/cosmosdb_mongo_user_definition_resource.go @@ -11,10 +11,9 @@ import ( "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2022-11-15/mongorbacs" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" ) @@ -48,7 +47,7 @@ func (r CosmosDbMongoUserDefinitionResource) Arguments() map[string]*pluginsdk.S Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.MongodbDatabaseID, + ValidateFunc: cosmosdb.ValidateMongodbDatabaseID, }, "username": { @@ -90,13 +89,13 @@ func (r CosmosDbMongoUserDefinitionResource) Create() sdk.ResourceFunc { } client := metadata.Client.Cosmos.MongoRBACClient - databaseId, err := parse.MongodbDatabaseID(model.CosmosMongoDatabaseId) + databaseId, err := cosmosdb.ParseMongodbDatabaseID(model.CosmosMongoDatabaseId) if err != nil { return err } - mongoUserDefinitionId := fmt.Sprintf("%s.%s", databaseId.Name, model.Username) - id := mongorbacs.NewMongodbUserDefinitionID(databaseId.SubscriptionId, databaseId.ResourceGroup, databaseId.DatabaseAccountName, mongoUserDefinitionId) + mongoUserDefinitionId := fmt.Sprintf("%s.%s", databaseId.MongodbDatabaseName, model.Username) + id := mongorbacs.NewMongodbUserDefinitionID(databaseId.SubscriptionId, databaseId.ResourceGroupName, databaseId.DatabaseAccountName, mongoUserDefinitionId) locks.ByName(id.DatabaseAccountName, CosmosDbAccountResourceName) defer locks.UnlockByName(id.DatabaseAccountName, CosmosDbAccountResourceName) @@ -112,11 +111,11 @@ func (r CosmosDbMongoUserDefinitionResource) Create() sdk.ResourceFunc { properties := mongorbacs.MongoUserDefinitionCreateUpdateParameters{ Properties: &mongorbacs.MongoUserDefinitionResource{ - DatabaseName: pointer.To(databaseId.Name), + DatabaseName: pointer.To(databaseId.MongodbDatabaseName), Mechanisms: pointer.To("SCRAM-SHA-256"), Password: pointer.To(model.Password), UserName: pointer.To(model.Username), - Roles: expandInheritedRole(model.InheritedRoleNames, databaseId.Name), + Roles: expandInheritedRole(model.InheritedRoleNames, databaseId.MongodbDatabaseName), }, } @@ -159,7 +158,7 @@ func (r CosmosDbMongoUserDefinitionResource) Update() sdk.ResourceFunc { return fmt.Errorf("retrieving %s: properties was nil", id) } - databaseId, err := parse.MongodbDatabaseID(model.CosmosMongoDatabaseId) + databaseId, err := cosmosdb.ParseMongodbDatabaseID(model.CosmosMongoDatabaseId) if err != nil { return err } @@ -173,7 +172,7 @@ func (r CosmosDbMongoUserDefinitionResource) Update() sdk.ResourceFunc { } if metadata.ResourceData.HasChange("inherited_role_names") { - parameters.Properties.Roles = expandInheritedRole(model.InheritedRoleNames, databaseId.Name) + parameters.Properties.Roles = expandInheritedRole(model.InheritedRoleNames, databaseId.MongodbDatabaseName) } if err := client.MongoDBResourcesCreateUpdateMongoUserDefinitionThenPoll(ctx, *id, parameters); err != nil { @@ -209,7 +208,7 @@ func (r CosmosDbMongoUserDefinitionResource) Read() sdk.ResourceFunc { if model := resp.Model; model != nil { if properties := model.Properties; properties != nil { - databaseId := parse.NewMongodbDatabaseID(id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, *properties.DatabaseName) + databaseId := cosmosdb.NewMongodbDatabaseID(id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, *properties.DatabaseName) state.CosmosMongoDatabaseId = databaseId.ID() state.Username = pointer.From(properties.UserName) diff --git a/internal/services/cosmos/cosmosdb_mongo_user_definition_resource_test.go b/internal/services/cosmos/cosmosdb_mongo_user_definition_resource_test.go index a2f0438cde3e..48d0a3154f28 100644 --- a/internal/services/cosmos/cosmosdb_mongo_user_definition_resource_test.go +++ b/internal/services/cosmos/cosmosdb_mongo_user_definition_resource_test.go @@ -93,7 +93,7 @@ func (r CosmosMongoUserDefinitionResource) Exists(ctx context.Context, clients * resp, err := clients.Cosmos.MongoRBACClient.MongoDBResourcesGetMongoUserDefinition(ctx, *id) if err != nil { - return nil, fmt.Errorf("reading %q: %+v", id, err) + return nil, fmt.Errorf("retrieving %s: %+v", id, err) } return pointer.To(resp.Model != nil), nil From e8302df3ed47aaf839df3eff23aa70baf817e6ea Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:31:23 -0600 Subject: [PATCH 11/25] `azurerm_cosmosdb_restorable_database_accounts` - migrate to `go-azure-sdk` --- ...estorable_database_accounts_data_source.go | 94 ++++++------------- 1 file changed, 30 insertions(+), 64 deletions(-) diff --git a/internal/services/cosmos/cosmosdb_restorable_database_accounts_data_source.go b/internal/services/cosmos/cosmosdb_restorable_database_accounts_data_source.go index 486e6e931bbe..c880c43895f1 100644 --- a/internal/services/cosmos/cosmosdb_restorable_database_accounts_data_source.go +++ b/internal/services/cosmos/cosmosdb_restorable_database_accounts_data_source.go @@ -7,14 +7,15 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceCosmosDbRestorableDatabaseAccounts() *pluginsdk.Resource { @@ -94,28 +95,30 @@ func dataSourceCosmosDbRestorableDatabaseAccounts() *pluginsdk.Resource { } func dataSourceCosmosDbRestorableDatabaseAccountsRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.RestorableDatabaseAccountsClient - subscriptionId := meta.(*clients.Client).Account.SubscriptionId + client := meta.(*clients.Client).Cosmos.RestorablesClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id := parse.NewRestorableDatabaseAccountID(subscriptionId, d.Get("location").(string), "read") + locationName := d.Get("location").(string) + id := restorables.NewRestorableDatabaseAccountID(meta.(*clients.Client).Account.SubscriptionId, locationName, "read") - name := d.Get("name").(string) - location := d.Get("location").(string) - resp, err := client.ListByLocation(ctx, location) + locationID := restorables.NewLocationID(id.SubscriptionId, location.Normalize(locationName)) + resp, err := client.RestorableDatabaseAccountsListByLocation(ctx, locationID) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { return fmt.Errorf("%s was not found", id) } return fmt.Errorf("retrieving %s: %+v", id, err) } - d.Set("location", location) + d.Set("location", locationName) - if props := resp.Value; props != nil { - if err := d.Set("accounts", flattenCosmosDbRestorableDatabaseAccounts(props, name)); err != nil { - return fmt.Errorf("flattening `accounts`: %+v", err) + if resp.Model != nil { + if v := resp.Model.Value; v != nil { + if err := d.Set("accounts", flattenCosmosDbRestorableDatabaseAccounts(v, d.Get("name").(string))); err != nil { + return fmt.Errorf("flattening `accounts`: %+v", err) + } } } @@ -124,39 +127,20 @@ func dataSourceCosmosDbRestorableDatabaseAccountsRead(d *pluginsdk.ResourceData, return nil } -func flattenCosmosDbRestorableDatabaseAccounts(input *[]documentdb.RestorableDatabaseAccountGetResult, accountName string) []interface{} { +func flattenCosmosDbRestorableDatabaseAccounts(input *[]restorables.RestorableDatabaseAccountGetResult, accountName string) []interface{} { result := make([]interface{}, 0) - if len(*input) == 0 { + if input == nil { return result } for _, item := range *input { - if props := item.RestorableDatabaseAccountProperties; props != nil && props.AccountName != nil && *props.AccountName == accountName { - var id, creationTime, deletionTime string - var apiType documentdb.APIType - - if item.ID != nil { - id = *item.ID - } - - if props.APIType != "" { - apiType = props.APIType - } - - if props.CreationTime != nil { - creationTime = props.CreationTime.Format(time.RFC3339) - } - - if props.DeletionTime != nil { - deletionTime = props.DeletionTime.Format(time.RFC3339) - } - + if props := item.Properties; props != nil && pointer.From(props.AccountName) == accountName { result = append(result, map[string]interface{}{ - "id": id, - "api_type": string(apiType), - "creation_time": creationTime, - "deletion_time": deletionTime, + "id": pointer.From(item.Id), + "api_type": pointer.From(props.ApiType), + "creation_time": pointer.From(props.CreationTime), + "deletion_time": pointer.From(props.DeletionTime), "restorable_locations": flattenCosmosDbRestorableDatabaseAccountsRestorableLocations(props.RestorableLocations), }) } @@ -165,37 +149,19 @@ func flattenCosmosDbRestorableDatabaseAccounts(input *[]documentdb.RestorableDat return result } -func flattenCosmosDbRestorableDatabaseAccountsRestorableLocations(input *[]documentdb.RestorableLocationResource) []interface{} { +func flattenCosmosDbRestorableDatabaseAccountsRestorableLocations(input *[]restorables.RestorableLocationResource) []interface{} { result := make([]interface{}, 0) - if len(*input) == 0 { + if input == nil { return result } for _, item := range *input { - var location, regionalDatabaseAccountInstanceId, creationTime, deletionTime string - - if item.LocationName != nil { - location = *item.LocationName - } - - if item.RegionalDatabaseAccountInstanceID != nil { - regionalDatabaseAccountInstanceId = *item.RegionalDatabaseAccountInstanceID - } - - if item.CreationTime != nil { - creationTime = item.CreationTime.Format(time.RFC3339) - } - - if item.DeletionTime != nil { - deletionTime = item.DeletionTime.Format(time.RFC3339) - } - result = append(result, map[string]interface{}{ - "creation_time": creationTime, - "deletion_time": deletionTime, - "location": location, - "regional_database_account_instance_id": regionalDatabaseAccountInstanceId, + "creation_time": pointer.From(item.CreationTime), + "deletion_time": pointer.From(item.DeletionTime), + "location": pointer.From(item.LocationName), + "regional_database_account_instance_id": pointer.From(item.RegionalDatabaseAccountInstanceId), }) } From e5046bc7e42efecee92e395b5c33358c8e2da615 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:32:17 -0600 Subject: [PATCH 12/25] `azurerm_cosmosdb_sql_container` - migrate to `go-azure-sdk` --- .../cosmos/cosmosdb_sql_container_resource.go | 50 ++++++++----------- .../cosmosdb_sql_container_resource_test.go | 2 +- 2 files changed, 21 insertions(+), 31 deletions(-) diff --git a/internal/services/cosmos/cosmosdb_sql_container_resource.go b/internal/services/cosmos/cosmosdb_sql_container_resource.go index be9a6ed1d53a..1bf55b135965 100644 --- a/internal/services/cosmos/cosmosdb_sql_container_resource.go +++ b/internal/services/cosmos/cosmosdb_sql_container_resource.go @@ -6,7 +6,6 @@ package cosmos import ( "context" "fmt" - "log" "time" "github.com/hashicorp/go-azure-helpers/lang/pointer" @@ -17,7 +16,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/common" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/migration" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -33,7 +31,7 @@ func resourceCosmosDbSQLContainer() *pluginsdk.Resource { Delete: resourceCosmosDbSQLContainerDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.SqlContainerID(id) + _, err := cosmosdb.ParseContainerID(id) return err }), @@ -163,11 +161,11 @@ func resourceCosmosDbSQLContainer() *pluginsdk.Resource { func resourceCosmosDbSQLContainerCreate(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).Cosmos.CosmosDBClient - subscriptionId := meta.(*clients.Client).Account.SubscriptionId + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - id := cosmosdb.NewContainerID(subscriptionId, d.Get("resource_group_name").(string), d.Get("account_name").(string), d.Get("database_name").(string), d.Get("name").(string)) + id := cosmosdb.NewContainerID(meta.(*clients.Client).Account.SubscriptionId, d.Get("resource_group_name").(string), d.Get("account_name").(string), d.Get("database_name").(string), d.Get("name").(string)) existing, err := client.SqlResourcesGetSqlContainer(ctx, id) if err != nil { @@ -180,9 +178,8 @@ func resourceCosmosDbSQLContainerCreate(d *pluginsdk.ResourceData, meta interfac } indexingPolicy := common.ExpandAzureRmCosmosDbIndexingPolicy(d) - err = common.ValidateAzureRmCosmosDbIndexingPolicy(indexingPolicy) - if err != nil { - return fmt.Errorf("generating indexing policy for %s", id) + if err := common.ValidateAzureRmCosmosDbIndexingPolicy(indexingPolicy); err != nil { + return fmt.Errorf("validating `indexing_policy`: %w", err) } db := cosmosdb.SqlContainerCreateUpdateParameters{ @@ -254,13 +251,12 @@ func resourceCosmosDbSQLContainerUpdate(d *pluginsdk.ResourceData, meta interfac err = common.CheckForChangeFromAutoscaleAndManualThroughput(d) if err != nil { - return fmt.Errorf("updating Cosmos SQL Container %q (Account: %q, Database: %q): %+v", id.ContainerName, id.DatabaseAccountName, id.SqlDatabaseName, err) + return fmt.Errorf("checking `autoscale_settings` and `throughput` for %s: %w", id, err) } indexingPolicy := common.ExpandAzureRmCosmosDbIndexingPolicy(d) - err = common.ValidateAzureRmCosmosDbIndexingPolicy(indexingPolicy) - if err != nil { - return fmt.Errorf("updating Cosmos SQL Container %q (Account: %q, Database: %q): %+v", id.ContainerName, id.DatabaseAccountName, id.SqlDatabaseName, err) + if err := common.ValidateAzureRmCosmosDbIndexingPolicy(indexingPolicy); err != nil { + return fmt.Errorf("validating `indexing_policy`: %w", err) } db := cosmosdb.SqlContainerCreateUpdateParameters{ @@ -305,11 +301,8 @@ func resourceCosmosDbSQLContainerUpdate(d *pluginsdk.ResourceData, meta interfac } if common.HasThroughputChange(d) { - throughputParameters := common.ExpandCosmosDBThroughputSettingsUpdateParameters(d) - err := client.SqlResourcesUpdateSqlContainerThroughputThenPoll(ctx, *id, *throughputParameters) - if err != nil { - return fmt.Errorf("setting Throughput for Cosmos SQL Container %q (Account: %q, Database: %q): %+v - "+ - "If the collection has not been created with an initial throughput, you cannot configure it later", id.ContainerName, id.DatabaseAccountName, id.SqlDatabaseName, err) + if err := client.SqlResourcesUpdateSqlContainerThroughputThenPoll(ctx, *id, common.ExpandCosmosDBThroughputSettingsUpdateParameters(d)); err != nil { + return fmt.Errorf("setting Throughput for %s: %+v - If the collection has not been created with an initial throughput, you cannot configure it later", id, err) } } @@ -318,7 +311,7 @@ func resourceCosmosDbSQLContainerUpdate(d *pluginsdk.ResourceData, meta interfac func resourceCosmosDbSQLContainerRead(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).Cosmos.CosmosDBClient - accountClient := meta.(*clients.Client).Cosmos.DatabaseClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -330,12 +323,11 @@ func resourceCosmosDbSQLContainerRead(d *pluginsdk.ResourceData, meta interface{ resp, err := client.SqlResourcesGetSqlContainer(ctx, *id) if err != nil { if response.WasNotFound(resp.HttpResponse) { - log.Printf("[INFO] Error reading %q - removing from state", id) d.SetId("") return nil } - return fmt.Errorf("reading %q: %+v", id, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } d.Set("name", id.ContainerName) @@ -383,27 +375,24 @@ func resourceCosmosDbSQLContainerRead(d *pluginsdk.ResourceData, meta interface{ } } - accResp, err := accountClient.Get(ctx, id.ResourceGroupName, id.DatabaseAccountName) + databaseAccountID := cosmosdb.NewDatabaseAccountID(id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName) + accResp, err := client.DatabaseAccountsGet(ctx, databaseAccountID) if err != nil { - return fmt.Errorf("reading CosmosDB Account %q (Resource Group %q): %+v", id.DatabaseAccountName, id.ResourceGroupName, err) - } - - if accResp.ID == nil || *accResp.ID == "" { - return fmt.Errorf("cosmosDB Account %q (Resource Group %q) ID is empty or nil", id.DatabaseAccountName, id.ResourceGroupName) + return fmt.Errorf("retrieving %s: %+v", databaseAccountID, err) } // if the cosmos account is serverless calling the get throughput api would yield an error - if !isServerlessCapacityMode(accResp) { + if !isServerlessCapacityMode(accResp.Model) { throughputResp, err := client.SqlResourcesGetSqlContainerThroughput(ctx, *id) if err != nil { if !response.WasNotFound(throughputResp.HttpResponse) { - return fmt.Errorf("reading Throughput on Cosmos SQL Container %s (Account: %q, Database: %q) ID: %v", id.ContainerName, id.DatabaseAccountName, id.SqlDatabaseName, err) + return fmt.Errorf("retrieving Throughput for %s: %v", id, err) } else { d.Set("throughput", nil) d.Set("autoscale_settings", nil) } } else { - common.SetResourceDataThroughputFromResponse(*throughputResp.Model, d) + common.SetResourceDataThroughputFromResponse(pointer.From(throughputResp.Model), d) } } @@ -412,6 +401,7 @@ func resourceCosmosDbSQLContainerRead(d *pluginsdk.ResourceData, meta interface{ func resourceCosmosDbSQLContainerDelete(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() @@ -422,7 +412,7 @@ func resourceCosmosDbSQLContainerDelete(d *pluginsdk.ResourceData, meta interfac err = client.SqlResourcesDeleteSqlContainerThenPoll(ctx, *id) if err != nil { - return fmt.Errorf("deleting Cosmos SQL Container %q (Account: %q): %+v", id.SqlDatabaseName, id.ContainerName, err) + return fmt.Errorf("deleting %s: %+v", id, err) } return nil diff --git a/internal/services/cosmos/cosmosdb_sql_container_resource_test.go b/internal/services/cosmos/cosmosdb_sql_container_resource_test.go index ea950b3ff05a..c6a7a6427b03 100644 --- a/internal/services/cosmos/cosmosdb_sql_container_resource_test.go +++ b/internal/services/cosmos/cosmosdb_sql_container_resource_test.go @@ -246,7 +246,7 @@ func (t CosmosSqlContainerResource) Exists(ctx context.Context, clients *clients resp, err := clients.Cosmos.CosmosDBClient.SqlResourcesGetSqlContainer(ctx, *id) if err != nil { - return nil, fmt.Errorf("reading Cosmos SQL Container (%s): %+v", id.String(), err) + return nil, fmt.Errorf("retrieving %s: %+v", id, err) } return pointer.To(resp.Model != nil), nil From 1301f83be1c517dd7bf89b296dec8ff53e729808 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:32:56 -0600 Subject: [PATCH 13/25] `azurerm_cosmosdb_sql_database` - migrate to `go-azure-sdk` --- .../cosmosdb_sql_database_data_source.go | 46 +++--- .../cosmos/cosmosdb_sql_database_resource.go | 151 ++++++------------ .../cosmosdb_sql_database_resource_test.go | 9 +- 3 files changed, 74 insertions(+), 132 deletions(-) diff --git a/internal/services/cosmos/cosmosdb_sql_database_data_source.go b/internal/services/cosmos/cosmosdb_sql_database_data_source.go index 1298774ef296..428048cbc16c 100644 --- a/internal/services/cosmos/cosmosdb_sql_database_data_source.go +++ b/internal/services/cosmos/cosmosdb_sql_database_data_source.go @@ -7,14 +7,15 @@ import ( "fmt" "time" + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/common" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceCosmosDbSQLDatabase() *pluginsdk.Resource { @@ -62,53 +63,46 @@ func dataSourceCosmosDbSQLDatabase() *pluginsdk.Resource { } func dataSourceCosmosDbSQLDatabaseRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.SqlClient - accountClient := meta.(*clients.Client).Cosmos.DatabaseClient - subscriptionId := meta.(*clients.Client).Account.SubscriptionId + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id := parse.NewSqlDatabaseID(subscriptionId, d.Get("resource_group_name").(string), d.Get("account_name").(string), d.Get("name").(string)) + id := cosmosdb.NewSqlDatabaseID(meta.(*clients.Client).Account.SubscriptionId, d.Get("resource_group_name").(string), d.Get("account_name").(string), d.Get("name").(string)) - resp, err := client.GetSQLDatabase(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name) + resp, err := client.SqlResourcesGetSqlDatabase(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { return fmt.Errorf("%s was not found", id) } - return fmt.Errorf("reading Cosmos SQL Database %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } d.SetId(id.ID()) - d.Set("resource_group_name", id.ResourceGroup) + + d.Set("resource_group_name", id.ResourceGroupName) d.Set("account_name", id.DatabaseAccountName) - if props := resp.SQLDatabaseGetProperties; props != nil { - if res := props.Resource; res != nil { - d.Set("name", res.ID) - } - } + d.Set("name", id.SqlDatabaseName) - accResp, err := accountClient.Get(ctx, id.ResourceGroup, id.DatabaseAccountName) + databaseAccountID := cosmosdb.NewDatabaseAccountID(id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName) + accResp, err := client.DatabaseAccountsGet(ctx, databaseAccountID) if err != nil { - return fmt.Errorf("reading CosmosDB Account %q (Resource Group %q): %+v", id.DatabaseAccountName, id.ResourceGroup, err) - } - - if accResp.ID == nil || *accResp.ID == "" { - return fmt.Errorf("cosmosDB Account %q (Resource Group %q) ID is empty or nil", id.DatabaseAccountName, id.ResourceGroup) + return fmt.Errorf("retrieving %s: %+v", databaseAccountID, err) } // if the cosmos account is serverless calling the get throughput api would yield an error - if !isServerlessCapacityMode(accResp) { - throughputResp, err := client.GetSQLDatabaseThroughput(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name) + if !isServerlessCapacityMode(accResp.Model) { + throughputResp, err := client.SqlResourcesGetSqlDatabaseThroughput(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(throughputResp.Response) { - return fmt.Errorf("reading Throughput on Cosmos SQL Database %q (Account: %q) ID: %v", id.Name, id.DatabaseAccountName, err) + if !response.WasNotFound(throughputResp.HttpResponse) { + return fmt.Errorf("retrieving %s: %v", id, err) } else { d.Set("throughput", nil) d.Set("autoscale_settings", nil) } } else { - common.SetResourceDataThroughputFromResponseLegacy(throughputResp, d) + common.SetResourceDataThroughputFromResponse(pointer.From(throughputResp.Model), d) } } diff --git a/internal/services/cosmos/cosmosdb_sql_database_resource.go b/internal/services/cosmos/cosmosdb_sql_database_resource.go index 590ecfe18840..350f83ed8f45 100644 --- a/internal/services/cosmos/cosmosdb_sql_database_resource.go +++ b/internal/services/cosmos/cosmosdb_sql_database_resource.go @@ -5,21 +5,19 @@ package cosmos import ( "fmt" - "log" "time" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/common" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/migration" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceCosmosDbSQLDatabase() *pluginsdk.Resource { @@ -30,7 +28,7 @@ func resourceCosmosDbSQLDatabase() *pluginsdk.Resource { Delete: resourceCosmosDbSQLDatabaseDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.SqlDatabaseID(id) + _, err := cosmosdb.ParseSqlDatabaseID(id) return err }), @@ -76,52 +74,40 @@ func resourceCosmosDbSQLDatabase() *pluginsdk.Resource { } func resourceCosmosDbSQLDatabaseCreate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.SqlClient - subscriptionId := meta.(*clients.Client).Account.SubscriptionId + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - id := parse.NewSqlDatabaseID(subscriptionId, d.Get("resource_group_name").(string), d.Get("account_name").(string), d.Get("name").(string)) + id := cosmosdb.NewSqlDatabaseID(meta.(*clients.Client).Account.SubscriptionId, d.Get("resource_group_name").(string), d.Get("account_name").(string), d.Get("name").(string)) - existing, err := client.GetSQLDatabase(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name) - if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { + existing, err := client.SqlResourcesGetSqlDatabase(ctx, id) + if !response.WasNotFound(existing.HttpResponse) { + if err != nil { return fmt.Errorf("checking for presence of %s: %+v", id, err) } - } else { - if existing.ID == nil && *existing.ID == "" { - return fmt.Errorf("generating import ID for %s", id) - } - - return tf.ImportAsExistsError("azurerm_cosmosdb_sql_database", *existing.ID) + return tf.ImportAsExistsError("azurerm_cosmosdb_sql_database", id.ID()) } - db := documentdb.SQLDatabaseCreateUpdateParameters{ - SQLDatabaseCreateUpdateProperties: &documentdb.SQLDatabaseCreateUpdateProperties{ - Resource: &documentdb.SQLDatabaseResource{ - ID: &id.Name, + db := cosmosdb.SqlDatabaseCreateUpdateParameters{ + Properties: cosmosdb.SqlDatabaseCreateUpdateProperties{ + Resource: cosmosdb.SqlDatabaseResource{ + Id: id.SqlDatabaseName, }, - Options: &documentdb.CreateUpdateOptions{}, + Options: &cosmosdb.CreateUpdateOptions{}, }, } - if throughput, hasThroughput := d.GetOk("throughput"); hasThroughput { - if throughput != 0 { - db.Options.Throughput = common.ConvertThroughputFromResourceDataLegacy(throughput) - } - } - - if _, hasAutoscaleSettings := d.GetOk("autoscale_settings"); hasAutoscaleSettings { - db.Options.AutoscaleSettings = common.ExpandCosmosDbAutoscaleSettingsLegacy(d) + if throughput, ok := d.GetOk("throughput"); ok && throughput != 0 { + db.Properties.Options.Throughput = common.ConvertThroughputFromResourceData(throughput) } - future, err := client.CreateUpdateSQLDatabase(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name, db) - if err != nil { - return fmt.Errorf("issuing create/update request for %s: %+v", id, err) + if _, ok := d.GetOk("autoscale_settings"); ok { + db.Properties.Options.AutoScaleSettings = common.ExpandCosmosDbAutoscaleSettings(d) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting on create/update future for %s: %+v", id, err) + if err := client.SqlResourcesCreateUpdateSqlDatabaseThenPoll(ctx, id, db); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) } d.SetId(id.ID()) @@ -130,50 +116,28 @@ func resourceCosmosDbSQLDatabaseCreate(d *pluginsdk.ResourceData, meta interface } func resourceCosmosDbSQLDatabaseUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.SqlClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SqlDatabaseID(d.Id()) + id, err := cosmosdb.ParseSqlDatabaseID(d.Id()) if err != nil { return err } err = common.CheckForChangeFromAutoscaleAndManualThroughput(d) if err != nil { - return fmt.Errorf("updating Cosmos SQL Database %q (Account: %q) - %+v", id.Name, id.DatabaseAccountName, err) - } - - db := documentdb.SQLDatabaseCreateUpdateParameters{ - SQLDatabaseCreateUpdateProperties: &documentdb.SQLDatabaseCreateUpdateProperties{ - Resource: &documentdb.SQLDatabaseResource{ - ID: &id.Name, - }, - Options: &documentdb.CreateUpdateOptions{}, - }, - } - - future, err := client.CreateUpdateSQLDatabase(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name, db) - if err != nil { - return fmt.Errorf("issuing create/update request for Cosmos SQL Database %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) + return fmt.Errorf("checking `autoscale_settings` and `throughput` for %s: %w", id, err) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting on create/update future for Cosmos SQL Database %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) + if _, err := client.SqlResourcesGetSqlDatabase(ctx, *id); err != nil { + return fmt.Errorf("retrieving %s: %w", id, err) } if common.HasThroughputChange(d) { - throughputParameters := common.ExpandCosmosDBThroughputSettingsUpdateParametersLegacy(d) - throughputFuture, err := client.UpdateSQLDatabaseThroughput(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name, *throughputParameters) - if err != nil { - if response.WasNotFound(throughputFuture.Response()) { - return fmt.Errorf("setting Throughput for Cosmos SQL Database %q (Account: %q) %+v - "+ - "If the collection has not been created with an initial throughput, you cannot configure it later", id.Name, id.DatabaseAccountName, err) - } - } - - if err = throughputFuture.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting on ThroughputUpdate future for Cosmos SQL Database %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) + if err := client.SqlResourcesUpdateSqlDatabaseThroughputThenPoll(ctx, *id, common.ExpandCosmosDBThroughputSettingsUpdateParameters(d)); err != nil { + return fmt.Errorf("setting Throughput for %s: %+v - If the collection has not been created with an initial throughput, you cannot configure it later", id, err) } } @@ -181,56 +145,48 @@ func resourceCosmosDbSQLDatabaseUpdate(d *pluginsdk.ResourceData, meta interface } func resourceCosmosDbSQLDatabaseRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.SqlClient - accountClient := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SqlDatabaseID(d.Id()) + id, err := cosmosdb.ParseSqlDatabaseID(d.Id()) if err != nil { return err } - resp, err := client.GetSQLDatabase(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name) + resp, err := client.SqlResourcesGetSqlDatabase(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[INFO] Error reading Cosmos SQL Database %q (Account: %q) - removing from state", id.Name, id.DatabaseAccountName) + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("reading Cosmos SQL Database %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } - d.Set("resource_group_name", id.ResourceGroup) + d.Set("resource_group_name", id.ResourceGroupName) d.Set("account_name", id.DatabaseAccountName) - if props := resp.SQLDatabaseGetProperties; props != nil { - if res := props.Resource; res != nil { - d.Set("name", res.ID) - } - } + d.Set("name", id.SqlDatabaseName) - accResp, err := accountClient.Get(ctx, id.ResourceGroup, id.DatabaseAccountName) + databaseAccountID := cosmosdb.NewDatabaseAccountID(id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName) + accResp, err := client.DatabaseAccountsGet(ctx, databaseAccountID) if err != nil { - return fmt.Errorf("reading CosmosDB Account %q (Resource Group %q): %+v", id.DatabaseAccountName, id.ResourceGroup, err) - } - - if accResp.ID == nil || *accResp.ID == "" { - return fmt.Errorf("cosmosDB Account %q (Resource Group %q) ID is empty or nil", id.DatabaseAccountName, id.ResourceGroup) + return fmt.Errorf("retrieving %s: %+v", databaseAccountID, err) } // if the cosmos account is serverless calling the get throughput api would yield an error - if !isServerlessCapacityMode(accResp) { - throughputResp, err := client.GetSQLDatabaseThroughput(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name) + if !isServerlessCapacityMode(accResp.Model) { + throughputResp, err := client.SqlResourcesGetSqlDatabaseThroughput(ctx, *id) if err != nil { - if !utils.ResponseWasNotFound(throughputResp.Response) { - return fmt.Errorf("reading Throughput on Cosmos SQL Database %q (Account: %q) ID: %v", id.Name, id.DatabaseAccountName, err) + if !response.WasNotFound(throughputResp.HttpResponse) { + return fmt.Errorf("retrieving Throughput for %s: %v", id, err) } else { d.Set("throughput", nil) d.Set("autoscale_settings", nil) } } else { - common.SetResourceDataThroughputFromResponseLegacy(throughputResp, d) + common.SetResourceDataThroughputFromResponse(pointer.From(throughputResp.Model), d) } } @@ -238,25 +194,18 @@ func resourceCosmosDbSQLDatabaseRead(d *pluginsdk.ResourceData, meta interface{} } func resourceCosmosDbSQLDatabaseDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.SqlClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SqlDatabaseID(d.Id()) + id, err := cosmosdb.ParseSqlDatabaseID(d.Id()) if err != nil { return err } - future, err := client.DeleteSQLDatabase(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name) - if err != nil { - if !response.WasNotFound(future.Response()) { - return fmt.Errorf("deleting Cosmos SQL Database %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) - } - } - - err = future.WaitForCompletionRef(ctx, client.Client) - if err != nil { - return fmt.Errorf("waiting on delete future for Cosmos SQL Database %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) + if err := client.SqlResourcesDeleteSqlDatabaseThenPoll(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", id, err) } return nil diff --git a/internal/services/cosmos/cosmosdb_sql_database_resource_test.go b/internal/services/cosmos/cosmosdb_sql_database_resource_test.go index 7afab08d4f1b..6897ce9c00fd 100644 --- a/internal/services/cosmos/cosmosdb_sql_database_resource_test.go +++ b/internal/services/cosmos/cosmosdb_sql_database_resource_test.go @@ -13,7 +13,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) @@ -106,17 +105,17 @@ func TestAccCosmosDbSqlDatabase_serverless(t *testing.T) { } func (t CosmosSqlDatabaseResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.SqlDatabaseID(state.ID) + id, err := cosmosdb.ParseSqlDatabaseID(state.ID) if err != nil { return nil, err } - resp, err := clients.Cosmos.SqlClient.GetSQLDatabase(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name) + resp, err := clients.Cosmos.CosmosDBClient.SqlResourcesGetSqlDatabase(ctx, *id) if err != nil { - return nil, fmt.Errorf("reading Cosmos SQL Database (%s): %+v", id.String(), err) + return nil, fmt.Errorf("retrieving %s: %+v", id, err) } - return pointer.To(resp.ID != nil), nil + return pointer.To(resp.Model != nil), nil } func (CosmosSqlDatabaseResource) basic(data acceptance.TestData) string { From 174cb952218880d6abac2aa432c57d4f6db1308b Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:33:28 -0600 Subject: [PATCH 14/25] `azurerm_cosmosdb_sql_function` - migrate to `go-azure-sdk` --- .../cosmos/cosmosdb_sql_function_resource.go | 130 ++++++++++-------- .../cosmosdb_sql_function_resource_test.go | 17 +-- 2 files changed, 82 insertions(+), 65 deletions(-) diff --git a/internal/services/cosmos/cosmosdb_sql_function_resource.go b/internal/services/cosmos/cosmosdb_sql_function_resource.go index 8f283461a92e..98e83afdbda6 100644 --- a/internal/services/cosmos/cosmosdb_sql_function_resource.go +++ b/internal/services/cosmos/cosmosdb_sql_function_resource.go @@ -5,25 +5,23 @@ package cosmos import ( "fmt" - "log" "time" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceCosmosDbSQLFunction() *pluginsdk.Resource { return &pluginsdk.Resource{ - Create: resourceCosmosDbSQLFunctionCreateUpdate, + Create: resourceCosmosDbSQLFunctionCreate, Read: resourceCosmosDbSQLFunctionRead, - Update: resourceCosmosDbSQLFunctionCreateUpdate, + Update: resourceCosmosDbSQLFunctionUpdate, Delete: resourceCosmosDbSQLFunctionDelete, Timeouts: &pluginsdk.ResourceTimeout{ @@ -34,7 +32,7 @@ func resourceCosmosDbSQLFunction() *pluginsdk.Resource { }, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.SqlFunctionID(id) + _, err := cosmosdb.ParseUserDefinedFunctionID(id) return err }), @@ -49,7 +47,7 @@ func resourceCosmosDbSQLFunction() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.SqlContainerID, + ValidateFunc: cosmosdb.ValidateContainerID, }, "body": { @@ -61,99 +59,123 @@ func resourceCosmosDbSQLFunction() *pluginsdk.Resource { } } -func resourceCosmosDbSQLFunctionCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - subscriptionId := meta.(*clients.Client).Account.SubscriptionId - client := meta.(*clients.Client).Cosmos.SqlResourceClient - ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) +func resourceCosmosDbSQLFunctionCreate(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Cosmos.CosmosDBClient + + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - name := d.Get("name").(string) - containerId, _ := parse.SqlContainerID(d.Get("container_id").(string)) - body := d.Get("body").(string) + containerId, err := cosmosdb.ParseContainerID(d.Get("container_id").(string)) + if err != nil { + return err + } - id := parse.NewSqlFunctionID(subscriptionId, containerId.ResourceGroup, containerId.DatabaseAccountName, containerId.SqlDatabaseName, containerId.ContainerName, name) + id := cosmosdb.NewUserDefinedFunctionID(meta.(*clients.Client).Account.SubscriptionId, containerId.ResourceGroupName, containerId.DatabaseAccountName, containerId.SqlDatabaseName, containerId.ContainerName, d.Get("name").(string)) - if d.IsNewResource() { - existing, err := client.GetSQLUserDefinedFunction(ctx, id.ResourceGroup, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName, id.UserDefinedFunctionName) + existing, err := client.SqlResourcesGetSqlUserDefinedFunction(ctx, id) + if !response.WasNotFound(existing.HttpResponse) { if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for existing CosmosDb SqlFunction %q: %+v", id, err) - } - } - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_cosmosdb_sql_function", id.ID()) + return fmt.Errorf("checking for existing %s: %+v", id, err) } + return tf.ImportAsExistsError("azurerm_cosmosdb_sql_function", id.ID()) } - createUpdateSqlUserDefinedFunctionParameters := documentdb.SQLUserDefinedFunctionCreateUpdateParameters{ - SQLUserDefinedFunctionCreateUpdateProperties: &documentdb.SQLUserDefinedFunctionCreateUpdateProperties{ - Resource: &documentdb.SQLUserDefinedFunctionResource{ - ID: &name, - Body: &body, + payload := cosmosdb.SqlUserDefinedFunctionCreateUpdateParameters{ + Properties: cosmosdb.SqlUserDefinedFunctionCreateUpdateProperties{ + Resource: cosmosdb.SqlUserDefinedFunctionResource{ + Id: id.UserDefinedFunctionName, + Body: pointer.To(d.Get("body").(string)), }, - Options: &documentdb.CreateUpdateOptions{}, + Options: &cosmosdb.CreateUpdateOptions{}, }, } - future, err := client.CreateUpdateSQLUserDefinedFunction(ctx, id.ResourceGroup, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName, id.UserDefinedFunctionName, createUpdateSqlUserDefinedFunctionParameters) + + if err := client.SqlResourcesCreateUpdateSqlUserDefinedFunctionThenPoll(ctx, id, payload); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + d.SetId(id.ID()) + return resourceCosmosDbSQLFunctionRead(d, meta) +} + +func resourceCosmosDbSQLFunctionUpdate(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Cosmos.CosmosDBClient + + ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := cosmosdb.ParseUserDefinedFunctionID(d.Id()) if err != nil { - return fmt.Errorf("creating/updating CosmosDb SqlFunction %q: %+v", id, err) + return err } - if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for creation/update of the CosmosDb SqlFunction %q: %+v", id, err) + if _, err := client.SqlResourcesGetSqlUserDefinedFunction(ctx, *id); err != nil { + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + payload := cosmosdb.SqlUserDefinedFunctionCreateUpdateParameters{ + Properties: cosmosdb.SqlUserDefinedFunctionCreateUpdateProperties{ + Resource: cosmosdb.SqlUserDefinedFunctionResource{ + Id: id.UserDefinedFunctionName, + Body: pointer.To(d.Get("body").(string)), + }, + Options: &cosmosdb.CreateUpdateOptions{}, + }, + } + + if err := client.SqlResourcesCreateUpdateSqlUserDefinedFunctionThenPoll(ctx, *id, payload); err != nil { + return fmt.Errorf("updating %s: %+v", id, err) } - d.SetId(id.ID()) return resourceCosmosDbSQLFunctionRead(d, meta) } func resourceCosmosDbSQLFunctionRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.SqlResourceClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SqlFunctionID(d.Id()) + id, err := cosmosdb.ParseUserDefinedFunctionID(d.Id()) if err != nil { return err } - resp, err := client.GetSQLUserDefinedFunction(ctx, id.ResourceGroup, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName, id.UserDefinedFunctionName) + resp, err := client.SqlResourcesGetSqlUserDefinedFunction(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[INFO] CosmosDb SqlFunction %q does not exist - removing from state", d.Id()) + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("retrieving CosmosDb SqlFunction %q: %+v", id, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } - containerId := parse.NewSqlContainerID(id.SubscriptionId, id.ResourceGroup, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName) + d.Set("name", id.UserDefinedFunctionName) - d.Set("container_id", containerId.ID()) - if props := resp.SQLUserDefinedFunctionGetProperties; props != nil { - if props.Resource != nil { + d.Set("container_id", cosmosdb.NewContainerID(id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName).ID()) + + if resp.Model != nil { + if props := resp.Model.Properties; props != nil && props.Resource != nil { d.Set("body", props.Resource.Body) } } + return nil } func resourceCosmosDbSQLFunctionDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.SqlResourceClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SqlFunctionID(d.Id()) + id, err := cosmosdb.ParseUserDefinedFunctionID(d.Id()) if err != nil { return err } - future, err := client.DeleteSQLUserDefinedFunction(ctx, id.ResourceGroup, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName, id.UserDefinedFunctionName) - if err != nil { - return fmt.Errorf("deleting CosmosDb SqlFunction %q: %+v", id, err) + if err := client.SqlResourcesDeleteSqlUserDefinedFunctionThenPoll(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", id, err) } - if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for deletion of the CosmosDb SqlFunction %q: %+v", id, err) - } return nil } diff --git a/internal/services/cosmos/cosmosdb_sql_function_resource_test.go b/internal/services/cosmos/cosmosdb_sql_function_resource_test.go index c86af2a28fbb..b961d0a9d049 100644 --- a/internal/services/cosmos/cosmosdb_sql_function_resource_test.go +++ b/internal/services/cosmos/cosmosdb_sql_function_resource_test.go @@ -8,14 +8,12 @@ import ( "fmt" "testing" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb" // nolint: staticcheck "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) type CosmosDbSQLFunctionResource struct{} @@ -77,18 +75,15 @@ func TestAccCosmosDbSQLFunction_update(t *testing.T) { } func (r CosmosDbSQLFunctionResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.SqlFunctionID(state.ID) + id, err := cosmosdb.ParseUserDefinedFunctionID(state.ID) if err != nil { return nil, err } - resp, err := client.Cosmos.SqlResourceClient.GetSQLUserDefinedFunction(ctx, id.ResourceGroup, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName, id.UserDefinedFunctionName) + resp, err := client.Cosmos.CosmosDBClient.SqlResourcesGetSqlUserDefinedFunction(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return pointer.To(false), nil - } - return nil, fmt.Errorf("retrieving CosmosDb SQLFunction %q: %+v", id, err) + return nil, fmt.Errorf("retrieving %s: %+v", id, err) } - return pointer.To(true), nil + return pointer.To(resp.Model != nil), nil } func (r CosmosDbSQLFunctionResource) template(data acceptance.TestData) string { @@ -132,7 +127,7 @@ resource "azurerm_cosmosdb_sql_container" "test" { database_name = azurerm_cosmosdb_sql_database.test.name partition_key_paths = ["/definition/id"] } - `, data.Locations.Primary, data.RandomInteger, string(documentdb.DatabaseAccountKindGlobalDocumentDB), string(documentdb.DefaultConsistencyLevelSession)) + `, data.Locations.Primary, data.RandomInteger, string(cosmosdb.DatabaseAccountKindGlobalDocumentDB), string(cosmosdb.DefaultConsistencyLevelSession)) } func (r CosmosDbSQLFunctionResource) basic(data acceptance.TestData) string { From 9d8368a467b97d9295e22badf950a433a80cfa2e Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:34:16 -0600 Subject: [PATCH 15/25] `azurerm_cosmosdb_sql_role_assignment` - migrate to `go-azure-sdk` --- .../cosmosdb_sql_role_assignment_resource.go | 101 +++++++----------- ...mosdb_sql_role_assignment_resource_test.go | 12 +-- 2 files changed, 45 insertions(+), 68 deletions(-) diff --git a/internal/services/cosmos/cosmosdb_sql_role_assignment_resource.go b/internal/services/cosmos/cosmosdb_sql_role_assignment_resource.go index 4149c913c10d..c00c28dd2bff 100644 --- a/internal/services/cosmos/cosmosdb_sql_role_assignment_resource.go +++ b/internal/services/cosmos/cosmosdb_sql_role_assignment_resource.go @@ -5,22 +5,20 @@ package cosmos import ( "fmt" - "log" "time" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb" // nolint: staticcheck "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs" "github.com/hashicorp/go-uuid" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceCosmosDbSQLRoleAssignment() *pluginsdk.Resource { @@ -38,7 +36,7 @@ func resourceCosmosDbSQLRoleAssignment() *pluginsdk.Resource { }, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.SqlRoleAssignmentID(id) + _, err := rbacs.ParseAccountID(id) return err }), @@ -77,15 +75,15 @@ func resourceCosmosDbSQLRoleAssignment() *pluginsdk.Resource { "role_definition_id": { Type: pluginsdk.TypeString, Required: true, - ValidateFunc: validate.SqlRoleDefinitionID, + ValidateFunc: rbacs.ValidateSqlRoleDefinitionID, }, }, } } func resourceCosmosDbSQLRoleAssignmentCreate(d *pluginsdk.ResourceData, meta interface{}) error { - subscriptionId := meta.(*clients.Client).Account.SubscriptionId - client := meta.(*clients.Client).Cosmos.SqlResourceClient + client := meta.(*clients.Client).Cosmos.RbacsClient + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -99,39 +97,29 @@ func resourceCosmosDbSQLRoleAssignmentCreate(d *pluginsdk.ResourceData, meta int name = uuid } - resourceGroup := d.Get("resource_group_name").(string) - accountName := d.Get("account_name").(string) - - id := parse.NewSqlRoleAssignmentID(subscriptionId, resourceGroup, accountName, name) + id := rbacs.NewAccountID(meta.(*clients.Client).Account.SubscriptionId, d.Get("resource_group_name").(string), d.Get("account_name").(string), name) locks.ByName(id.DatabaseAccountName, CosmosDbAccountResourceName) defer locks.UnlockByName(id.DatabaseAccountName, CosmosDbAccountResourceName) - existing, err := client.GetSQLRoleAssignment(ctx, id.Name, id.ResourceGroup, id.DatabaseAccountName) - if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { + existing, err := client.SqlResourcesGetSqlRoleAssignment(ctx, id) + if !response.WasNotFound(existing.HttpResponse) { + if err != nil { return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } - } - if !utils.ResponseWasNotFound(existing.Response) { return tf.ImportAsExistsError("azurerm_cosmosdb_sql_role_assignment", id.ID()) } - parameters := documentdb.SQLRoleAssignmentCreateUpdateParameters{ - SQLRoleAssignmentResource: &documentdb.SQLRoleAssignmentResource{ - PrincipalID: pointer.To(d.Get("principal_id").(string)), - RoleDefinitionID: pointer.To(d.Get("role_definition_id").(string)), + parameters := rbacs.SqlRoleAssignmentCreateUpdateParameters{ + Properties: &rbacs.SqlRoleAssignmentResource{ + PrincipalId: pointer.To(d.Get("principal_id").(string)), + RoleDefinitionId: pointer.To(d.Get("role_definition_id").(string)), Scope: pointer.To(d.Get("scope").(string)), }, } - future, err := client.CreateUpdateSQLRoleAssignment(ctx, id.Name, id.ResourceGroup, id.DatabaseAccountName, parameters) - if err != nil { - return fmt.Errorf("creating/updating %s: %+v", id, err) - } - - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for the completion of the creating/updating of %s: %+v", id, err) + if err := client.SqlResourcesCreateUpdateSqlRoleAssignmentThenPoll(ctx, id, parameters); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) } d.SetId(id.ID()) @@ -139,19 +127,19 @@ func resourceCosmosDbSQLRoleAssignmentCreate(d *pluginsdk.ResourceData, meta int } func resourceCosmosDbSQLRoleAssignmentRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.SqlResourceClient + client := meta.(*clients.Client).Cosmos.RbacsClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SqlRoleAssignmentID(d.Id()) + id, err := rbacs.ParseAccountID(d.Id()) if err != nil { return err } - resp, err := client.GetSQLRoleAssignment(ctx, id.Name, id.ResourceGroup, id.DatabaseAccountName) + resp, err := client.SqlResourcesGetSqlRoleAssignment(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[INFO] %s was not found - removing from state", id) + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } @@ -159,25 +147,28 @@ func resourceCosmosDbSQLRoleAssignmentRead(d *pluginsdk.ResourceData, meta inter return fmt.Errorf("retrieving %s: %+v", id, err) } - d.Set("name", id.Name) - d.Set("resource_group_name", id.ResourceGroup) + d.Set("name", id.DatabaseAccountName) + d.Set("resource_group_name", id.ResourceGroupName) d.Set("account_name", id.DatabaseAccountName) - if props := resp.SQLRoleAssignmentResource; props != nil { - d.Set("principal_id", props.PrincipalID) - d.Set("role_definition_id", props.RoleDefinitionID) - d.Set("scope", props.Scope) + if resp.Model != nil { + if props := resp.Model.Properties; props != nil { + d.Set("principal_id", props.PrincipalId) + d.Set("role_definition_id", props.RoleDefinitionId) + d.Set("scope", props.Scope) + } } return nil } func resourceCosmosDbSQLRoleAssignmentUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.SqlResourceClient + client := meta.(*clients.Client).Cosmos.RbacsClient + ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SqlRoleAssignmentID(d.Id()) + id, err := rbacs.ParseAccountID(d.Id()) if err != nil { return err } @@ -185,33 +176,28 @@ func resourceCosmosDbSQLRoleAssignmentUpdate(d *pluginsdk.ResourceData, meta int locks.ByName(id.DatabaseAccountName, CosmosDbAccountResourceName) defer locks.UnlockByName(id.DatabaseAccountName, CosmosDbAccountResourceName) - parameters := documentdb.SQLRoleAssignmentCreateUpdateParameters{ - SQLRoleAssignmentResource: &documentdb.SQLRoleAssignmentResource{ - PrincipalID: pointer.To(d.Get("principal_id").(string)), - RoleDefinitionID: pointer.To(d.Get("role_definition_id").(string)), + parameters := rbacs.SqlRoleAssignmentCreateUpdateParameters{ + Properties: &rbacs.SqlRoleAssignmentResource{ + PrincipalId: pointer.To(d.Get("principal_id").(string)), + RoleDefinitionId: pointer.To(d.Get("role_definition_id").(string)), Scope: pointer.To(d.Get("scope").(string)), }, } - future, err := client.CreateUpdateSQLRoleAssignment(ctx, id.Name, id.ResourceGroup, id.DatabaseAccountName, parameters) - if err != nil { + if err := client.SqlResourcesCreateUpdateSqlRoleAssignmentThenPoll(ctx, *id, parameters); err != nil { return fmt.Errorf("updating %s: %+v", id, err) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for the completion of the updating of %s: %+v", id, err) - } - - d.SetId(id.ID()) return resourceCosmosDbSQLRoleAssignmentRead(d, meta) } func resourceCosmosDbSQLRoleAssignmentDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.SqlResourceClient + client := meta.(*clients.Client).Cosmos.RbacsClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SqlRoleAssignmentID(d.Id()) + id, err := rbacs.ParseAccountID(d.Id()) if err != nil { return err } @@ -219,14 +205,9 @@ func resourceCosmosDbSQLRoleAssignmentDelete(d *pluginsdk.ResourceData, meta int locks.ByName(id.DatabaseAccountName, CosmosDbAccountResourceName) defer locks.UnlockByName(id.DatabaseAccountName, CosmosDbAccountResourceName) - future, err := client.DeleteSQLRoleAssignment(ctx, id.Name, id.ResourceGroup, id.DatabaseAccountName) - if err != nil { + if err := client.SqlResourcesDeleteSqlRoleAssignmentThenPoll(ctx, *id); err != nil { return fmt.Errorf("deleting %s: %+v", id, err) } - if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for the completion of the deleting of %s: %+v", id, err) - } - return nil } diff --git a/internal/services/cosmos/cosmosdb_sql_role_assignment_resource_test.go b/internal/services/cosmos/cosmosdb_sql_role_assignment_resource_test.go index fb9d0cdead1c..1f27ed9b6245 100644 --- a/internal/services/cosmos/cosmosdb_sql_role_assignment_resource_test.go +++ b/internal/services/cosmos/cosmosdb_sql_role_assignment_resource_test.go @@ -10,12 +10,11 @@ import ( "github.com/google/uuid" "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) type CosmosDbSQLRoleAssignmentResource struct{} @@ -96,19 +95,16 @@ func TestAccCosmosDbSQLRoleAssignment_multiple(t *testing.T) { } func (r CosmosDbSQLRoleAssignmentResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.SqlRoleAssignmentID(state.ID) + id, err := rbacs.ParseAccountID(state.ID) if err != nil { return nil, err } - resp, err := client.Cosmos.SqlResourceClient.GetSQLRoleAssignment(ctx, id.Name, id.ResourceGroup, id.DatabaseAccountName) + resp, err := client.Cosmos.RbacsClient.SqlResourcesGetSqlRoleAssignment(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return pointer.To(false), nil - } return nil, fmt.Errorf("retrieving %q: %+v", id, err) } - return pointer.To(true), nil + return pointer.To(resp.Model != nil), nil } func (r CosmosDbSQLRoleAssignmentResource) template(data acceptance.TestData) string { From 9f7c5be7ba57045b1a2378867b6bf64cec37225c Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:36:35 -0600 Subject: [PATCH 16/25] `azurerm_cosmosdb_sql_role_definition` - migrate to `go-azure-sdk` --- ...osmosdb_sql_role_definition_data_source.go | 35 +++-- .../cosmosdb_sql_role_definition_resource.go | 135 +++++++++--------- ...mosdb_sql_role_definition_resource_test.go | 14 +- 3 files changed, 90 insertions(+), 94 deletions(-) diff --git a/internal/services/cosmos/cosmosdb_sql_role_definition_data_source.go b/internal/services/cosmos/cosmosdb_sql_role_definition_data_source.go index d577430d3edd..61d0f5641076 100644 --- a/internal/services/cosmos/cosmosdb_sql_role_definition_data_source.go +++ b/internal/services/cosmos/cosmosdb_sql_role_definition_data_source.go @@ -7,9 +7,10 @@ import ( "fmt" "time" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -78,37 +79,35 @@ func dataSourceCosmosDbSQLRoleDefinition() *pluginsdk.Resource { } func dataSourceCosmosDbSQLRoleDefinitionRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.SqlResourceClient - subscriptionId := meta.(*clients.Client).Account.SubscriptionId + client := meta.(*clients.Client).Cosmos.RbacsClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - roleDefinitionId := d.Get("role_definition_id").(string) - resourceGroup := d.Get("resource_group_name").(string) - accountName := d.Get("account_name").(string) - - id := parse.NewSqlRoleDefinitionID(subscriptionId, resourceGroup, accountName, roleDefinitionId) + id := rbacs.NewSqlRoleDefinitionID(meta.(*clients.Client).Account.SubscriptionId, d.Get("resource_group_name").(string), d.Get("account_name").(string), d.Get("role_definition_id").(string)) - resp, err := client.GetSQLRoleDefinition(ctx, id.Name, id.ResourceGroup, id.DatabaseAccountName) + resp, err := client.SqlResourcesGetSqlRoleDefinition(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { return fmt.Errorf("%s was not found", id) } return fmt.Errorf("retrieving %s: %+v", id, err) } d.SetId(id.ID()) - d.Set("role_definition_id", id.Name) - d.Set("resource_group_name", id.ResourceGroup) + d.Set("role_definition_id", id.RoleDefinitionId) + d.Set("resource_group_name", id.ResourceGroupName) d.Set("account_name", id.DatabaseAccountName) - if props := resp.SQLRoleDefinitionResource; props != nil { - d.Set("assignable_scopes", utils.FlattenStringSlice(props.AssignableScopes)) - d.Set("name", props.RoleName) - d.Set("type", props.Type) + if resp.Model != nil { + if props := resp.Model.Properties; props != nil { + d.Set("assignable_scopes", utils.FlattenStringSlice(props.AssignableScopes)) + d.Set("name", props.RoleName) + d.Set("type", props.Type) - if err := d.Set("permissions", flattenSqlRoleDefinitionPermissions(props.Permissions)); err != nil { - return fmt.Errorf("setting `permissions`: %+v", err) + if err := d.Set("permissions", flattenSqlRoleDefinitionPermissions(props.Permissions)); err != nil { + return fmt.Errorf("setting `permissions`: %+v", err) + } } } diff --git a/internal/services/cosmos/cosmosdb_sql_role_definition_resource.go b/internal/services/cosmos/cosmosdb_sql_role_definition_resource.go index ff51dbe7c122..c96a7c012cf7 100644 --- a/internal/services/cosmos/cosmosdb_sql_role_definition_resource.go +++ b/internal/services/cosmos/cosmosdb_sql_role_definition_resource.go @@ -5,17 +5,16 @@ package cosmos import ( "fmt" - "log" "time" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb" // nolint: staticcheck "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs" "github.com/hashicorp/go-uuid" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -38,7 +37,7 @@ func resourceCosmosDbSQLRoleDefinition() *pluginsdk.Resource { }, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.SqlRoleDefinitionID(id) + _, err := rbacs.ParseSqlRoleDefinitionID(id) return err }), @@ -64,10 +63,10 @@ func resourceCosmosDbSQLRoleDefinition() *pluginsdk.Resource { Type: pluginsdk.TypeString, Optional: true, ForceNew: true, - Default: string(documentdb.RoleDefinitionTypeCustomRole), + Default: string(rbacs.RoleDefinitionTypeCustomRole), ValidateFunc: validation.StringInSlice([]string{ - string(documentdb.RoleDefinitionTypeBuiltInRole), - string(documentdb.RoleDefinitionTypeCustomRole), + string(rbacs.RoleDefinitionTypeBuiltInRole), + string(rbacs.RoleDefinitionTypeCustomRole), }, false), }, @@ -107,8 +106,8 @@ func resourceCosmosDbSQLRoleDefinition() *pluginsdk.Resource { } func resourceCosmosDbSQLRoleDefinitionCreate(d *pluginsdk.ResourceData, meta interface{}) error { - subscriptionId := meta.(*clients.Client).Account.SubscriptionId - client := meta.(*clients.Client).Cosmos.SqlResourceClient + client := meta.(*clients.Client).Cosmos.RbacsClient + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -122,78 +121,70 @@ func resourceCosmosDbSQLRoleDefinitionCreate(d *pluginsdk.ResourceData, meta int roleDefinitionId = uuid } - resourceGroup := d.Get("resource_group_name").(string) - accountName := d.Get("account_name").(string) - - id := parse.NewSqlRoleDefinitionID(subscriptionId, resourceGroup, accountName, roleDefinitionId) + id := rbacs.NewSqlRoleDefinitionID(meta.(*clients.Client).Account.SubscriptionId, d.Get("resource_group_name").(string), d.Get("account_name").(string), roleDefinitionId) locks.ByName(id.DatabaseAccountName, CosmosDbAccountResourceName) defer locks.UnlockByName(id.DatabaseAccountName, CosmosDbAccountResourceName) - existing, err := client.GetSQLRoleDefinition(ctx, id.Name, id.ResourceGroup, id.DatabaseAccountName) - if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { + existing, err := client.SqlResourcesGetSqlRoleDefinition(ctx, id) + if !response.WasNotFound(existing.HttpResponse) { + if err != nil { return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } - } - if !utils.ResponseWasNotFound(existing.Response) { return tf.ImportAsExistsError("azurerm_cosmosdb_sql_role_definition", id.ID()) } - parameters := documentdb.SQLRoleDefinitionCreateUpdateParameters{ - SQLRoleDefinitionResource: &documentdb.SQLRoleDefinitionResource{ + parameters := rbacs.SqlRoleDefinitionCreateUpdateParameters{ + Properties: &rbacs.SqlRoleDefinitionResource{ RoleName: pointer.To(d.Get("name").(string)), AssignableScopes: utils.ExpandStringSlice(d.Get("assignable_scopes").(*pluginsdk.Set).List()), Permissions: expandSqlRoleDefinitionPermissions(d.Get("permissions").(*pluginsdk.Set).List()), - Type: documentdb.RoleDefinitionType(d.Get("type").(string)), + Type: pointer.ToEnum[rbacs.RoleDefinitionType](d.Get("type").(string)), }, } - future, err := client.CreateUpdateSQLRoleDefinition(ctx, id.Name, id.ResourceGroup, id.DatabaseAccountName, parameters) - if err != nil { + if err := client.SqlResourcesCreateUpdateSqlRoleDefinitionThenPoll(ctx, id, parameters); err != nil { return fmt.Errorf("creating %s: %+v", id, err) } - if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for creation of %s: %+v", id, err) - } - d.SetId(id.ID()) return resourceCosmosDbSQLRoleDefinitionRead(d, meta) } func resourceCosmosDbSQLRoleDefinitionRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.SqlResourceClient + client := meta.(*clients.Client).Cosmos.RbacsClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SqlRoleDefinitionID(d.Id()) + id, err := rbacs.ParseSqlRoleDefinitionID(d.Id()) if err != nil { return err } - resp, err := client.GetSQLRoleDefinition(ctx, id.Name, id.ResourceGroup, id.DatabaseAccountName) + resp, err := client.SqlResourcesGetSqlRoleDefinition(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[DEBUG] %s was not found - removing from state", *id) + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } return fmt.Errorf("retrieving %s: %+v", *id, err) } - d.Set("role_definition_id", id.Name) - d.Set("resource_group_name", id.ResourceGroup) + d.Set("role_definition_id", id.RoleDefinitionId) + d.Set("resource_group_name", id.ResourceGroupName) d.Set("account_name", id.DatabaseAccountName) - if props := resp.SQLRoleDefinitionResource; props != nil { - d.Set("assignable_scopes", utils.FlattenStringSlice(props.AssignableScopes)) - d.Set("name", props.RoleName) - d.Set("type", props.Type) + if resp.Model != nil { + if props := resp.Model.Properties; props != nil { + d.Set("assignable_scopes", utils.FlattenStringSlice(props.AssignableScopes)) + d.Set("name", props.RoleName) + d.Set("type", props.Type) - if err := d.Set("permissions", flattenSqlRoleDefinitionPermissions(props.Permissions)); err != nil { - return fmt.Errorf("setting `permissions`: %+v", err) + if err := d.Set("permissions", flattenSqlRoleDefinitionPermissions(props.Permissions)); err != nil { + return fmt.Errorf("setting `permissions`: %+v", err) + } } } @@ -201,11 +192,12 @@ func resourceCosmosDbSQLRoleDefinitionRead(d *pluginsdk.ResourceData, meta inter } func resourceCosmosDbSQLRoleDefinitionUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.SqlResourceClient + client := meta.(*clients.Client).Cosmos.RbacsClient + ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SqlRoleDefinitionID(d.Id()) + id, err := rbacs.ParseSqlRoleDefinitionID(d.Id()) if err != nil { return err } @@ -213,35 +205,49 @@ func resourceCosmosDbSQLRoleDefinitionUpdate(d *pluginsdk.ResourceData, meta int locks.ByName(id.DatabaseAccountName, CosmosDbAccountResourceName) defer locks.UnlockByName(id.DatabaseAccountName, CosmosDbAccountResourceName) - parameters := documentdb.SQLRoleDefinitionCreateUpdateParameters{ - SQLRoleDefinitionResource: &documentdb.SQLRoleDefinitionResource{ - RoleName: pointer.To(d.Get("name").(string)), - AssignableScopes: utils.ExpandStringSlice(d.Get("assignable_scopes").(*pluginsdk.Set).List()), - Permissions: expandSqlRoleDefinitionPermissions(d.Get("permissions").(*pluginsdk.Set).List()), - Type: documentdb.RoleDefinitionType(d.Get("type").(string)), - }, + existing, err := client.SqlResourcesGetSqlRoleDefinition(ctx, *id) + if err != nil { + return fmt.Errorf("retrieving %s: %w", id, err) } - future, err := client.CreateUpdateSQLRoleDefinition(ctx, id.Name, id.ResourceGroup, id.DatabaseAccountName, parameters) - if err != nil { - return fmt.Errorf("updating %s: %+v", id, err) + if existing.Model == nil { + return fmt.Errorf("retrieving %s: model was nil", id) } - if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for update of %s: %+v", id, err) + if existing.Model.Properties == nil { + return fmt.Errorf("retrieving %s: properties was nil", id) } - d.SetId(id.ID()) + parameters := rbacs.SqlRoleDefinitionCreateUpdateParameters{ + Properties: existing.Model.Properties, + } + + if d.HasChange("assignable_scopes") { + parameters.Properties.AssignableScopes = utils.ExpandStringSlice(d.Get("assignable_scopes").(*pluginsdk.Set).List()) + } + + if d.HasChange("name") { + parameters.Properties.RoleName = pointer.To(d.Get("name").(string)) + } + + if d.HasChange("permission") { + parameters.Properties.Permissions = expandSqlRoleDefinitionPermissions(d.Get("permissions").(*pluginsdk.Set).List()) + } + + if err := client.SqlResourcesCreateUpdateSqlRoleDefinitionThenPoll(ctx, *id, parameters); err != nil { + return fmt.Errorf("updating %s: %+v", id, err) + } return resourceCosmosDbSQLRoleDefinitionRead(d, meta) } func resourceCosmosDbSQLRoleDefinitionDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.SqlResourceClient + client := meta.(*clients.Client).Cosmos.RbacsClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SqlRoleDefinitionID(d.Id()) + id, err := rbacs.ParseSqlRoleDefinitionID(d.Id()) if err != nil { return err } @@ -249,25 +255,20 @@ func resourceCosmosDbSQLRoleDefinitionDelete(d *pluginsdk.ResourceData, meta int locks.ByName(id.DatabaseAccountName, CosmosDbAccountResourceName) defer locks.UnlockByName(id.DatabaseAccountName, CosmosDbAccountResourceName) - future, err := client.DeleteSQLRoleDefinition(ctx, id.Name, id.ResourceGroup, id.DatabaseAccountName) - if err != nil { + if err := client.SqlResourcesDeleteSqlRoleDefinitionThenPoll(ctx, *id); err != nil { return fmt.Errorf("deleting %s: %+v", *id, err) } - if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for deletion of %s: %+v", *id, err) - } - return nil } -func expandSqlRoleDefinitionPermissions(input []interface{}) *[]documentdb.Permission { - results := make([]documentdb.Permission, 0) +func expandSqlRoleDefinitionPermissions(input []interface{}) *[]rbacs.Permission { + results := make([]rbacs.Permission, 0) for _, item := range input { v := item.(map[string]interface{}) - results = append(results, documentdb.Permission{ + results = append(results, rbacs.Permission{ DataActions: utils.ExpandStringSlice(v["data_actions"].(*pluginsdk.Set).List()), }) } @@ -275,7 +276,7 @@ func expandSqlRoleDefinitionPermissions(input []interface{}) *[]documentdb.Permi return &results } -func flattenSqlRoleDefinitionPermissions(input *[]documentdb.Permission) []interface{} { +func flattenSqlRoleDefinitionPermissions(input *[]rbacs.Permission) []interface{} { results := make([]interface{}, 0) if input == nil { return results diff --git a/internal/services/cosmos/cosmosdb_sql_role_definition_resource_test.go b/internal/services/cosmos/cosmosdb_sql_role_definition_resource_test.go index b99f8e935901..b2013da77947 100644 --- a/internal/services/cosmos/cosmosdb_sql_role_definition_resource_test.go +++ b/internal/services/cosmos/cosmosdb_sql_role_definition_resource_test.go @@ -10,12 +10,11 @@ import ( "github.com/google/uuid" "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) type CosmosDbSQLRoleDefinitionResource struct{} @@ -112,19 +111,16 @@ func TestAccCosmosDbSQLRoleDefinition_multiple(t *testing.T) { } func (r CosmosDbSQLRoleDefinitionResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.SqlRoleDefinitionID(state.ID) + id, err := rbacs.ParseSqlRoleDefinitionID(state.ID) if err != nil { return nil, err } - resp, err := client.Cosmos.SqlResourceClient.GetSQLRoleDefinition(ctx, id.Name, id.ResourceGroup, id.DatabaseAccountName) + resp, err := client.Cosmos.RbacsClient.SqlResourcesGetSqlRoleDefinition(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return pointer.To(false), nil - } - return nil, fmt.Errorf("retrieving %q: %+v", id, err) + return nil, fmt.Errorf("retrieving %s: %+v", id, err) } - return pointer.To(true), nil + return pointer.To(resp.Model != nil), nil } func (r CosmosDbSQLRoleDefinitionResource) template(data acceptance.TestData) string { From bb3a12963a5c955f67fbf00089c57c9b1e712a66 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:38:08 -0600 Subject: [PATCH 17/25] `azurerm_cosmosdb_sql_stored_procedure` - migrate to `go-azure-sdk` --- .../cosmosdb_sql_stored_procedure_resource.go | 114 +++++++----------- ...osdb_sql_stored_procedure_resource_test.go | 13 +- 2 files changed, 49 insertions(+), 78 deletions(-) diff --git a/internal/services/cosmos/cosmosdb_sql_stored_procedure_resource.go b/internal/services/cosmos/cosmosdb_sql_stored_procedure_resource.go index 5f3578f300de..ee50c1005dbd 100644 --- a/internal/services/cosmos/cosmosdb_sql_stored_procedure_resource.go +++ b/internal/services/cosmos/cosmosdb_sql_stored_procedure_resource.go @@ -5,21 +5,18 @@ package cosmos import ( "fmt" - "log" "time" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb" // nolint: staticcheck "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceCosmosDbSQLStoredProcedure() *pluginsdk.Resource { @@ -30,7 +27,7 @@ func resourceCosmosDbSQLStoredProcedure() *pluginsdk.Resource { Delete: resourceCosmosDbSQLStoredProcedureDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.SqlStoredProcedureID(id) + _, err := cosmosdb.ParseStoredProcedureID(id) return err }), @@ -82,144 +79,119 @@ func resourceCosmosDbSQLStoredProcedure() *pluginsdk.Resource { } func resourceCosmosDbSQLStoredProcedureCreate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.SqlClient - subscriptionId := meta.(*clients.Client).Account.SubscriptionId + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - storedProcBody := d.Get("body").(string) - id := parse.NewSqlStoredProcedureID(subscriptionId, d.Get("resource_group_name").(string), d.Get("account_name").(string), d.Get("database_name").(string), d.Get("container_name").(string), d.Get("name").(string)) + id := cosmosdb.NewStoredProcedureID(meta.(*clients.Client).Account.SubscriptionId, d.Get("resource_group_name").(string), d.Get("account_name").(string), d.Get("database_name").(string), d.Get("container_name").(string), d.Get("name").(string)) - existing, err := client.GetSQLStoredProcedure(ctx, id.ResourceGroup, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName, id.StoredProcedureName) - if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { + existing, err := client.SqlResourcesGetSqlStoredProcedure(ctx, id) + if !response.WasNotFound(existing.HttpResponse) { + if err != nil { return fmt.Errorf("checking for presence of %s: %+v", id, err) } - } else { - if existing.ID == nil && *existing.ID == "" { - return fmt.Errorf("generating import ID for %s", id) - } - - return tf.ImportAsExistsError("azurerm_cosmosdb_sql_stored_procedure", *existing.ID) + return tf.ImportAsExistsError("azurerm_cosmosdb_sql_stored_procedure", id.ID()) } - storedProcParams := documentdb.SQLStoredProcedureCreateUpdateParameters{ - SQLStoredProcedureCreateUpdateProperties: &documentdb.SQLStoredProcedureCreateUpdateProperties{ - Resource: &documentdb.SQLStoredProcedureResource{ - ID: &id.StoredProcedureName, - Body: &storedProcBody, + storedProcParams := cosmosdb.SqlStoredProcedureCreateUpdateParameters{ + Properties: cosmosdb.SqlStoredProcedureCreateUpdateProperties{ + Resource: cosmosdb.SqlStoredProcedureResource{ + Id: id.StoredProcedureName, + Body: pointer.To(d.Get("body").(string)), }, - Options: &documentdb.CreateUpdateOptions{}, + Options: &cosmosdb.CreateUpdateOptions{}, }, } - future, err := client.CreateUpdateSQLStoredProcedure(ctx, id.ResourceGroup, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName, id.StoredProcedureName, storedProcParams) - if err != nil { + if err := client.SqlResourcesCreateUpdateSqlStoredProcedureThenPoll(ctx, id, storedProcParams); err != nil { return fmt.Errorf("creating %s: %+v", id, err) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for creation of %s: %+v", id, err) - } - d.SetId(id.ID()) return resourceCosmosDbSQLStoredProcedureRead(d, meta) } func resourceCosmosDbSQLStoredProcedureUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.SqlClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SqlStoredProcedureID(d.Id()) + id, err := cosmosdb.ParseStoredProcedureID(d.Id()) if err != nil { return err } - containerName := id.ContainerName - databaseName := id.SqlDatabaseName - accountName := id.DatabaseAccountName - name := id.StoredProcedureName + if _, err := client.SqlResourcesGetSqlStoredProcedure(ctx, *id); err != nil { + return fmt.Errorf("retrieving %s: %w", id, err) + } - storedProcParams := documentdb.SQLStoredProcedureCreateUpdateParameters{ - SQLStoredProcedureCreateUpdateProperties: &documentdb.SQLStoredProcedureCreateUpdateProperties{ - Resource: &documentdb.SQLStoredProcedureResource{ - ID: pointer.To(name), + storedProcParams := cosmosdb.SqlStoredProcedureCreateUpdateParameters{ + Properties: cosmosdb.SqlStoredProcedureCreateUpdateProperties{ + Resource: cosmosdb.SqlStoredProcedureResource{ + Id: id.StoredProcedureName, Body: pointer.To(d.Get("body").(string)), }, - Options: &documentdb.CreateUpdateOptions{}, + Options: &cosmosdb.CreateUpdateOptions{}, }, } - future, err := client.CreateUpdateSQLStoredProcedure(ctx, id.ResourceGroup, accountName, databaseName, containerName, name, storedProcParams) - if err != nil { - return fmt.Errorf("updating SQL Stored Procedure %q (Container %q / Database %q / Account %q): %+v", name, containerName, databaseName, accountName, err) - } - - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for update of SQL Stored Procedure %q (Container %q / Database %q / Account %q): %+v", name, containerName, databaseName, accountName, err) + if err := client.SqlResourcesCreateUpdateSqlStoredProcedureThenPoll(ctx, *id, storedProcParams); err != nil { + return fmt.Errorf("updating %s: %+v", id, err) } return resourceCosmosDbSQLStoredProcedureRead(d, meta) } func resourceCosmosDbSQLStoredProcedureRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.SqlClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SqlStoredProcedureID(d.Id()) + id, err := cosmosdb.ParseStoredProcedureID(d.Id()) if err != nil { return err } - resp, err := client.GetSQLStoredProcedure(ctx, id.ResourceGroup, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName, id.StoredProcedureName) + resp, err := client.SqlResourcesGetSqlStoredProcedure(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[INFO] SQL Stored Procedure %q (Container %q / Database %q / Account %q) was not found - removing from state", id.StoredProcedureName, id.ContainerName, id.SqlDatabaseName, id.DatabaseAccountName) + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("retrieving SQL Stored Procedure %q (Container %q / Database %q / Account %q): %+v", id.StoredProcedureName, id.ContainerName, id.SqlDatabaseName, id.DatabaseAccountName, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } - d.Set("resource_group_name", id.ResourceGroup) + d.Set("resource_group_name", id.ResourceGroupName) d.Set("account_name", id.DatabaseAccountName) d.Set("database_name", id.SqlDatabaseName) d.Set("container_name", id.ContainerName) d.Set("name", id.StoredProcedureName) - if props := resp.SQLStoredProcedureGetProperties; props != nil { - if props.Resource != nil { - d.Set("body", props.Resource.Body) - } + if resp.Model != nil && resp.Model.Properties != nil && resp.Model.Properties.Resource != nil { + d.Set("body", resp.Model.Properties.Resource.Body) } return nil } func resourceCosmosDbSQLStoredProcedureDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.SqlClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SqlStoredProcedureID(d.Id()) + id, err := cosmosdb.ParseStoredProcedureID(d.Id()) if err != nil { return err } - future, err := client.DeleteSQLStoredProcedure(ctx, id.ResourceGroup, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName, id.StoredProcedureName) - if err != nil { - if !response.WasNotFound(future.Response()) { - return fmt.Errorf("deleting SQL Stored Procedure %q (Container %q / Database %q / Account %q): %+v", id.StoredProcedureName, id.ContainerName, id.SqlDatabaseName, id.DatabaseAccountName, err) - } - } - - err = future.WaitForCompletionRef(ctx, client.Client) - if err != nil { - return fmt.Errorf("waiting for deletion of SQL Stored Procedure %q (Container %q / Database %q / Account %q): %+v", id.StoredProcedureName, id.ContainerName, id.SqlDatabaseName, id.DatabaseAccountName, err) + if err := client.SqlResourcesDeleteSqlStoredProcedureThenPoll(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", id, err) } return nil diff --git a/internal/services/cosmos/cosmosdb_sql_stored_procedure_resource_test.go b/internal/services/cosmos/cosmosdb_sql_stored_procedure_resource_test.go index 7cd1c7a9517b..4c1f36262c3e 100644 --- a/internal/services/cosmos/cosmosdb_sql_stored_procedure_resource_test.go +++ b/internal/services/cosmos/cosmosdb_sql_stored_procedure_resource_test.go @@ -8,12 +8,11 @@ import ( "fmt" "testing" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb" // nolint: staticcheck "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) @@ -57,17 +56,17 @@ func TestAccCosmosDbSqlStoredProcedure_update(t *testing.T) { } func (t CosmosSqlStoredProcedureResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.SqlStoredProcedureID(state.ID) + id, err := cosmosdb.ParseStoredProcedureID(state.ID) if err != nil { return nil, err } - resp, err := clients.Cosmos.SqlClient.GetSQLStoredProcedure(ctx, id.ResourceGroup, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName, id.StoredProcedureName) + resp, err := clients.Cosmos.CosmosDBClient.SqlResourcesGetSqlStoredProcedure(ctx, *id) if err != nil { - return nil, fmt.Errorf("reading Cosmos SQL Stored Procedure (%s): %+v", id.String(), err) + return nil, fmt.Errorf("retrieving %s: %+v", id, err) } - return pointer.To(resp.ID != nil), nil + return pointer.To(resp.Model != nil), nil } func (CosmosSqlStoredProcedureResource) base(data acceptance.TestData) string { @@ -111,7 +110,7 @@ resource "azurerm_cosmosdb_sql_container" "test" { database_name = azurerm_cosmosdb_sql_database.test.name partition_key_paths = ["/definition/id"] } -`, data.Locations.Primary, data.RandomInteger, string(documentdb.DatabaseAccountKindGlobalDocumentDB), string(documentdb.DefaultConsistencyLevelSession)) +`, data.Locations.Primary, data.RandomInteger, string(cosmosdb.DatabaseAccountKindGlobalDocumentDB), string(cosmosdb.DefaultConsistencyLevelSession)) } func (r CosmosSqlStoredProcedureResource) basic(data acceptance.TestData) string { From 299e0b0eb2a5f601fa8d9d097c82364473c4d18a Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:38:41 -0600 Subject: [PATCH 18/25] `azurerm_cosmosdb_sql_trigger` - migrate to `go-azure-sdk` --- .../cosmos/cosmosdb_sql_trigger_resource.go | 117 ++++++++---------- .../cosmosdb_sql_trigger_resource_test.go | 18 ++- 2 files changed, 62 insertions(+), 73 deletions(-) diff --git a/internal/services/cosmos/cosmosdb_sql_trigger_resource.go b/internal/services/cosmos/cosmosdb_sql_trigger_resource.go index d06e8d7fab48..fb18ccbe195e 100644 --- a/internal/services/cosmos/cosmosdb_sql_trigger_resource.go +++ b/internal/services/cosmos/cosmosdb_sql_trigger_resource.go @@ -5,18 +5,17 @@ package cosmos import ( "fmt" - "log" "time" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceCosmosDbSQLTrigger() *pluginsdk.Resource { @@ -34,7 +33,7 @@ func resourceCosmosDbSQLTrigger() *pluginsdk.Resource { }, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.SqlTriggerID(id) + _, err := cosmosdb.ParseTriggerID(id) return err }), @@ -50,7 +49,7 @@ func resourceCosmosDbSQLTrigger() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.SqlContainerID, + ValidateFunc: cosmosdb.ValidateContainerID, }, "body": { @@ -63,11 +62,11 @@ func resourceCosmosDbSQLTrigger() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(documentdb.TriggerOperationAll), - string(documentdb.TriggerOperationCreate), - string(documentdb.TriggerOperationUpdate), - string(documentdb.TriggerOperationDelete), - string(documentdb.TriggerOperationReplace), + string(cosmosdb.TriggerOperationAll), + string(cosmosdb.TriggerOperationCreate), + string(cosmosdb.TriggerOperationUpdate), + string(cosmosdb.TriggerOperationDelete), + string(cosmosdb.TriggerOperationReplace), }, false), }, @@ -75,8 +74,8 @@ func resourceCosmosDbSQLTrigger() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(documentdb.TriggerTypePre), - string(documentdb.TriggerTypePost), + string(cosmosdb.TriggerTypePre), + string(cosmosdb.TriggerTypePost), }, false), }, }, @@ -84,49 +83,42 @@ func resourceCosmosDbSQLTrigger() *pluginsdk.Resource { } func resourceCosmosDbSQLTriggerCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - subscriptionId := meta.(*clients.Client).Account.SubscriptionId - client := meta.(*clients.Client).Cosmos.SqlResourceClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - name := d.Get("name").(string) - containerId, _ := parse.SqlContainerID(d.Get("container_id").(string)) - body := d.Get("body").(string) - triggerOperation := d.Get("operation").(string) - triggerType := d.Get("type").(string) + containerId, err := cosmosdb.ParseContainerID(d.Get("container_id").(string)) + if err != nil { + return err + } - id := parse.NewSqlTriggerID(subscriptionId, containerId.ResourceGroup, containerId.DatabaseAccountName, containerId.SqlDatabaseName, containerId.ContainerName, name) + id := cosmosdb.NewTriggerID(meta.(*clients.Client).Account.SubscriptionId, containerId.ResourceGroupName, containerId.DatabaseAccountName, containerId.SqlDatabaseName, containerId.ContainerName, d.Get("name").(string)) if d.IsNewResource() { - existing, err := client.GetSQLTrigger(ctx, id.ResourceGroup, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName, id.TriggerName) - if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for existing CosmosDb SQLTrigger %q: %+v", id, err) + existing, err := client.SqlResourcesGetSqlTrigger(ctx, id) + if !response.WasNotFound(existing.HttpResponse) { + if err != nil { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } - } - if !utils.ResponseWasNotFound(existing.Response) { return tf.ImportAsExistsError("azurerm_cosmosdb_sql_trigger", id.ID()) } } - createUpdateSqlTriggerParameters := documentdb.SQLTriggerCreateUpdateParameters{ - SQLTriggerCreateUpdateProperties: &documentdb.SQLTriggerCreateUpdateProperties{ - Resource: &documentdb.SQLTriggerResource{ - ID: &name, - Body: &body, - TriggerType: documentdb.TriggerType(triggerType), - TriggerOperation: documentdb.TriggerOperation(triggerOperation), + createUpdateSqlTriggerParameters := cosmosdb.SqlTriggerCreateUpdateParameters{ + Properties: cosmosdb.SqlTriggerCreateUpdateProperties{ + Resource: cosmosdb.SqlTriggerResource{ + Id: id.SqlDatabaseName, + Body: pointer.To(d.Get("body").(string)), + TriggerType: pointer.ToEnum[cosmosdb.TriggerType](d.Get("type").(string)), + TriggerOperation: pointer.ToEnum[cosmosdb.TriggerOperation](d.Get("operation").(string)), }, - Options: &documentdb.CreateUpdateOptions{}, + Options: &cosmosdb.CreateUpdateOptions{}, }, } - future, err := client.CreateUpdateSQLTrigger(ctx, id.ResourceGroup, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName, name, createUpdateSqlTriggerParameters) - if err != nil { - return fmt.Errorf("creating/updating CosmosDb SQLTrigger %q: %+v", id, err) - } - if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for creation/update of the CosmosDb SQLTrigger %q: %+v", id, err) + if err := client.SqlResourcesCreateUpdateSqlTriggerThenPoll(ctx, id, createUpdateSqlTriggerParameters); err != nil { + return fmt.Errorf("creating/updating %s: %+v", id, err) } d.SetId(id.ID()) @@ -134,54 +126,55 @@ func resourceCosmosDbSQLTriggerCreateUpdate(d *pluginsdk.ResourceData, meta inte } func resourceCosmosDbSQLTriggerRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.SqlResourceClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SqlTriggerID(d.Id()) + id, err := cosmosdb.ParseTriggerID(d.Id()) if err != nil { return err } - resp, err := client.GetSQLTrigger(ctx, id.ResourceGroup, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName, id.TriggerName) + resp, err := client.SqlResourcesGetSqlTrigger(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[INFO] CosmosDb SQLTrigger %q does not exist - removing from state", d.Id()) + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("retrieving CosmosDb SQLTrigger %q: %+v", id, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } - containerId := parse.NewSqlContainerID(id.SubscriptionId, id.ResourceGroup, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName) + d.Set("name", id.TriggerName) - d.Set("container_id", containerId.ID()) - if props := resp.SQLTriggerGetProperties; props != nil { - if props.Resource != nil { - d.Set("body", props.Resource.Body) - d.Set("operation", props.Resource.TriggerOperation) - d.Set("type", props.Resource.TriggerType) + d.Set("container_id", cosmosdb.NewContainerID(id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName).ID()) + + if resp.Model != nil { + if props := resp.Model.Properties; props != nil { + if r := props.Resource; r != nil { + d.Set("body", r.Body) + d.Set("operation", r.TriggerOperation) + d.Set("type", r.TriggerType) + } } } + return nil } func resourceCosmosDbSQLTriggerDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.SqlResourceClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SqlTriggerID(d.Id()) + id, err := cosmosdb.ParseTriggerID(d.Id()) if err != nil { return err } - future, err := client.DeleteSQLTrigger(ctx, id.ResourceGroup, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName, id.TriggerName) - if err != nil { - return fmt.Errorf("deleting CosmosDb SQLResourcesSQLTrigger %q: %+v", id, err) + if err := client.SqlResourcesDeleteSqlTriggerThenPoll(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", id, err) } - if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for deletion of the CosmosDb SQLResourcesSQLTrigger %q: %+v", id, err) - } return nil } diff --git a/internal/services/cosmos/cosmosdb_sql_trigger_resource_test.go b/internal/services/cosmos/cosmosdb_sql_trigger_resource_test.go index 3b1f23d14496..c5e9a700b59a 100644 --- a/internal/services/cosmos/cosmosdb_sql_trigger_resource_test.go +++ b/internal/services/cosmos/cosmosdb_sql_trigger_resource_test.go @@ -8,14 +8,12 @@ import ( "fmt" "testing" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb" // nolint: staticcheck "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) type CosmosDbSQLTriggerResource struct{} @@ -77,18 +75,16 @@ func TestAccCosmosDbSQLTrigger_update(t *testing.T) { } func (r CosmosDbSQLTriggerResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.SqlTriggerID(state.ID) + id, err := cosmosdb.ParseTriggerID(state.ID) if err != nil { return nil, err } - resp, err := client.Cosmos.SqlResourceClient.GetSQLTrigger(ctx, id.ResourceGroup, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName, id.TriggerName) + + resp, err := client.Cosmos.CosmosDBClient.SqlResourcesGetSqlTrigger(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return pointer.To(false), nil - } - return nil, fmt.Errorf("retrieving CosmosDb SQLTrigger %q: %+v", id, err) + return nil, fmt.Errorf("retrieving %s: %+v", id, err) } - return pointer.To(true), nil + return pointer.To(resp.Model != nil), nil } func (r CosmosDbSQLTriggerResource) template(data acceptance.TestData) string { @@ -132,7 +128,7 @@ resource "azurerm_cosmosdb_sql_container" "test" { database_name = azurerm_cosmosdb_sql_database.test.name partition_key_paths = ["/definition/id"] } - `, data.Locations.Primary, data.RandomInteger, string(documentdb.DatabaseAccountKindGlobalDocumentDB), string(documentdb.DefaultConsistencyLevelSession)) + `, data.Locations.Primary, data.RandomInteger, string(cosmosdb.DatabaseAccountKindGlobalDocumentDB), string(cosmosdb.DefaultConsistencyLevelSession)) } func (r CosmosDbSQLTriggerResource) basic(data acceptance.TestData) string { From ba1fcea637b5f978a0018d36a6646458192a9e3d Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:39:17 -0600 Subject: [PATCH 19/25] `azurerm_cosmosdb_table` - migrate to `go-azure-sdk` --- .../cosmos/cosmosdb_table_resource.go | 154 ++++++------------ .../cosmos/cosmosdb_table_resource_test.go | 9 +- 2 files changed, 53 insertions(+), 110 deletions(-) diff --git a/internal/services/cosmos/cosmosdb_table_resource.go b/internal/services/cosmos/cosmosdb_table_resource.go index 85f6a5e3a057..b3866fc24bfe 100644 --- a/internal/services/cosmos/cosmosdb_table_resource.go +++ b/internal/services/cosmos/cosmosdb_table_resource.go @@ -5,21 +5,19 @@ package cosmos import ( "fmt" - "log" "time" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/common" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/migration" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceCosmosDbTable() *pluginsdk.Resource { @@ -30,7 +28,7 @@ func resourceCosmosDbTable() *pluginsdk.Resource { Delete: resourceCosmosDbTableDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.TableID(id) + _, err := cosmosdb.ParseTableID(id) return err }), @@ -76,52 +74,40 @@ func resourceCosmosDbTable() *pluginsdk.Resource { } func resourceCosmosDbTableCreate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.TableClient - subscriptionId := meta.(*clients.Client).Account.SubscriptionId + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - id := parse.NewTableID(subscriptionId, d.Get("resource_group_name").(string), d.Get("account_name").(string), d.Get("name").(string)) + id := cosmosdb.NewTableID(meta.(*clients.Client).Account.SubscriptionId, d.Get("resource_group_name").(string), d.Get("account_name").(string), d.Get("name").(string)) - existing, err := client.GetTable(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name) - if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { + existing, err := client.TableResourcesGetTable(ctx, id) + if !response.WasNotFound(existing.HttpResponse) { + if err != nil { return fmt.Errorf("checking for presence of %s: %+v", id, err) } - } else { - if existing.ID == nil && *existing.ID == "" { - return fmt.Errorf("generating import ID for %s", id) - } - - return tf.ImportAsExistsError("azurerm_cosmosdb_mongo_database", *existing.ID) + return tf.ImportAsExistsError("azurerm_cosmosdb_mongo_database", id.ID()) } - db := documentdb.TableCreateUpdateParameters{ - TableCreateUpdateProperties: &documentdb.TableCreateUpdateProperties{ - Resource: &documentdb.TableResource{ - ID: &id.Name, + db := cosmosdb.TableCreateUpdateParameters{ + Properties: cosmosdb.TableCreateUpdateProperties{ + Resource: cosmosdb.TableResource{ + Id: id.TableName, }, - Options: &documentdb.CreateUpdateOptions{}, + Options: &cosmosdb.CreateUpdateOptions{}, }, } - if throughput, hasThroughput := d.GetOk("throughput"); hasThroughput { - if throughput != 0 { - db.Options.Throughput = common.ConvertThroughputFromResourceDataLegacy(throughput) - } - } - - if _, hasAutoscaleSettings := d.GetOk("autoscale_settings"); hasAutoscaleSettings { - db.Options.AutoscaleSettings = common.ExpandCosmosDbAutoscaleSettingsLegacy(d) + if throughput, ok := d.GetOk("throughput"); ok && throughput != 0 { + db.Properties.Options.Throughput = common.ConvertThroughputFromResourceData(throughput) } - future, err := client.CreateUpdateTable(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name, db) - if err != nil { - return fmt.Errorf("issuing create/update request for %s: %+v", id, err) + if _, ok := d.GetOk("autoscale_settings"); ok { + db.Properties.Options.AutoScaleSettings = common.ExpandCosmosDbAutoscaleSettings(d) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting on create/update future for %s: %+v", id, err) + if err := client.TableResourcesCreateUpdateTableThenPoll(ctx, id, db); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) } d.SetId(id.ID()) @@ -130,50 +116,23 @@ func resourceCosmosDbTableCreate(d *pluginsdk.ResourceData, meta interface{}) er } func resourceCosmosDbTableUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.TableClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.TableID(d.Id()) + id, err := cosmosdb.ParseTableID(d.Id()) if err != nil { return err } - err = common.CheckForChangeFromAutoscaleAndManualThroughput(d) - if err != nil { - return fmt.Errorf("updating Cosmos Table %q (Account: %q) - %+v", id.Name, id.DatabaseAccountName, err) - } - - db := documentdb.TableCreateUpdateParameters{ - TableCreateUpdateProperties: &documentdb.TableCreateUpdateProperties{ - Resource: &documentdb.TableResource{ - ID: &id.Name, - }, - Options: &documentdb.CreateUpdateOptions{}, - }, - } - - future, err := client.CreateUpdateTable(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name, db) - if err != nil { - return fmt.Errorf("issuing create/update request for Cosmos Table %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) - } - - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting on create/update future for Cosmos Table %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) + if err := common.CheckForChangeFromAutoscaleAndManualThroughput(d); err != nil { + return fmt.Errorf("checking `autoscale_settings` and `throughput` for %s: %w", id, err) } if common.HasThroughputChange(d) { - throughputParameters := common.ExpandCosmosDBThroughputSettingsUpdateParametersLegacy(d) - throughputFuture, err := client.UpdateTableThroughput(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name, *throughputParameters) - if err != nil { - if response.WasNotFound(throughputFuture.Response()) { - return fmt.Errorf("setting Throughput for Cosmos Table %q (Account: %q): %+v - "+ - "If the collection has not been created with an initial throughput, you cannot configure it later", id.Name, id.DatabaseAccountName, err) - } - } - - if err = throughputFuture.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting on ThroughputUpdate future for Cosmos Table %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) + if err := client.TableResourcesUpdateTableThroughputThenPoll(ctx, *id, common.ExpandCosmosDBThroughputSettingsUpdateParameters(d)); err != nil { + return fmt.Errorf("setting Throughput for %s: %+v - If the collection has not been created with an initial throughput, you cannot configure it later", id, err) } } @@ -181,56 +140,48 @@ func resourceCosmosDbTableUpdate(d *pluginsdk.ResourceData, meta interface{}) er } func resourceCosmosDbTableRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.TableClient - accountClient := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.TableID(d.Id()) + id, err := cosmosdb.ParseTableID(d.Id()) if err != nil { return err } - resp, err := client.GetTable(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name) + resp, err := client.TableResourcesGetTable(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[INFO] Error reading Cosmos Table %q (Account: %q) - removing from state", id.Name, id.DatabaseAccountName) + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("reading Cosmos Table %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } - d.Set("resource_group_name", id.ResourceGroup) + d.Set("resource_group_name", id.ResourceGroupName) d.Set("account_name", id.DatabaseAccountName) - if props := resp.TableGetProperties; props != nil { - if res := props.Resource; res != nil { - d.Set("name", res.ID) - } - } + d.Set("name", id.TableName) - accResp, err := accountClient.Get(ctx, id.ResourceGroup, id.DatabaseAccountName) + databaseAccountID := cosmosdb.NewDatabaseAccountID(id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName) + accResp, err := client.DatabaseAccountsGet(ctx, databaseAccountID) if err != nil { - return fmt.Errorf("reading CosmosDB Account %q (Resource Group %q): %+v", id.DatabaseAccountName, id.ResourceGroup, err) - } - - if accResp.ID == nil || *accResp.ID == "" { - return fmt.Errorf("cosmosDB Account %q (Resource Group %q) ID is empty or nil", id.DatabaseAccountName, id.ResourceGroup) + return fmt.Errorf("retrieving %s: %+v", databaseAccountID, err) } // if the cosmos account is serverless calling the get throughput api would yield an error - if !isServerlessCapacityMode(accResp) { - throughputResp, err := client.GetTableThroughput(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name) + if !isServerlessCapacityMode(accResp.Model) { + throughputResp, err := client.TableResourcesGetTableThroughput(ctx, *id) if err != nil { - if !utils.ResponseWasNotFound(throughputResp.Response) { - return fmt.Errorf("reading Throughput on Cosmos Table %q (Account: %q) ID: %v", id.Name, id.DatabaseAccountName, err) + if !response.WasNotFound(throughputResp.HttpResponse) { + return fmt.Errorf("retrieving %s: %v", id, err) } else { d.Set("throughput", nil) d.Set("autoscale_settings", nil) } } else { - common.SetResourceDataThroughputFromResponseLegacy(throughputResp, d) + common.SetResourceDataThroughputFromResponse(pointer.From(throughputResp.Model), d) } } @@ -238,25 +189,18 @@ func resourceCosmosDbTableRead(d *pluginsdk.ResourceData, meta interface{}) erro } func resourceCosmosDbTableDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.TableClient + client := meta.(*clients.Client).Cosmos.CosmosDBClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.TableID(d.Id()) + id, err := cosmosdb.ParseTableID(d.Id()) if err != nil { return err } - future, err := client.DeleteTable(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name) - if err != nil { - if !response.WasNotFound(future.Response()) { - return fmt.Errorf("deleting Cosmos Table %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) - } - } - - err = future.WaitForCompletionRef(ctx, client.Client) - if err != nil { - return fmt.Errorf("waiting on delete future for Cosmos Table %q (Account: %q): %+v", id.Name, id.DatabaseAccountName, err) + if err := client.TableResourcesDeleteTableThenPoll(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", id, err) } return nil diff --git a/internal/services/cosmos/cosmosdb_table_resource_test.go b/internal/services/cosmos/cosmosdb_table_resource_test.go index 10533be4a0b6..f538806514d1 100644 --- a/internal/services/cosmos/cosmosdb_table_resource_test.go +++ b/internal/services/cosmos/cosmosdb_table_resource_test.go @@ -13,7 +13,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) @@ -106,17 +105,17 @@ func TestAccCosmosDbTable_serverless(t *testing.T) { } func (t CosmosTableResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.TableID(state.ID) + id, err := cosmosdb.ParseTableID(state.ID) if err != nil { return nil, err } - resp, err := clients.Cosmos.TableClient.GetTable(ctx, id.ResourceGroup, id.DatabaseAccountName, id.Name) + resp, err := clients.Cosmos.CosmosDBClient.TableResourcesGetTable(ctx, *id) if err != nil { - return nil, fmt.Errorf("reading Cosmos Table (%s): %+v", id.String(), err) + return nil, fmt.Errorf("retrieving %s: %+v", id, err) } - return pointer.To(resp.ID != nil), nil + return pointer.To(resp.Model != nil), nil } func (CosmosTableResource) basic(data acceptance.TestData) string { From 3a4f0627bda763574e0a90aebf92385497e9d77a Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:40:33 -0600 Subject: [PATCH 20/25] `cosmos` - clean up local resource ids --- .../cosmos/parse/cassandra_keyspace.go | 79 --------- .../cosmos/parse/cassandra_keyspace_test.go | 130 -------------- .../services/cosmos/parse/cassandra_table.go | 85 --------- .../cosmos/parse/cassandra_table_test.go | 146 ---------------- .../services/cosmos/parse/database_account.go | 73 -------- .../cosmos/parse/database_account_test.go | 114 ------------ .../services/cosmos/parse/gremlin_database.go | 79 --------- .../cosmos/parse/gremlin_database_test.go | 130 -------------- .../services/cosmos/parse/gremlin_graph.go | 85 --------- .../cosmos/parse/gremlin_graph_test.go | 146 ---------------- .../cosmos/parse/mongodb_collection.go | 85 --------- .../cosmos/parse/mongodb_collection_test.go | 146 ---------------- .../services/cosmos/parse/mongodb_database.go | 79 --------- .../cosmos/parse/mongodb_database_test.go | 130 -------------- .../cosmos/parse/notebook_workspace.go | 79 --------- .../cosmos/parse/notebook_workspace_test.go | 130 -------------- .../parse/restorable_database_account.go | 71 -------- .../parse/restorable_database_account_test.go | 114 ------------ .../services/cosmos/parse/sql_container.go | 85 --------- .../cosmos/parse/sql_container_test.go | 146 ---------------- .../services/cosmos/parse/sql_database.go | 79 --------- .../cosmos/parse/sql_database_test.go | 130 -------------- .../services/cosmos/parse/sql_function.go | 91 ---------- .../cosmos/parse/sql_function_test.go | 162 ------------------ .../cosmos/parse/sql_role_assignment.go | 79 --------- .../cosmos/parse/sql_role_assignment_test.go | 130 -------------- .../cosmos/parse/sql_role_definition.go | 79 --------- .../cosmos/parse/sql_role_definition_test.go | 130 -------------- .../cosmos/parse/sql_stored_procedure.go | 91 ---------- .../cosmos/parse/sql_stored_procedure_test.go | 162 ------------------ internal/services/cosmos/parse/sql_trigger.go | 91 ---------- .../services/cosmos/parse/sql_trigger_test.go | 162 ------------------ internal/services/cosmos/parse/table.go | 79 --------- internal/services/cosmos/parse/table_test.go | 130 -------------- internal/services/cosmos/resourceids.go | 22 --- .../cosmos/validate/cassandra_keyspace_id.go | 26 --- .../validate/cassandra_keyspace_id_test.go | 90 ---------- .../cosmos/validate/cassandra_table_id.go | 26 --- .../validate/cassandra_table_id_test.go | 102 ----------- .../cosmos/validate/database_account_id.go | 26 --- .../validate/database_account_id_test.go | 78 --------- .../cosmos/validate/gremlin_database_id.go | 26 --- .../validate/gremlin_database_id_test.go | 90 ---------- .../cosmos/validate/gremlin_graph_id.go | 26 --- .../cosmos/validate/gremlin_graph_id_test.go | 102 ----------- .../cosmos/validate/mongodb_collection_id.go | 26 --- .../validate/mongodb_collection_id_test.go | 102 ----------- .../cosmos/validate/mongodb_database_id.go | 26 --- .../validate/mongodb_database_id_test.go | 90 ---------- .../cosmos/validate/notebook_workspace_id.go | 26 --- .../validate/notebook_workspace_id_test.go | 90 ---------- .../restorable_database_account_id.go | 26 --- .../restorable_database_account_id_test.go | 78 --------- .../cosmos/validate/sql_container_id.go | 26 --- .../cosmos/validate/sql_container_id_test.go | 102 ----------- .../cosmos/validate/sql_database_id.go | 26 --- .../cosmos/validate/sql_database_id_test.go | 90 ---------- .../cosmos/validate/sql_function_id.go | 26 --- .../cosmos/validate/sql_function_id_test.go | 114 ------------ .../cosmos/validate/sql_role_assignment_id.go | 26 --- .../validate/sql_role_assignment_id_test.go | 90 ---------- .../cosmos/validate/sql_role_definition_id.go | 26 --- .../validate/sql_role_definition_id_test.go | 90 ---------- .../validate/sql_stored_procedure_id.go | 26 --- .../validate/sql_stored_procedure_id_test.go | 114 ------------ .../cosmos/validate/sql_trigger_id.go | 26 --- .../cosmos/validate/sql_trigger_id_test.go | 114 ------------ internal/services/cosmos/validate/table_id.go | 26 --- .../services/cosmos/validate/table_id_test.go | 90 ---------- .../network/private_endpoint_resource.go | 6 +- ...cloud_app_cosmosdb_association_resource.go | 3 +- ...ream_analytics_output_cosmosdb_resource.go | 15 +- 72 files changed, 12 insertions(+), 5829 deletions(-) delete mode 100644 internal/services/cosmos/parse/cassandra_keyspace.go delete mode 100644 internal/services/cosmos/parse/cassandra_keyspace_test.go delete mode 100644 internal/services/cosmos/parse/cassandra_table.go delete mode 100644 internal/services/cosmos/parse/cassandra_table_test.go delete mode 100644 internal/services/cosmos/parse/database_account.go delete mode 100644 internal/services/cosmos/parse/database_account_test.go delete mode 100644 internal/services/cosmos/parse/gremlin_database.go delete mode 100644 internal/services/cosmos/parse/gremlin_database_test.go delete mode 100644 internal/services/cosmos/parse/gremlin_graph.go delete mode 100644 internal/services/cosmos/parse/gremlin_graph_test.go delete mode 100644 internal/services/cosmos/parse/mongodb_collection.go delete mode 100644 internal/services/cosmos/parse/mongodb_collection_test.go delete mode 100644 internal/services/cosmos/parse/mongodb_database.go delete mode 100644 internal/services/cosmos/parse/mongodb_database_test.go delete mode 100644 internal/services/cosmos/parse/notebook_workspace.go delete mode 100644 internal/services/cosmos/parse/notebook_workspace_test.go delete mode 100644 internal/services/cosmos/parse/restorable_database_account.go delete mode 100644 internal/services/cosmos/parse/restorable_database_account_test.go delete mode 100644 internal/services/cosmos/parse/sql_container.go delete mode 100644 internal/services/cosmos/parse/sql_container_test.go delete mode 100644 internal/services/cosmos/parse/sql_database.go delete mode 100644 internal/services/cosmos/parse/sql_database_test.go delete mode 100644 internal/services/cosmos/parse/sql_function.go delete mode 100644 internal/services/cosmos/parse/sql_function_test.go delete mode 100644 internal/services/cosmos/parse/sql_role_assignment.go delete mode 100644 internal/services/cosmos/parse/sql_role_assignment_test.go delete mode 100644 internal/services/cosmos/parse/sql_role_definition.go delete mode 100644 internal/services/cosmos/parse/sql_role_definition_test.go delete mode 100644 internal/services/cosmos/parse/sql_stored_procedure.go delete mode 100644 internal/services/cosmos/parse/sql_stored_procedure_test.go delete mode 100644 internal/services/cosmos/parse/sql_trigger.go delete mode 100644 internal/services/cosmos/parse/sql_trigger_test.go delete mode 100644 internal/services/cosmos/parse/table.go delete mode 100644 internal/services/cosmos/parse/table_test.go delete mode 100644 internal/services/cosmos/resourceids.go delete mode 100644 internal/services/cosmos/validate/cassandra_keyspace_id.go delete mode 100644 internal/services/cosmos/validate/cassandra_keyspace_id_test.go delete mode 100644 internal/services/cosmos/validate/cassandra_table_id.go delete mode 100644 internal/services/cosmos/validate/cassandra_table_id_test.go delete mode 100644 internal/services/cosmos/validate/database_account_id.go delete mode 100644 internal/services/cosmos/validate/database_account_id_test.go delete mode 100644 internal/services/cosmos/validate/gremlin_database_id.go delete mode 100644 internal/services/cosmos/validate/gremlin_database_id_test.go delete mode 100644 internal/services/cosmos/validate/gremlin_graph_id.go delete mode 100644 internal/services/cosmos/validate/gremlin_graph_id_test.go delete mode 100644 internal/services/cosmos/validate/mongodb_collection_id.go delete mode 100644 internal/services/cosmos/validate/mongodb_collection_id_test.go delete mode 100644 internal/services/cosmos/validate/mongodb_database_id.go delete mode 100644 internal/services/cosmos/validate/mongodb_database_id_test.go delete mode 100644 internal/services/cosmos/validate/notebook_workspace_id.go delete mode 100644 internal/services/cosmos/validate/notebook_workspace_id_test.go delete mode 100644 internal/services/cosmos/validate/restorable_database_account_id.go delete mode 100644 internal/services/cosmos/validate/restorable_database_account_id_test.go delete mode 100644 internal/services/cosmos/validate/sql_container_id.go delete mode 100644 internal/services/cosmos/validate/sql_container_id_test.go delete mode 100644 internal/services/cosmos/validate/sql_database_id.go delete mode 100644 internal/services/cosmos/validate/sql_database_id_test.go delete mode 100644 internal/services/cosmos/validate/sql_function_id.go delete mode 100644 internal/services/cosmos/validate/sql_function_id_test.go delete mode 100644 internal/services/cosmos/validate/sql_role_assignment_id.go delete mode 100644 internal/services/cosmos/validate/sql_role_assignment_id_test.go delete mode 100644 internal/services/cosmos/validate/sql_role_definition_id.go delete mode 100644 internal/services/cosmos/validate/sql_role_definition_id_test.go delete mode 100644 internal/services/cosmos/validate/sql_stored_procedure_id.go delete mode 100644 internal/services/cosmos/validate/sql_stored_procedure_id_test.go delete mode 100644 internal/services/cosmos/validate/sql_trigger_id.go delete mode 100644 internal/services/cosmos/validate/sql_trigger_id_test.go delete mode 100644 internal/services/cosmos/validate/table_id.go delete mode 100644 internal/services/cosmos/validate/table_id_test.go diff --git a/internal/services/cosmos/parse/cassandra_keyspace.go b/internal/services/cosmos/parse/cassandra_keyspace.go deleted file mode 100644 index 72f5f904ffac..000000000000 --- a/internal/services/cosmos/parse/cassandra_keyspace.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type CassandraKeyspaceId struct { - SubscriptionId string - ResourceGroup string - DatabaseAccountName string - Name string -} - -func NewCassandraKeyspaceID(subscriptionId, resourceGroup, databaseAccountName, name string) CassandraKeyspaceId { - return CassandraKeyspaceId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DatabaseAccountName: databaseAccountName, - Name: name, - } -} - -func (id CassandraKeyspaceId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Database Account Name %q", id.DatabaseAccountName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Cassandra Keyspace", segmentsStr) -} - -func (id CassandraKeyspaceId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/cassandraKeyspaces/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.DatabaseAccountName, id.Name) -} - -// CassandraKeyspaceID parses a CassandraKeyspace ID into an CassandraKeyspaceId struct -func CassandraKeyspaceID(input string) (*CassandraKeyspaceId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an CassandraKeyspace ID: %+v", input, err) - } - - resourceId := CassandraKeyspaceId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.DatabaseAccountName, err = id.PopSegment("databaseAccounts"); err != nil { - return nil, err - } - if resourceId.Name, err = id.PopSegment("cassandraKeyspaces"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/cosmos/parse/cassandra_keyspace_test.go b/internal/services/cosmos/parse/cassandra_keyspace_test.go deleted file mode 100644 index 3613da7bd711..000000000000 --- a/internal/services/cosmos/parse/cassandra_keyspace_test.go +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = CassandraKeyspaceId{} - -func TestCassandraKeyspaceIDFormatter(t *testing.T) { - actual := NewCassandraKeyspaceID("12345678-1234-9876-4563-123456789012", "resGroup1", "acc1", "keyspace1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/cassandraKeyspaces/keyspace1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestCassandraKeyspaceID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *CassandraKeyspaceId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Error: true, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/cassandraKeyspaces/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/cassandraKeyspaces/keyspace1", - Expected: &CassandraKeyspaceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - DatabaseAccountName: "acc1", - Name: "keyspace1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACC1/CASSANDRAKEYSPACES/KEYSPACE1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := CassandraKeyspaceID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.DatabaseAccountName != v.Expected.DatabaseAccountName { - t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/cosmos/parse/cassandra_table.go b/internal/services/cosmos/parse/cassandra_table.go deleted file mode 100644 index 8eb1665229ec..000000000000 --- a/internal/services/cosmos/parse/cassandra_table.go +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type CassandraTableId struct { - SubscriptionId string - ResourceGroup string - DatabaseAccountName string - CassandraKeyspaceName string - TableName string -} - -func NewCassandraTableID(subscriptionId, resourceGroup, databaseAccountName, cassandraKeyspaceName, tableName string) CassandraTableId { - return CassandraTableId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DatabaseAccountName: databaseAccountName, - CassandraKeyspaceName: cassandraKeyspaceName, - TableName: tableName, - } -} - -func (id CassandraTableId) String() string { - segments := []string{ - fmt.Sprintf("Table Name %q", id.TableName), - fmt.Sprintf("Cassandra Keyspace Name %q", id.CassandraKeyspaceName), - fmt.Sprintf("Database Account Name %q", id.DatabaseAccountName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Cassandra Table", segmentsStr) -} - -func (id CassandraTableId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/cassandraKeyspaces/%s/tables/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.DatabaseAccountName, id.CassandraKeyspaceName, id.TableName) -} - -// CassandraTableID parses a CassandraTable ID into an CassandraTableId struct -func CassandraTableID(input string) (*CassandraTableId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an CassandraTable ID: %+v", input, err) - } - - resourceId := CassandraTableId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.DatabaseAccountName, err = id.PopSegment("databaseAccounts"); err != nil { - return nil, err - } - if resourceId.CassandraKeyspaceName, err = id.PopSegment("cassandraKeyspaces"); err != nil { - return nil, err - } - if resourceId.TableName, err = id.PopSegment("tables"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/cosmos/parse/cassandra_table_test.go b/internal/services/cosmos/parse/cassandra_table_test.go deleted file mode 100644 index 6e9bb5246aa4..000000000000 --- a/internal/services/cosmos/parse/cassandra_table_test.go +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = CassandraTableId{} - -func TestCassandraTableIDFormatter(t *testing.T) { - actual := NewCassandraTableID("12345678-1234-9876-4563-123456789012", "resGroup1", "acc1", "keyspace1", "table1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/cassandraKeyspaces/keyspace1/tables/table1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestCassandraTableID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *CassandraTableId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Error: true, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Error: true, - }, - - { - // missing CassandraKeyspaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/", - Error: true, - }, - - { - // missing value for CassandraKeyspaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/cassandraKeyspaces/", - Error: true, - }, - - { - // missing TableName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/cassandraKeyspaces/keyspace1/", - Error: true, - }, - - { - // missing value for TableName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/cassandraKeyspaces/keyspace1/tables/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/cassandraKeyspaces/keyspace1/tables/table1", - Expected: &CassandraTableId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - DatabaseAccountName: "acc1", - CassandraKeyspaceName: "keyspace1", - TableName: "table1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACC1/CASSANDRAKEYSPACES/KEYSPACE1/TABLES/TABLE1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := CassandraTableID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - 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) - } - } -} diff --git a/internal/services/cosmos/parse/database_account.go b/internal/services/cosmos/parse/database_account.go deleted file mode 100644 index e0dc6191dc6d..000000000000 --- a/internal/services/cosmos/parse/database_account.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type DatabaseAccountId struct { - SubscriptionId string - ResourceGroup string - Name string -} - -func NewDatabaseAccountID(subscriptionId, resourceGroup, name string) DatabaseAccountId { - return DatabaseAccountId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - Name: name, - } -} - -func (id DatabaseAccountId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Database Account", segmentsStr) -} - -func (id DatabaseAccountId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) -} - -// DatabaseAccountID parses a DatabaseAccount ID into an DatabaseAccountId struct -func DatabaseAccountID(input string) (*DatabaseAccountId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an DatabaseAccount ID: %+v", input, err) - } - - resourceId := DatabaseAccountId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.Name, err = id.PopSegment("databaseAccounts"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/cosmos/parse/database_account_test.go b/internal/services/cosmos/parse/database_account_test.go deleted file mode 100644 index 2df454ac2823..000000000000 --- a/internal/services/cosmos/parse/database_account_test.go +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = DatabaseAccountId{} - -func TestDatabaseAccountIDFormatter(t *testing.T) { - actual := NewDatabaseAccountID("12345678-1234-9876-4563-123456789012", "resGroup1", "acc1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestDatabaseAccountID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *DatabaseAccountId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1", - Expected: &DatabaseAccountId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "acc1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACC1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := DatabaseAccountID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/cosmos/parse/gremlin_database.go b/internal/services/cosmos/parse/gremlin_database.go deleted file mode 100644 index 63379a27ef20..000000000000 --- a/internal/services/cosmos/parse/gremlin_database.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type GremlinDatabaseId struct { - SubscriptionId string - ResourceGroup string - DatabaseAccountName string - Name string -} - -func NewGremlinDatabaseID(subscriptionId, resourceGroup, databaseAccountName, name string) GremlinDatabaseId { - return GremlinDatabaseId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DatabaseAccountName: databaseAccountName, - Name: name, - } -} - -func (id GremlinDatabaseId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Database Account Name %q", id.DatabaseAccountName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Gremlin Database", segmentsStr) -} - -func (id GremlinDatabaseId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/gremlinDatabases/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.DatabaseAccountName, id.Name) -} - -// GremlinDatabaseID parses a GremlinDatabase ID into an GremlinDatabaseId struct -func GremlinDatabaseID(input string) (*GremlinDatabaseId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an GremlinDatabase ID: %+v", input, err) - } - - resourceId := GremlinDatabaseId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.DatabaseAccountName, err = id.PopSegment("databaseAccounts"); err != nil { - return nil, err - } - if resourceId.Name, err = id.PopSegment("gremlinDatabases"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/cosmos/parse/gremlin_database_test.go b/internal/services/cosmos/parse/gremlin_database_test.go deleted file mode 100644 index 3956cbbbb396..000000000000 --- a/internal/services/cosmos/parse/gremlin_database_test.go +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = GremlinDatabaseId{} - -func TestGremlinDatabaseIDFormatter(t *testing.T) { - actual := NewGremlinDatabaseID("12345678-1234-9876-4563-123456789012", "resGroup1", "acc1", "database1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/gremlinDatabases/database1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestGremlinDatabaseID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *GremlinDatabaseId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Error: true, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/gremlinDatabases/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/gremlinDatabases/database1", - Expected: &GremlinDatabaseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - DatabaseAccountName: "acc1", - Name: "database1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACC1/GREMLINDATABASES/DATABASE1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := GremlinDatabaseID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.DatabaseAccountName != v.Expected.DatabaseAccountName { - t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/cosmos/parse/gremlin_graph.go b/internal/services/cosmos/parse/gremlin_graph.go deleted file mode 100644 index 5e8b01f7dc3f..000000000000 --- a/internal/services/cosmos/parse/gremlin_graph.go +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type GremlinGraphId struct { - SubscriptionId string - ResourceGroup string - DatabaseAccountName string - GremlinDatabaseName string - GraphName string -} - -func NewGremlinGraphID(subscriptionId, resourceGroup, databaseAccountName, gremlinDatabaseName, graphName string) GremlinGraphId { - return GremlinGraphId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DatabaseAccountName: databaseAccountName, - GremlinDatabaseName: gremlinDatabaseName, - GraphName: graphName, - } -} - -func (id GremlinGraphId) String() string { - segments := []string{ - fmt.Sprintf("Graph Name %q", id.GraphName), - fmt.Sprintf("Gremlin Database Name %q", id.GremlinDatabaseName), - fmt.Sprintf("Database Account Name %q", id.DatabaseAccountName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Gremlin Graph", segmentsStr) -} - -func (id GremlinGraphId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/gremlinDatabases/%s/graphs/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.DatabaseAccountName, id.GremlinDatabaseName, id.GraphName) -} - -// GremlinGraphID parses a GremlinGraph ID into an GremlinGraphId struct -func GremlinGraphID(input string) (*GremlinGraphId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an GremlinGraph ID: %+v", input, err) - } - - resourceId := GremlinGraphId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.DatabaseAccountName, err = id.PopSegment("databaseAccounts"); err != nil { - return nil, err - } - if resourceId.GremlinDatabaseName, err = id.PopSegment("gremlinDatabases"); err != nil { - return nil, err - } - if resourceId.GraphName, err = id.PopSegment("graphs"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/cosmos/parse/gremlin_graph_test.go b/internal/services/cosmos/parse/gremlin_graph_test.go deleted file mode 100644 index f567685c700c..000000000000 --- a/internal/services/cosmos/parse/gremlin_graph_test.go +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = GremlinGraphId{} - -func TestGremlinGraphIDFormatter(t *testing.T) { - actual := NewGremlinGraphID("12345678-1234-9876-4563-123456789012", "resGroup1", "acc1", "database1", "graph1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/gremlinDatabases/database1/graphs/graph1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestGremlinGraphID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *GremlinGraphId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Error: true, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Error: true, - }, - - { - // missing GremlinDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/", - Error: true, - }, - - { - // missing value for GremlinDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/gremlinDatabases/", - Error: true, - }, - - { - // missing GraphName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/gremlinDatabases/database1/", - Error: true, - }, - - { - // missing value for GraphName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/gremlinDatabases/database1/graphs/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/gremlinDatabases/database1/graphs/graph1", - Expected: &GremlinGraphId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - DatabaseAccountName: "acc1", - GremlinDatabaseName: "database1", - GraphName: "graph1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACC1/GREMLINDATABASES/DATABASE1/GRAPHS/GRAPH1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := GremlinGraphID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - 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) - } - } -} diff --git a/internal/services/cosmos/parse/mongodb_collection.go b/internal/services/cosmos/parse/mongodb_collection.go deleted file mode 100644 index 153fe8013acb..000000000000 --- a/internal/services/cosmos/parse/mongodb_collection.go +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type MongodbCollectionId struct { - SubscriptionId string - ResourceGroup string - DatabaseAccountName string - MongodbDatabaseName string - CollectionName string -} - -func NewMongodbCollectionID(subscriptionId, resourceGroup, databaseAccountName, mongodbDatabaseName, collectionName string) MongodbCollectionId { - return MongodbCollectionId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DatabaseAccountName: databaseAccountName, - MongodbDatabaseName: mongodbDatabaseName, - CollectionName: collectionName, - } -} - -func (id MongodbCollectionId) String() string { - segments := []string{ - fmt.Sprintf("Collection Name %q", id.CollectionName), - fmt.Sprintf("Mongodb Database Name %q", id.MongodbDatabaseName), - fmt.Sprintf("Database Account Name %q", id.DatabaseAccountName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Mongodb Collection", segmentsStr) -} - -func (id MongodbCollectionId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/mongodbDatabases/%s/collections/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.DatabaseAccountName, id.MongodbDatabaseName, id.CollectionName) -} - -// MongodbCollectionID parses a MongodbCollection ID into an MongodbCollectionId struct -func MongodbCollectionID(input string) (*MongodbCollectionId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an MongodbCollection ID: %+v", input, err) - } - - resourceId := MongodbCollectionId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.DatabaseAccountName, err = id.PopSegment("databaseAccounts"); err != nil { - return nil, err - } - if resourceId.MongodbDatabaseName, err = id.PopSegment("mongodbDatabases"); err != nil { - return nil, err - } - if resourceId.CollectionName, err = id.PopSegment("collections"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/cosmos/parse/mongodb_collection_test.go b/internal/services/cosmos/parse/mongodb_collection_test.go deleted file mode 100644 index 1dd5f2427ebc..000000000000 --- a/internal/services/cosmos/parse/mongodb_collection_test.go +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = MongodbCollectionId{} - -func TestMongodbCollectionIDFormatter(t *testing.T) { - actual := NewMongodbCollectionID("12345678-1234-9876-4563-123456789012", "resGroup1", "acc1", "db1", "coll1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/mongodbDatabases/db1/collections/coll1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestMongodbCollectionID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *MongodbCollectionId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Error: true, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Error: true, - }, - - { - // missing MongodbDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/", - Error: true, - }, - - { - // missing value for MongodbDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/mongodbDatabases/", - Error: true, - }, - - { - // missing CollectionName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/mongodbDatabases/db1/", - Error: true, - }, - - { - // missing value for CollectionName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/mongodbDatabases/db1/collections/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/mongodbDatabases/db1/collections/coll1", - Expected: &MongodbCollectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - DatabaseAccountName: "acc1", - MongodbDatabaseName: "db1", - CollectionName: "coll1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACC1/MONGODBDATABASES/DB1/COLLECTIONS/COLL1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := MongodbCollectionID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - 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) - } - } -} diff --git a/internal/services/cosmos/parse/mongodb_database.go b/internal/services/cosmos/parse/mongodb_database.go deleted file mode 100644 index 57717bf4dc4e..000000000000 --- a/internal/services/cosmos/parse/mongodb_database.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type MongodbDatabaseId struct { - SubscriptionId string - ResourceGroup string - DatabaseAccountName string - Name string -} - -func NewMongodbDatabaseID(subscriptionId, resourceGroup, databaseAccountName, name string) MongodbDatabaseId { - return MongodbDatabaseId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DatabaseAccountName: databaseAccountName, - Name: name, - } -} - -func (id MongodbDatabaseId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Database Account Name %q", id.DatabaseAccountName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Mongodb Database", segmentsStr) -} - -func (id MongodbDatabaseId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/mongodbDatabases/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.DatabaseAccountName, id.Name) -} - -// MongodbDatabaseID parses a MongodbDatabase ID into an MongodbDatabaseId struct -func MongodbDatabaseID(input string) (*MongodbDatabaseId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an MongodbDatabase ID: %+v", input, err) - } - - resourceId := MongodbDatabaseId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.DatabaseAccountName, err = id.PopSegment("databaseAccounts"); err != nil { - return nil, err - } - if resourceId.Name, err = id.PopSegment("mongodbDatabases"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/cosmos/parse/mongodb_database_test.go b/internal/services/cosmos/parse/mongodb_database_test.go deleted file mode 100644 index 08c7ec5d8db7..000000000000 --- a/internal/services/cosmos/parse/mongodb_database_test.go +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = MongodbDatabaseId{} - -func TestMongodbDatabaseIDFormatter(t *testing.T) { - actual := NewMongodbDatabaseID("12345678-1234-9876-4563-123456789012", "resGroup1", "acc1", "db1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/mongodbDatabases/db1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestMongodbDatabaseID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *MongodbDatabaseId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Error: true, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/mongodbDatabases/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/mongodbDatabases/db1", - Expected: &MongodbDatabaseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - DatabaseAccountName: "acc1", - Name: "db1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACC1/MONGODBDATABASES/DB1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := MongodbDatabaseID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.DatabaseAccountName != v.Expected.DatabaseAccountName { - t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/cosmos/parse/notebook_workspace.go b/internal/services/cosmos/parse/notebook_workspace.go deleted file mode 100644 index ea3fa46c8102..000000000000 --- a/internal/services/cosmos/parse/notebook_workspace.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type NotebookWorkspaceId struct { - SubscriptionId string - ResourceGroup string - DatabaseAccountName string - Name string -} - -func NewNotebookWorkspaceID(subscriptionId, resourceGroup, databaseAccountName, name string) NotebookWorkspaceId { - return NotebookWorkspaceId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DatabaseAccountName: databaseAccountName, - Name: name, - } -} - -func (id NotebookWorkspaceId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Database Account Name %q", id.DatabaseAccountName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Notebook Workspace", segmentsStr) -} - -func (id NotebookWorkspaceId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/notebookWorkspaces/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.DatabaseAccountName, id.Name) -} - -// NotebookWorkspaceID parses a NotebookWorkspace ID into an NotebookWorkspaceId struct -func NotebookWorkspaceID(input string) (*NotebookWorkspaceId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an NotebookWorkspace ID: %+v", input, err) - } - - resourceId := NotebookWorkspaceId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.DatabaseAccountName, err = id.PopSegment("databaseAccounts"); err != nil { - return nil, err - } - if resourceId.Name, err = id.PopSegment("notebookWorkspaces"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/cosmos/parse/notebook_workspace_test.go b/internal/services/cosmos/parse/notebook_workspace_test.go deleted file mode 100644 index b03454e4025b..000000000000 --- a/internal/services/cosmos/parse/notebook_workspace_test.go +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = NotebookWorkspaceId{} - -func TestNotebookWorkspaceIDFormatter(t *testing.T) { - actual := NewNotebookWorkspaceID("12345678-1234-9876-4563-123456789012", "resourceGroup1", "account1", "notebookWorkspace1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/notebookWorkspaces/notebookWorkspace1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestNotebookWorkspaceID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *NotebookWorkspaceId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/", - Error: true, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/notebookWorkspaces/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/notebookWorkspaces/notebookWorkspace1", - Expected: &NotebookWorkspaceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resourceGroup1", - DatabaseAccountName: "account1", - Name: "notebookWorkspace1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESOURCEGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACCOUNT1/NOTEBOOKWORKSPACES/NOTEBOOKWORKSPACE1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := NotebookWorkspaceID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.DatabaseAccountName != v.Expected.DatabaseAccountName { - t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/cosmos/parse/restorable_database_account.go b/internal/services/cosmos/parse/restorable_database_account.go deleted file mode 100644 index 98fec0c26a7a..000000000000 --- a/internal/services/cosmos/parse/restorable_database_account.go +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type RestorableDatabaseAccountId struct { - SubscriptionId string - LocationName string - Name string -} - -func NewRestorableDatabaseAccountID(subscriptionId, locationName, name string) RestorableDatabaseAccountId { - return RestorableDatabaseAccountId{ - SubscriptionId: subscriptionId, - LocationName: locationName, - Name: name, - } -} - -func (id RestorableDatabaseAccountId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Location Name %q", id.LocationName), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Restorable Database Account", segmentsStr) -} - -func (id RestorableDatabaseAccountId) ID() string { - fmtString := "/subscriptions/%s/providers/Microsoft.DocumentDB/locations/%s/restorableDatabaseAccounts/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.Name) -} - -// RestorableDatabaseAccountID parses a RestorableDatabaseAccount ID into an RestorableDatabaseAccountId struct -func RestorableDatabaseAccountID(input string) (*RestorableDatabaseAccountId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an RestorableDatabaseAccount ID: %+v", input, err) - } - - resourceId := RestorableDatabaseAccountId{ - SubscriptionId: id.SubscriptionID, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.LocationName, err = id.PopSegment("locations"); err != nil { - return nil, err - } - if resourceId.Name, err = id.PopSegment("restorableDatabaseAccounts"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/cosmos/parse/restorable_database_account_test.go b/internal/services/cosmos/parse/restorable_database_account_test.go deleted file mode 100644 index a21acffd63e0..000000000000 --- a/internal/services/cosmos/parse/restorable_database_account_test.go +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = RestorableDatabaseAccountId{} - -func TestRestorableDatabaseAccountIDFormatter(t *testing.T) { - actual := NewRestorableDatabaseAccountID("12345678-1234-9876-4563-123456789012", "location1", "account1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/location1/restorableDatabaseAccounts/account1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestRestorableDatabaseAccountID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *RestorableDatabaseAccountId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing LocationName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/", - Error: true, - }, - - { - // missing value for LocationName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/location1/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/location1/restorableDatabaseAccounts/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/location1/restorableDatabaseAccounts/account1", - Expected: &RestorableDatabaseAccountId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - LocationName: "location1", - Name: "account1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/PROVIDERS/MICROSOFT.DOCUMENTDB/LOCATIONS/LOCATION1/RESTORABLEDATABASEACCOUNTS/ACCOUNT1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := RestorableDatabaseAccountID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.LocationName != v.Expected.LocationName { - t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/cosmos/parse/sql_container.go b/internal/services/cosmos/parse/sql_container.go deleted file mode 100644 index 622c11c8220e..000000000000 --- a/internal/services/cosmos/parse/sql_container.go +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type SqlContainerId struct { - SubscriptionId string - ResourceGroup string - DatabaseAccountName string - SqlDatabaseName string - ContainerName string -} - -func NewSqlContainerID(subscriptionId, resourceGroup, databaseAccountName, sqlDatabaseName, containerName string) SqlContainerId { - return SqlContainerId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DatabaseAccountName: databaseAccountName, - SqlDatabaseName: sqlDatabaseName, - ContainerName: containerName, - } -} - -func (id SqlContainerId) String() string { - segments := []string{ - fmt.Sprintf("Container Name %q", id.ContainerName), - fmt.Sprintf("Sql Database Name %q", id.SqlDatabaseName), - fmt.Sprintf("Database Account Name %q", id.DatabaseAccountName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Sql Container", segmentsStr) -} - -func (id SqlContainerId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/sqlDatabases/%s/containers/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName) -} - -// SqlContainerID parses a SqlContainer ID into an SqlContainerId struct -func SqlContainerID(input string) (*SqlContainerId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an SqlContainer ID: %+v", input, err) - } - - resourceId := SqlContainerId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.DatabaseAccountName, err = id.PopSegment("databaseAccounts"); err != nil { - return nil, err - } - if resourceId.SqlDatabaseName, err = id.PopSegment("sqlDatabases"); err != nil { - return nil, err - } - if resourceId.ContainerName, err = id.PopSegment("containers"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/cosmos/parse/sql_container_test.go b/internal/services/cosmos/parse/sql_container_test.go deleted file mode 100644 index be4d5158b631..000000000000 --- a/internal/services/cosmos/parse/sql_container_test.go +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = SqlContainerId{} - -func TestSqlContainerIDFormatter(t *testing.T) { - actual := NewSqlContainerID("12345678-1234-9876-4563-123456789012", "resGroup1", "acc1", "db1", "container1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1/containers/container1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestSqlContainerID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *SqlContainerId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Error: true, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Error: true, - }, - - { - // missing SqlDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/", - Error: true, - }, - - { - // missing value for SqlDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/", - Error: true, - }, - - { - // missing ContainerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1/", - Error: true, - }, - - { - // missing value for ContainerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1/containers/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1/containers/container1", - Expected: &SqlContainerId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - DatabaseAccountName: "acc1", - SqlDatabaseName: "db1", - ContainerName: "container1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACC1/SQLDATABASES/DB1/CONTAINERS/CONTAINER1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := SqlContainerID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - 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) - } - } -} diff --git a/internal/services/cosmos/parse/sql_database.go b/internal/services/cosmos/parse/sql_database.go deleted file mode 100644 index 0deea0ff7800..000000000000 --- a/internal/services/cosmos/parse/sql_database.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type SqlDatabaseId struct { - SubscriptionId string - ResourceGroup string - DatabaseAccountName string - Name string -} - -func NewSqlDatabaseID(subscriptionId, resourceGroup, databaseAccountName, name string) SqlDatabaseId { - return SqlDatabaseId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DatabaseAccountName: databaseAccountName, - Name: name, - } -} - -func (id SqlDatabaseId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Database Account Name %q", id.DatabaseAccountName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Sql Database", segmentsStr) -} - -func (id SqlDatabaseId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/sqlDatabases/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.DatabaseAccountName, id.Name) -} - -// SqlDatabaseID parses a SqlDatabase ID into an SqlDatabaseId struct -func SqlDatabaseID(input string) (*SqlDatabaseId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an SqlDatabase ID: %+v", input, err) - } - - resourceId := SqlDatabaseId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.DatabaseAccountName, err = id.PopSegment("databaseAccounts"); err != nil { - return nil, err - } - if resourceId.Name, err = id.PopSegment("sqlDatabases"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/cosmos/parse/sql_database_test.go b/internal/services/cosmos/parse/sql_database_test.go deleted file mode 100644 index b9eeb5b7f810..000000000000 --- a/internal/services/cosmos/parse/sql_database_test.go +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = SqlDatabaseId{} - -func TestSqlDatabaseIDFormatter(t *testing.T) { - actual := NewSqlDatabaseID("12345678-1234-9876-4563-123456789012", "resGroup1", "acc1", "db1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestSqlDatabaseID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *SqlDatabaseId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Error: true, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1", - Expected: &SqlDatabaseId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - DatabaseAccountName: "acc1", - Name: "db1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACC1/SQLDATABASES/DB1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := SqlDatabaseID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.DatabaseAccountName != v.Expected.DatabaseAccountName { - t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/cosmos/parse/sql_function.go b/internal/services/cosmos/parse/sql_function.go deleted file mode 100644 index fe82aa16ce7b..000000000000 --- a/internal/services/cosmos/parse/sql_function.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type SqlFunctionId struct { - SubscriptionId string - ResourceGroup string - DatabaseAccountName string - SqlDatabaseName string - ContainerName string - UserDefinedFunctionName string -} - -func NewSqlFunctionID(subscriptionId, resourceGroup, databaseAccountName, sqlDatabaseName, containerName, userDefinedFunctionName string) SqlFunctionId { - return SqlFunctionId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DatabaseAccountName: databaseAccountName, - SqlDatabaseName: sqlDatabaseName, - ContainerName: containerName, - UserDefinedFunctionName: userDefinedFunctionName, - } -} - -func (id SqlFunctionId) String() string { - segments := []string{ - fmt.Sprintf("User Defined Function Name %q", id.UserDefinedFunctionName), - fmt.Sprintf("Container Name %q", id.ContainerName), - fmt.Sprintf("Sql Database Name %q", id.SqlDatabaseName), - fmt.Sprintf("Database Account Name %q", id.DatabaseAccountName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Sql Function", segmentsStr) -} - -func (id SqlFunctionId) 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.ResourceGroup, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName, id.UserDefinedFunctionName) -} - -// SqlFunctionID parses a SqlFunction ID into an SqlFunctionId struct -func SqlFunctionID(input string) (*SqlFunctionId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an SqlFunction ID: %+v", input, err) - } - - resourceId := SqlFunctionId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.DatabaseAccountName, err = id.PopSegment("databaseAccounts"); err != nil { - return nil, err - } - if resourceId.SqlDatabaseName, err = id.PopSegment("sqlDatabases"); err != nil { - return nil, err - } - if resourceId.ContainerName, err = id.PopSegment("containers"); err != nil { - return nil, err - } - if resourceId.UserDefinedFunctionName, err = id.PopSegment("userDefinedFunctions"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/cosmos/parse/sql_function_test.go b/internal/services/cosmos/parse/sql_function_test.go deleted file mode 100644 index e32a108cbd37..000000000000 --- a/internal/services/cosmos/parse/sql_function_test.go +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = SqlFunctionId{} - -func TestSqlFunctionIDFormatter(t *testing.T) { - actual := NewSqlFunctionID("12345678-1234-9876-4563-123456789012", "resourceGroup1", "account1", "database1", "container1", "userDefinedFunction1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1/userDefinedFunctions/userDefinedFunction1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestSqlFunctionID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *SqlFunctionId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/", - Error: true, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Error: true, - }, - - { - // missing SqlDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/", - Error: true, - }, - - { - // missing value for SqlDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/", - Error: true, - }, - - { - // missing ContainerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/", - Error: true, - }, - - { - // missing value for ContainerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/", - Error: true, - }, - - { - // missing UserDefinedFunctionName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1/", - Error: true, - }, - - { - // missing value for UserDefinedFunctionName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1/userDefinedFunctions/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1/userDefinedFunctions/userDefinedFunction1", - Expected: &SqlFunctionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resourceGroup1", - DatabaseAccountName: "account1", - SqlDatabaseName: "database1", - ContainerName: "container1", - UserDefinedFunctionName: "userDefinedFunction1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESOURCEGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACCOUNT1/SQLDATABASES/DATABASE1/CONTAINERS/CONTAINER1/USERDEFINEDFUNCTIONS/USERDEFINEDFUNCTION1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := SqlFunctionID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - 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) - } - } -} diff --git a/internal/services/cosmos/parse/sql_role_assignment.go b/internal/services/cosmos/parse/sql_role_assignment.go deleted file mode 100644 index 9c04740b6583..000000000000 --- a/internal/services/cosmos/parse/sql_role_assignment.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type SqlRoleAssignmentId struct { - SubscriptionId string - ResourceGroup string - DatabaseAccountName string - Name string -} - -func NewSqlRoleAssignmentID(subscriptionId, resourceGroup, databaseAccountName, name string) SqlRoleAssignmentId { - return SqlRoleAssignmentId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DatabaseAccountName: databaseAccountName, - Name: name, - } -} - -func (id SqlRoleAssignmentId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Database Account Name %q", id.DatabaseAccountName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Sql Role Assignment", segmentsStr) -} - -func (id SqlRoleAssignmentId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/sqlRoleAssignments/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.DatabaseAccountName, id.Name) -} - -// SqlRoleAssignmentID parses a SqlRoleAssignment ID into an SqlRoleAssignmentId struct -func SqlRoleAssignmentID(input string) (*SqlRoleAssignmentId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an SqlRoleAssignment ID: %+v", input, err) - } - - resourceId := SqlRoleAssignmentId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.DatabaseAccountName, err = id.PopSegment("databaseAccounts"); err != nil { - return nil, err - } - if resourceId.Name, err = id.PopSegment("sqlRoleAssignments"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/cosmos/parse/sql_role_assignment_test.go b/internal/services/cosmos/parse/sql_role_assignment_test.go deleted file mode 100644 index 6b6e922b5937..000000000000 --- a/internal/services/cosmos/parse/sql_role_assignment_test.go +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = SqlRoleAssignmentId{} - -func TestSqlRoleAssignmentIDFormatter(t *testing.T) { - actual := NewSqlRoleAssignmentID("12345678-1234-9876-4563-123456789012", "resourceGroup1", "account1", "roleAssignment1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlRoleAssignments/roleAssignment1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestSqlRoleAssignmentID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *SqlRoleAssignmentId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/", - Error: true, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlRoleAssignments/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlRoleAssignments/roleAssignment1", - Expected: &SqlRoleAssignmentId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resourceGroup1", - DatabaseAccountName: "account1", - Name: "roleAssignment1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESOURCEGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACCOUNT1/SQLROLEASSIGNMENTS/ROLEASSIGNMENT1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := SqlRoleAssignmentID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.DatabaseAccountName != v.Expected.DatabaseAccountName { - t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/cosmos/parse/sql_role_definition.go b/internal/services/cosmos/parse/sql_role_definition.go deleted file mode 100644 index 9d9c6993631a..000000000000 --- a/internal/services/cosmos/parse/sql_role_definition.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type SqlRoleDefinitionId struct { - SubscriptionId string - ResourceGroup string - DatabaseAccountName string - Name string -} - -func NewSqlRoleDefinitionID(subscriptionId, resourceGroup, databaseAccountName, name string) SqlRoleDefinitionId { - return SqlRoleDefinitionId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DatabaseAccountName: databaseAccountName, - Name: name, - } -} - -func (id SqlRoleDefinitionId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Database Account Name %q", id.DatabaseAccountName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Sql Role Definition", segmentsStr) -} - -func (id SqlRoleDefinitionId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/sqlRoleDefinitions/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.DatabaseAccountName, id.Name) -} - -// SqlRoleDefinitionID parses a SqlRoleDefinition ID into an SqlRoleDefinitionId struct -func SqlRoleDefinitionID(input string) (*SqlRoleDefinitionId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an SqlRoleDefinition ID: %+v", input, err) - } - - resourceId := SqlRoleDefinitionId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.DatabaseAccountName, err = id.PopSegment("databaseAccounts"); err != nil { - return nil, err - } - if resourceId.Name, err = id.PopSegment("sqlRoleDefinitions"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/cosmos/parse/sql_role_definition_test.go b/internal/services/cosmos/parse/sql_role_definition_test.go deleted file mode 100644 index 7ab4e384c466..000000000000 --- a/internal/services/cosmos/parse/sql_role_definition_test.go +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = SqlRoleDefinitionId{} - -func TestSqlRoleDefinitionIDFormatter(t *testing.T) { - actual := NewSqlRoleDefinitionID("12345678-1234-9876-4563-123456789012", "resourceGroup1", "account1", "def1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlRoleDefinitions/def1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestSqlRoleDefinitionID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *SqlRoleDefinitionId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/", - Error: true, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlRoleDefinitions/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlRoleDefinitions/def1", - Expected: &SqlRoleDefinitionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resourceGroup1", - DatabaseAccountName: "account1", - Name: "def1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESOURCEGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACCOUNT1/SQLROLEDEFINITIONS/DEF1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := SqlRoleDefinitionID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.DatabaseAccountName != v.Expected.DatabaseAccountName { - t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/cosmos/parse/sql_stored_procedure.go b/internal/services/cosmos/parse/sql_stored_procedure.go deleted file mode 100644 index 53937e1bd67a..000000000000 --- a/internal/services/cosmos/parse/sql_stored_procedure.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type SqlStoredProcedureId struct { - SubscriptionId string - ResourceGroup string - DatabaseAccountName string - SqlDatabaseName string - ContainerName string - StoredProcedureName string -} - -func NewSqlStoredProcedureID(subscriptionId, resourceGroup, databaseAccountName, sqlDatabaseName, containerName, storedProcedureName string) SqlStoredProcedureId { - return SqlStoredProcedureId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DatabaseAccountName: databaseAccountName, - SqlDatabaseName: sqlDatabaseName, - ContainerName: containerName, - StoredProcedureName: storedProcedureName, - } -} - -func (id SqlStoredProcedureId) String() string { - segments := []string{ - fmt.Sprintf("Stored Procedure Name %q", id.StoredProcedureName), - fmt.Sprintf("Container Name %q", id.ContainerName), - fmt.Sprintf("Sql Database Name %q", id.SqlDatabaseName), - fmt.Sprintf("Database Account Name %q", id.DatabaseAccountName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Sql Stored Procedure", segmentsStr) -} - -func (id SqlStoredProcedureId) 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.ResourceGroup, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName, id.StoredProcedureName) -} - -// SqlStoredProcedureID parses a SqlStoredProcedure ID into an SqlStoredProcedureId struct -func SqlStoredProcedureID(input string) (*SqlStoredProcedureId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an SqlStoredProcedure ID: %+v", input, err) - } - - resourceId := SqlStoredProcedureId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.DatabaseAccountName, err = id.PopSegment("databaseAccounts"); err != nil { - return nil, err - } - if resourceId.SqlDatabaseName, err = id.PopSegment("sqlDatabases"); err != nil { - return nil, err - } - if resourceId.ContainerName, err = id.PopSegment("containers"); err != nil { - return nil, err - } - if resourceId.StoredProcedureName, err = id.PopSegment("storedProcedures"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/cosmos/parse/sql_stored_procedure_test.go b/internal/services/cosmos/parse/sql_stored_procedure_test.go deleted file mode 100644 index c9699f3425a0..000000000000 --- a/internal/services/cosmos/parse/sql_stored_procedure_test.go +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = SqlStoredProcedureId{} - -func TestSqlStoredProcedureIDFormatter(t *testing.T) { - actual := NewSqlStoredProcedureID("12345678-1234-9876-4563-123456789012", "resGroup1", "acc1", "db1", "container1", "sproc1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1/containers/container1/storedProcedures/sproc1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestSqlStoredProcedureID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *SqlStoredProcedureId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Error: true, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Error: true, - }, - - { - // missing SqlDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/", - Error: true, - }, - - { - // missing value for SqlDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/", - Error: true, - }, - - { - // missing ContainerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1/", - Error: true, - }, - - { - // missing value for ContainerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1/containers/", - Error: true, - }, - - { - // missing StoredProcedureName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1/containers/container1/", - Error: true, - }, - - { - // missing value for StoredProcedureName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1/containers/container1/storedProcedures/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1/containers/container1/storedProcedures/sproc1", - Expected: &SqlStoredProcedureId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - DatabaseAccountName: "acc1", - SqlDatabaseName: "db1", - ContainerName: "container1", - StoredProcedureName: "sproc1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACC1/SQLDATABASES/DB1/CONTAINERS/CONTAINER1/STOREDPROCEDURES/SPROC1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := SqlStoredProcedureID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - 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) - } - } -} diff --git a/internal/services/cosmos/parse/sql_trigger.go b/internal/services/cosmos/parse/sql_trigger.go deleted file mode 100644 index b5a8a748db90..000000000000 --- a/internal/services/cosmos/parse/sql_trigger.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type SqlTriggerId struct { - SubscriptionId string - ResourceGroup string - DatabaseAccountName string - SqlDatabaseName string - ContainerName string - TriggerName string -} - -func NewSqlTriggerID(subscriptionId, resourceGroup, databaseAccountName, sqlDatabaseName, containerName, triggerName string) SqlTriggerId { - return SqlTriggerId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DatabaseAccountName: databaseAccountName, - SqlDatabaseName: sqlDatabaseName, - ContainerName: containerName, - TriggerName: triggerName, - } -} - -func (id SqlTriggerId) String() string { - segments := []string{ - fmt.Sprintf("Trigger Name %q", id.TriggerName), - fmt.Sprintf("Container Name %q", id.ContainerName), - fmt.Sprintf("Sql Database Name %q", id.SqlDatabaseName), - fmt.Sprintf("Database Account Name %q", id.DatabaseAccountName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Sql Trigger", segmentsStr) -} - -func (id SqlTriggerId) 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.ResourceGroup, id.DatabaseAccountName, id.SqlDatabaseName, id.ContainerName, id.TriggerName) -} - -// SqlTriggerID parses a SqlTrigger ID into an SqlTriggerId struct -func SqlTriggerID(input string) (*SqlTriggerId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an SqlTrigger ID: %+v", input, err) - } - - resourceId := SqlTriggerId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.DatabaseAccountName, err = id.PopSegment("databaseAccounts"); err != nil { - return nil, err - } - if resourceId.SqlDatabaseName, err = id.PopSegment("sqlDatabases"); err != nil { - return nil, err - } - if resourceId.ContainerName, err = id.PopSegment("containers"); err != nil { - return nil, err - } - if resourceId.TriggerName, err = id.PopSegment("triggers"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/cosmos/parse/sql_trigger_test.go b/internal/services/cosmos/parse/sql_trigger_test.go deleted file mode 100644 index 01733f767f28..000000000000 --- a/internal/services/cosmos/parse/sql_trigger_test.go +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = SqlTriggerId{} - -func TestSqlTriggerIDFormatter(t *testing.T) { - actual := NewSqlTriggerID("12345678-1234-9876-4563-123456789012", "resourceGroup1", "account1", "database1", "container1", "trigger1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1/triggers/trigger1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestSqlTriggerID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *SqlTriggerId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/", - Error: true, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Error: true, - }, - - { - // missing SqlDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/", - Error: true, - }, - - { - // missing value for SqlDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/", - Error: true, - }, - - { - // missing ContainerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/", - Error: true, - }, - - { - // missing value for ContainerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/", - Error: true, - }, - - { - // missing TriggerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1/", - Error: true, - }, - - { - // missing value for TriggerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1/triggers/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1/triggers/trigger1", - Expected: &SqlTriggerId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resourceGroup1", - DatabaseAccountName: "account1", - SqlDatabaseName: "database1", - ContainerName: "container1", - TriggerName: "trigger1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESOURCEGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACCOUNT1/SQLDATABASES/DATABASE1/CONTAINERS/CONTAINER1/TRIGGERS/TRIGGER1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := SqlTriggerID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - 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) - } - } -} diff --git a/internal/services/cosmos/parse/table.go b/internal/services/cosmos/parse/table.go deleted file mode 100644 index b1b7b48aa6a7..000000000000 --- a/internal/services/cosmos/parse/table.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type TableId struct { - SubscriptionId string - ResourceGroup string - DatabaseAccountName string - Name string -} - -func NewTableID(subscriptionId, resourceGroup, databaseAccountName, name string) TableId { - return TableId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - DatabaseAccountName: databaseAccountName, - Name: name, - } -} - -func (id TableId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Database Account Name %q", id.DatabaseAccountName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Table", segmentsStr) -} - -func (id TableId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DocumentDB/databaseAccounts/%s/tables/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.DatabaseAccountName, id.Name) -} - -// TableID parses a Table ID into an TableId struct -func TableID(input string) (*TableId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an Table ID: %+v", input, err) - } - - resourceId := TableId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.DatabaseAccountName, err = id.PopSegment("databaseAccounts"); err != nil { - return nil, err - } - if resourceId.Name, err = id.PopSegment("tables"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/cosmos/parse/table_test.go b/internal/services/cosmos/parse/table_test.go deleted file mode 100644 index 6a551c6d0db3..000000000000 --- a/internal/services/cosmos/parse/table_test.go +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = TableId{} - -func TestTableIDFormatter(t *testing.T) { - actual := NewTableID("12345678-1234-9876-4563-123456789012", "resGroup1", "acc1", "table1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/tables/table1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestTableID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *TableId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Error: true, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/tables/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/tables/table1", - Expected: &TableId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - DatabaseAccountName: "acc1", - Name: "table1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACC1/TABLES/TABLE1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := TableID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.DatabaseAccountName != v.Expected.DatabaseAccountName { - t.Fatalf("Expected %q but got %q for DatabaseAccountName", v.Expected.DatabaseAccountName, actual.DatabaseAccountName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/cosmos/resourceids.go b/internal/services/cosmos/resourceids.go deleted file mode 100644 index cacbde5b4f94..000000000000 --- a/internal/services/cosmos/resourceids.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package cosmos - -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=CassandraKeyspace -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/cassandraKeyspaces/keyspace1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=CassandraTable -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/cassandraKeyspaces/keyspace1/tables/table1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=DatabaseAccount -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=GremlinDatabase -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/gremlinDatabases/database1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=GremlinGraph -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/gremlinDatabases/database1/graphs/graph1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=MongodbCollection -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/mongodbDatabases/db1/collections/coll1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=MongodbDatabase -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/mongodbDatabases/db1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=NotebookWorkspace -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/notebookWorkspaces/notebookWorkspace1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=RestorableDatabaseAccount -id=/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/location1/restorableDatabaseAccounts/account1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SqlContainer -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1/containers/container1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SqlDatabase -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SqlFunction -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1/userDefinedFunctions/userDefinedFunction1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SqlRoleAssignment -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlRoleAssignments/roleAssignment1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SqlRoleDefinition -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlRoleDefinitions/def1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SqlStoredProcedure -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1/containers/container1/storedProcedures/sproc1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SqlTrigger -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1/triggers/trigger1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=Table -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/tables/table1 diff --git a/internal/services/cosmos/validate/cassandra_keyspace_id.go b/internal/services/cosmos/validate/cassandra_keyspace_id.go deleted file mode 100644 index 5ddb5c4b726a..000000000000 --- a/internal/services/cosmos/validate/cassandra_keyspace_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" -) - -func CassandraKeyspaceID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.CassandraKeyspaceID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/cosmos/validate/cassandra_keyspace_id_test.go b/internal/services/cosmos/validate/cassandra_keyspace_id_test.go deleted file mode 100644 index bf8fedb102ff..000000000000 --- a/internal/services/cosmos/validate/cassandra_keyspace_id_test.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestCassandraKeyspaceID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Valid: false, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/cassandraKeyspaces/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/cassandraKeyspaces/keyspace1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACC1/CASSANDRAKEYSPACES/KEYSPACE1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := CassandraKeyspaceID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/cosmos/validate/cassandra_table_id.go b/internal/services/cosmos/validate/cassandra_table_id.go deleted file mode 100644 index 93bd9573e754..000000000000 --- a/internal/services/cosmos/validate/cassandra_table_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" -) - -func CassandraTableID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.CassandraTableID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/cosmos/validate/cassandra_table_id_test.go b/internal/services/cosmos/validate/cassandra_table_id_test.go deleted file mode 100644 index 717b2f3b91c0..000000000000 --- a/internal/services/cosmos/validate/cassandra_table_id_test.go +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestCassandraTableID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Valid: false, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Valid: false, - }, - - { - // missing CassandraKeyspaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/", - Valid: false, - }, - - { - // missing value for CassandraKeyspaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/cassandraKeyspaces/", - Valid: false, - }, - - { - // missing TableName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/cassandraKeyspaces/keyspace1/", - Valid: false, - }, - - { - // missing value for TableName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/cassandraKeyspaces/keyspace1/tables/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/cassandraKeyspaces/keyspace1/tables/table1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACC1/CASSANDRAKEYSPACES/KEYSPACE1/TABLES/TABLE1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := CassandraTableID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/cosmos/validate/database_account_id.go b/internal/services/cosmos/validate/database_account_id.go deleted file mode 100644 index bf7cfb50e492..000000000000 --- a/internal/services/cosmos/validate/database_account_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" -) - -func DatabaseAccountID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.DatabaseAccountID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/cosmos/validate/database_account_id_test.go b/internal/services/cosmos/validate/database_account_id_test.go deleted file mode 100644 index f1bd5c5b4955..000000000000 --- a/internal/services/cosmos/validate/database_account_id_test.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestDatabaseAccountID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACC1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := DatabaseAccountID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/cosmos/validate/gremlin_database_id.go b/internal/services/cosmos/validate/gremlin_database_id.go deleted file mode 100644 index 68a9f75db996..000000000000 --- a/internal/services/cosmos/validate/gremlin_database_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" -) - -func GremlinDatabaseID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.GremlinDatabaseID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/cosmos/validate/gremlin_database_id_test.go b/internal/services/cosmos/validate/gremlin_database_id_test.go deleted file mode 100644 index 4100e081357f..000000000000 --- a/internal/services/cosmos/validate/gremlin_database_id_test.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestGremlinDatabaseID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Valid: false, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/gremlinDatabases/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/gremlinDatabases/database1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACC1/GREMLINDATABASES/DATABASE1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := GremlinDatabaseID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/cosmos/validate/gremlin_graph_id.go b/internal/services/cosmos/validate/gremlin_graph_id.go deleted file mode 100644 index 210f7fd75b27..000000000000 --- a/internal/services/cosmos/validate/gremlin_graph_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" -) - -func GremlinGraphID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.GremlinGraphID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/cosmos/validate/gremlin_graph_id_test.go b/internal/services/cosmos/validate/gremlin_graph_id_test.go deleted file mode 100644 index 61e5b0bd3dbe..000000000000 --- a/internal/services/cosmos/validate/gremlin_graph_id_test.go +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestGremlinGraphID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Valid: false, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Valid: false, - }, - - { - // missing GremlinDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/", - Valid: false, - }, - - { - // missing value for GremlinDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/gremlinDatabases/", - Valid: false, - }, - - { - // missing GraphName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/gremlinDatabases/database1/", - Valid: false, - }, - - { - // missing value for GraphName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/gremlinDatabases/database1/graphs/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/gremlinDatabases/database1/graphs/graph1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACC1/GREMLINDATABASES/DATABASE1/GRAPHS/GRAPH1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := GremlinGraphID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/cosmos/validate/mongodb_collection_id.go b/internal/services/cosmos/validate/mongodb_collection_id.go deleted file mode 100644 index 51ca234d70bf..000000000000 --- a/internal/services/cosmos/validate/mongodb_collection_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" -) - -func MongodbCollectionID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.MongodbCollectionID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/cosmos/validate/mongodb_collection_id_test.go b/internal/services/cosmos/validate/mongodb_collection_id_test.go deleted file mode 100644 index 0fe9c2e4a8ca..000000000000 --- a/internal/services/cosmos/validate/mongodb_collection_id_test.go +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestMongodbCollectionID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Valid: false, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Valid: false, - }, - - { - // missing MongodbDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/", - Valid: false, - }, - - { - // missing value for MongodbDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/mongodbDatabases/", - Valid: false, - }, - - { - // missing CollectionName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/mongodbDatabases/db1/", - Valid: false, - }, - - { - // missing value for CollectionName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/mongodbDatabases/db1/collections/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/mongodbDatabases/db1/collections/coll1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACC1/MONGODBDATABASES/DB1/COLLECTIONS/COLL1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := MongodbCollectionID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/cosmos/validate/mongodb_database_id.go b/internal/services/cosmos/validate/mongodb_database_id.go deleted file mode 100644 index 9ec0ab84b0bb..000000000000 --- a/internal/services/cosmos/validate/mongodb_database_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" -) - -func MongodbDatabaseID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.MongodbDatabaseID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/cosmos/validate/mongodb_database_id_test.go b/internal/services/cosmos/validate/mongodb_database_id_test.go deleted file mode 100644 index 1c2ef8aef54c..000000000000 --- a/internal/services/cosmos/validate/mongodb_database_id_test.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestMongodbDatabaseID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Valid: false, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/mongodbDatabases/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/mongodbDatabases/db1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACC1/MONGODBDATABASES/DB1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := MongodbDatabaseID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/cosmos/validate/notebook_workspace_id.go b/internal/services/cosmos/validate/notebook_workspace_id.go deleted file mode 100644 index 18d5ef8eb182..000000000000 --- a/internal/services/cosmos/validate/notebook_workspace_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" -) - -func NotebookWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.NotebookWorkspaceID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/cosmos/validate/notebook_workspace_id_test.go b/internal/services/cosmos/validate/notebook_workspace_id_test.go deleted file mode 100644 index fcda8c27c147..000000000000 --- a/internal/services/cosmos/validate/notebook_workspace_id_test.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestNotebookWorkspaceID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/", - Valid: false, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/notebookWorkspaces/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/notebookWorkspaces/notebookWorkspace1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESOURCEGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACCOUNT1/NOTEBOOKWORKSPACES/NOTEBOOKWORKSPACE1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := NotebookWorkspaceID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/cosmos/validate/restorable_database_account_id.go b/internal/services/cosmos/validate/restorable_database_account_id.go deleted file mode 100644 index 0e9789b936b9..000000000000 --- a/internal/services/cosmos/validate/restorable_database_account_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" -) - -func RestorableDatabaseAccountID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.RestorableDatabaseAccountID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/cosmos/validate/restorable_database_account_id_test.go b/internal/services/cosmos/validate/restorable_database_account_id_test.go deleted file mode 100644 index d66af376898e..000000000000 --- a/internal/services/cosmos/validate/restorable_database_account_id_test.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestRestorableDatabaseAccountID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing LocationName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/", - Valid: false, - }, - - { - // missing value for LocationName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/location1/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/location1/restorableDatabaseAccounts/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DocumentDB/locations/location1/restorableDatabaseAccounts/account1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/PROVIDERS/MICROSOFT.DOCUMENTDB/LOCATIONS/LOCATION1/RESTORABLEDATABASEACCOUNTS/ACCOUNT1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := RestorableDatabaseAccountID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/cosmos/validate/sql_container_id.go b/internal/services/cosmos/validate/sql_container_id.go deleted file mode 100644 index 3f515ad3e011..000000000000 --- a/internal/services/cosmos/validate/sql_container_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" -) - -func SqlContainerID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.SqlContainerID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/cosmos/validate/sql_container_id_test.go b/internal/services/cosmos/validate/sql_container_id_test.go deleted file mode 100644 index b8e772ee9e94..000000000000 --- a/internal/services/cosmos/validate/sql_container_id_test.go +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestSqlContainerID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Valid: false, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Valid: false, - }, - - { - // missing SqlDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/", - Valid: false, - }, - - { - // missing value for SqlDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/", - Valid: false, - }, - - { - // missing ContainerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1/", - Valid: false, - }, - - { - // missing value for ContainerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1/containers/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1/containers/container1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACC1/SQLDATABASES/DB1/CONTAINERS/CONTAINER1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := SqlContainerID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/cosmos/validate/sql_database_id.go b/internal/services/cosmos/validate/sql_database_id.go deleted file mode 100644 index b2a25e6b3101..000000000000 --- a/internal/services/cosmos/validate/sql_database_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" -) - -func SqlDatabaseID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.SqlDatabaseID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/cosmos/validate/sql_database_id_test.go b/internal/services/cosmos/validate/sql_database_id_test.go deleted file mode 100644 index c901f72fb1f4..000000000000 --- a/internal/services/cosmos/validate/sql_database_id_test.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestSqlDatabaseID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Valid: false, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACC1/SQLDATABASES/DB1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := SqlDatabaseID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/cosmos/validate/sql_function_id.go b/internal/services/cosmos/validate/sql_function_id.go deleted file mode 100644 index 0926c882d270..000000000000 --- a/internal/services/cosmos/validate/sql_function_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" -) - -func SqlFunctionID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.SqlFunctionID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/cosmos/validate/sql_function_id_test.go b/internal/services/cosmos/validate/sql_function_id_test.go deleted file mode 100644 index ecb9a0ca1f49..000000000000 --- a/internal/services/cosmos/validate/sql_function_id_test.go +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestSqlFunctionID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/", - Valid: false, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Valid: false, - }, - - { - // missing SqlDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/", - Valid: false, - }, - - { - // missing value for SqlDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/", - Valid: false, - }, - - { - // missing ContainerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/", - Valid: false, - }, - - { - // missing value for ContainerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/", - Valid: false, - }, - - { - // missing UserDefinedFunctionName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1/", - Valid: false, - }, - - { - // missing value for UserDefinedFunctionName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1/userDefinedFunctions/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1/userDefinedFunctions/userDefinedFunction1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESOURCEGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACCOUNT1/SQLDATABASES/DATABASE1/CONTAINERS/CONTAINER1/USERDEFINEDFUNCTIONS/USERDEFINEDFUNCTION1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := SqlFunctionID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/cosmos/validate/sql_role_assignment_id.go b/internal/services/cosmos/validate/sql_role_assignment_id.go deleted file mode 100644 index faf9b1ff5c65..000000000000 --- a/internal/services/cosmos/validate/sql_role_assignment_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" -) - -func SqlRoleAssignmentID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.SqlRoleAssignmentID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/cosmos/validate/sql_role_assignment_id_test.go b/internal/services/cosmos/validate/sql_role_assignment_id_test.go deleted file mode 100644 index 36a72d5ee5c7..000000000000 --- a/internal/services/cosmos/validate/sql_role_assignment_id_test.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestSqlRoleAssignmentID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/", - Valid: false, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlRoleAssignments/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlRoleAssignments/roleAssignment1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESOURCEGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACCOUNT1/SQLROLEASSIGNMENTS/ROLEASSIGNMENT1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := SqlRoleAssignmentID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/cosmos/validate/sql_role_definition_id.go b/internal/services/cosmos/validate/sql_role_definition_id.go deleted file mode 100644 index 32f9df0d10b6..000000000000 --- a/internal/services/cosmos/validate/sql_role_definition_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" -) - -func SqlRoleDefinitionID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.SqlRoleDefinitionID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/cosmos/validate/sql_role_definition_id_test.go b/internal/services/cosmos/validate/sql_role_definition_id_test.go deleted file mode 100644 index 73c8da16ccba..000000000000 --- a/internal/services/cosmos/validate/sql_role_definition_id_test.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestSqlRoleDefinitionID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/", - Valid: false, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlRoleDefinitions/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlRoleDefinitions/def1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESOURCEGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACCOUNT1/SQLROLEDEFINITIONS/DEF1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := SqlRoleDefinitionID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/cosmos/validate/sql_stored_procedure_id.go b/internal/services/cosmos/validate/sql_stored_procedure_id.go deleted file mode 100644 index 733c30a93cb7..000000000000 --- a/internal/services/cosmos/validate/sql_stored_procedure_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" -) - -func SqlStoredProcedureID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.SqlStoredProcedureID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/cosmos/validate/sql_stored_procedure_id_test.go b/internal/services/cosmos/validate/sql_stored_procedure_id_test.go deleted file mode 100644 index 664f6fbb5ab9..000000000000 --- a/internal/services/cosmos/validate/sql_stored_procedure_id_test.go +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestSqlStoredProcedureID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Valid: false, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Valid: false, - }, - - { - // missing SqlDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/", - Valid: false, - }, - - { - // missing value for SqlDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/", - Valid: false, - }, - - { - // missing ContainerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1/", - Valid: false, - }, - - { - // missing value for ContainerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1/containers/", - Valid: false, - }, - - { - // missing StoredProcedureName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1/containers/container1/", - Valid: false, - }, - - { - // missing value for StoredProcedureName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1/containers/container1/storedProcedures/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1/containers/container1/storedProcedures/sproc1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACC1/SQLDATABASES/DB1/CONTAINERS/CONTAINER1/STOREDPROCEDURES/SPROC1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := SqlStoredProcedureID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/cosmos/validate/sql_trigger_id.go b/internal/services/cosmos/validate/sql_trigger_id.go deleted file mode 100644 index 99725a71fbf9..000000000000 --- a/internal/services/cosmos/validate/sql_trigger_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" -) - -func SqlTriggerID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.SqlTriggerID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/cosmos/validate/sql_trigger_id_test.go b/internal/services/cosmos/validate/sql_trigger_id_test.go deleted file mode 100644 index fb0c8e0f4e9f..000000000000 --- a/internal/services/cosmos/validate/sql_trigger_id_test.go +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestSqlTriggerID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/", - Valid: false, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Valid: false, - }, - - { - // missing SqlDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/", - Valid: false, - }, - - { - // missing value for SqlDatabaseName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/", - Valid: false, - }, - - { - // missing ContainerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/", - Valid: false, - }, - - { - // missing value for ContainerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/", - Valid: false, - }, - - { - // missing TriggerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1/", - Valid: false, - }, - - { - // missing value for TriggerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1/triggers/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroup1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1/triggers/trigger1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESOURCEGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACCOUNT1/SQLDATABASES/DATABASE1/CONTAINERS/CONTAINER1/TRIGGERS/TRIGGER1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := SqlTriggerID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/cosmos/validate/table_id.go b/internal/services/cosmos/validate/table_id.go deleted file mode 100644 index 689dbd7b2e7e..000000000000 --- a/internal/services/cosmos/validate/table_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" -) - -func TableID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.TableID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/cosmos/validate/table_id_test.go b/internal/services/cosmos/validate/table_id_test.go deleted file mode 100644 index 7d79a1a8affc..000000000000 --- a/internal/services/cosmos/validate/table_id_test.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestTableID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/", - Valid: false, - }, - - { - // missing value for DatabaseAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/tables/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/tables/table1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.DOCUMENTDB/DATABASEACCOUNTS/ACC1/TABLES/TABLE1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := TableID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/private_endpoint_resource.go b/internal/services/network/private_endpoint_resource.go index 4fb247487a0f..f9f30481e6a4 100644 --- a/internal/services/network/private_endpoint_resource.go +++ b/internal/services/network/private_endpoint_resource.go @@ -19,6 +19,7 @@ import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" mariadbServers "github.com/hashicorp/go-azure-sdk/resource-manager/mariadb/2018-06-01/servers" "github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2017-12-01/servers" "github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-01-01/privatednszonegroups" @@ -33,7 +34,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" - cosmosParse "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" @@ -446,7 +446,7 @@ func getCosmosDbResIdInPrivateServiceConnections(p *privateendpoints.PrivateEndp continue } id := *l.Properties.PrivateLinkServiceId - if _, err := cosmosParse.DatabaseAccountID(id); err == nil { + if _, err := cosmosdb.ParseDatabaseAccountID(id); err == nil { _, ok := exists[id] if !ok { ids = append(ids, id) @@ -459,7 +459,7 @@ func getCosmosDbResIdInPrivateServiceConnections(p *privateendpoints.PrivateEndp continue } id := *l.Properties.PrivateLinkServiceId - if _, err := cosmosParse.DatabaseAccountID(id); err == nil { + if _, err := cosmosdb.ParseDatabaseAccountID(id); err == nil { _, ok := exists[id] if !ok { ids = append(ids, id) diff --git a/internal/services/springcloud/spring_cloud_app_cosmosdb_association_resource.go b/internal/services/springcloud/spring_cloud_app_cosmosdb_association_resource.go index 34b0f43961d5..6f2510a30fc0 100644 --- a/internal/services/springcloud/spring_cloud_app_cosmosdb_association_resource.go +++ b/internal/services/springcloud/spring_cloud_app_cosmosdb_association_resource.go @@ -9,6 +9,7 @@ import ( "time" "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/features" @@ -81,7 +82,7 @@ func resourceSpringCloudAppCosmosDBAssociation() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: cosmosValidate.DatabaseAccountID, + ValidateFunc: cosmosdb.ValidateDatabaseAccountID, }, "api_type": { diff --git a/internal/services/streamanalytics/stream_analytics_output_cosmosdb_resource.go b/internal/services/streamanalytics/stream_analytics_output_cosmosdb_resource.go index 0f17a3d2a487..5882ffc2c23a 100644 --- a/internal/services/streamanalytics/stream_analytics_output_cosmosdb_resource.go +++ b/internal/services/streamanalytics/stream_analytics_output_cosmosdb_resource.go @@ -10,12 +10,11 @@ import ( "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" "github.com/hashicorp/go-azure-sdk/resource-manager/streamanalytics/2020-03-01/streamingjobs" "github.com/hashicorp/go-azure-sdk/resource-manager/streamanalytics/2021-10-01-preview/outputs" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" - cosmosParse "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/parse" - cosmosValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/services/streamanalytics/migration" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -65,7 +64,7 @@ func (r OutputCosmosDBResource) Arguments() map[string]*pluginsdk.Schema { "cosmosdb_sql_database_id": { Type: pluginsdk.TypeString, Required: true, - ValidateFunc: cosmosValidate.SqlDatabaseID, + ValidateFunc: cosmosdb.ValidateSqlDatabaseID, }, "container_name": { @@ -137,7 +136,7 @@ func (r OutputCosmosDBResource) Create() sdk.ResourceFunc { return metadata.ResourceRequiresImport(r.ResourceType(), id) } - databaseId, err := cosmosParse.SqlDatabaseID(model.Database) + databaseId, err := cosmosdb.ParseSqlDatabaseID(model.Database) if err != nil { return err } @@ -145,7 +144,7 @@ func (r OutputCosmosDBResource) Create() sdk.ResourceFunc { documentDbOutputProps := &outputs.DocumentDbOutputDataSourceProperties{ AccountId: pointer.To(databaseId.DatabaseAccountName), AccountKey: pointer.To(model.AccountKey), - Database: pointer.To(databaseId.Name), + Database: pointer.To(databaseId.SqlDatabaseName), CollectionNamePattern: pointer.To(model.ContainerName), DocumentId: pointer.To(model.DocumentID), PartitionKey: pointer.To(model.PartitionKey), @@ -206,7 +205,7 @@ func (r OutputCosmosDBResource) Read() sdk.ResourceFunc { state.AccountKey = metadata.ResourceData.Get("cosmosdb_account_key").(string) - databaseId := cosmosParse.NewSqlDatabaseID(id.SubscriptionId, id.ResourceGroupName, *output.Properties.AccountId, *output.Properties.Database) + databaseId := cosmosdb.NewSqlDatabaseID(id.SubscriptionId, id.ResourceGroupName, *output.Properties.AccountId, *output.Properties.Database) state.Database = databaseId.ID() collectionName := "" @@ -278,7 +277,7 @@ func (r OutputCosmosDBResource) Update() sdk.ResourceFunc { return fmt.Errorf("decoding %+v", err) } - databaseId, err := cosmosParse.SqlDatabaseID(state.Database) + databaseId, err := cosmosdb.ParseSqlDatabaseID(state.Database) if err != nil { return err } @@ -289,7 +288,7 @@ func (r OutputCosmosDBResource) Update() sdk.ResourceFunc { Datasource: outputs.DocumentDbOutputDataSource{ Properties: &outputs.DocumentDbOutputDataSourceProperties{ AccountKey: &state.AccountKey, - Database: &databaseId.Name, + Database: &databaseId.SqlDatabaseName, CollectionNamePattern: &state.ContainerName, DocumentId: &state.DocumentID, PartitionKey: &state.PartitionKey, From 35414bfed016d71a42961d85714b090571b8b53c Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:41:06 -0600 Subject: [PATCH 21/25] `cosmos` - misc `azure-sdk-for-go` removal --- .../cosmos/common/autoscale_settings.go | 58 ------------------- internal/services/cosmos/common/schema.go | 16 ++--- internal/services/cosmos/common/throughput.go | 50 +--------------- 3 files changed, 10 insertions(+), 114 deletions(-) diff --git a/internal/services/cosmos/common/autoscale_settings.go b/internal/services/cosmos/common/autoscale_settings.go index cba06729aedc..85bb3fcf492f 100644 --- a/internal/services/cosmos/common/autoscale_settings.go +++ b/internal/services/cosmos/common/autoscale_settings.go @@ -6,29 +6,11 @@ package common import ( "log" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb" // nolint: staticcheck "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) -func ExpandCosmosDbAutoscaleSettingsLegacy(d *pluginsdk.ResourceData) *documentdb.AutoscaleSettings { - i := d.Get("autoscale_settings").([]interface{}) - if len(i) == 0 || i[0] == nil { - log.Printf("[DEBUG] Cosmos DB autoscale settings are not set on the resource") - return nil - } - input := i[0].(map[string]interface{}) - - autoscaleSettings := documentdb.AutoscaleSettings{} - - if maxThroughput, ok := input["max_throughput"].(int); ok { - autoscaleSettings.MaxThroughput = pointer.To(int32(maxThroughput)) - } - - return &autoscaleSettings -} - func ExpandCosmosDbAutoscaleSettings(d *pluginsdk.ResourceData) *cosmosdb.AutoScaleSettings { i := d.Get("autoscale_settings").([]interface{}) if len(i) == 0 || i[0] == nil { @@ -46,34 +28,6 @@ func ExpandCosmosDbAutoscaleSettings(d *pluginsdk.ResourceData) *cosmosdb.AutoSc return &autoscaleSettings } -func FlattenCosmosDbAutoscaleSettingsLegacy(throughputResponse documentdb.ThroughputSettingsGetResults) []interface{} { - results := make([]interface{}, 0) - - props := throughputResponse.ThroughputSettingsGetProperties - if props == nil { - return results - } - - res := props.Resource - if res == nil { - return results - } - - autoscaleSettings := res.AutoscaleSettings - if autoscaleSettings == nil { - log.Printf("[DEBUG] Cosmos DB autoscale settings are not set on the throughput response") - return results - } - - result := make(map[string]interface{}) - - if autoscaleSettings.MaxThroughput != nil { - result["max_throughput"] = autoscaleSettings.MaxThroughput - } - - return append(results, result) -} - func FlattenCosmosDbAutoscaleSettings(throughputResponse cosmosdb.ThroughputSettingsGetResults) []interface{} { results := make([]interface{}, 0) @@ -100,18 +54,6 @@ func FlattenCosmosDbAutoscaleSettings(throughputResponse cosmosdb.ThroughputSett return append(results, result) } -func ExpandCosmosDbAutoscaleSettingsResourceLegacy(d *pluginsdk.ResourceData) *documentdb.AutoscaleSettingsResource { - autoscaleSettings := ExpandCosmosDbAutoscaleSettingsLegacy(d) - - if autoscaleSettings == nil { - return nil - } - - return &documentdb.AutoscaleSettingsResource{ - MaxThroughput: autoscaleSettings.MaxThroughput, - } -} - func ExpandCosmosDbAutoscaleSettingsResource(d *pluginsdk.ResourceData) *cosmosdb.AutoscaleSettingsResource { autoscaleSettings := ExpandCosmosDbAutoscaleSettings(d) diff --git a/internal/services/cosmos/common/schema.go b/internal/services/cosmos/common/schema.go index c620cca2ba6e..b329487fab5c 100644 --- a/internal/services/cosmos/common/schema.go +++ b/internal/services/cosmos/common/schema.go @@ -4,7 +4,7 @@ package common import ( - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb" // nolint: staticcheck + "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/suppress" @@ -109,10 +109,10 @@ func CosmosDbIndexingPolicySchema() *pluginsdk.Schema { "indexing_mode": { Type: pluginsdk.TypeString, Optional: true, - Default: documentdb.IndexingModeConsistent, + Default: cosmosdb.IndexingModeConsistent, ValidateFunc: validation.StringInSlice([]string{ - string(documentdb.IndexingModeConsistent), - string(documentdb.IndexingModeNone), + string(cosmosdb.IndexingModeConsistent), + string(cosmosdb.IndexingModeNone), }, false), }, @@ -163,8 +163,8 @@ func ConflictResolutionPolicy() *pluginsdk.Schema { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(documentdb.ConflictResolutionModeLastWriterWins), - string(documentdb.ConflictResolutionModeCustom), + string(cosmosdb.ConflictResolutionModeLastWriterWins), + string(cosmosdb.ConflictResolutionModeCustom), }, false), }, @@ -208,8 +208,8 @@ func CosmosDbIndexingPolicyCompositeIndexSchema() *pluginsdk.Schema { // Workaround for Azure/azure-rest-api-specs#11222 DiffSuppressFunc: suppress.CaseDifference, ValidateFunc: validation.StringInSlice([]string{ - string(documentdb.CompositePathSortOrderAscending), - string(documentdb.CompositePathSortOrderDescending), + string(cosmosdb.CompositePathSortOrderAscending), + string(cosmosdb.CompositePathSortOrderDescending), }, true), }, }, diff --git a/internal/services/cosmos/common/throughput.go b/internal/services/cosmos/common/throughput.go index f05bb3ddf660..6e79607c733a 100644 --- a/internal/services/cosmos/common/throughput.go +++ b/internal/services/cosmos/common/throughput.go @@ -6,26 +6,11 @@ package common import ( "fmt" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb" // nolint: staticcheck "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) -func GetThroughputFromResultLegacy(throughputResponse documentdb.ThroughputSettingsGetResults) *int32 { - props := throughputResponse.ThroughputSettingsGetProperties - if props == nil { - return nil - } - - res := props.Resource - if res == nil { - return nil - } - - return res.Throughput -} - func GetThroughputFromResult(throughputResponse cosmosdb.ThroughputSettingsGetResults) *int64 { props := throughputResponse.Properties if props == nil { @@ -40,35 +25,11 @@ func GetThroughputFromResult(throughputResponse cosmosdb.ThroughputSettingsGetRe return res.Throughput } -func ConvertThroughputFromResourceDataLegacy(throughput interface{}) *int32 { - return pointer.To(int32(throughput.(int))) -} - func ConvertThroughputFromResourceData(throughput interface{}) *int64 { return pointer.To(int64(throughput.(int))) } -func ExpandCosmosDBThroughputSettingsUpdateParametersLegacy(d *pluginsdk.ResourceData) *documentdb.ThroughputSettingsUpdateParameters { - throughputParameters := documentdb.ThroughputSettingsUpdateParameters{ - ThroughputSettingsUpdateProperties: &documentdb.ThroughputSettingsUpdateProperties{ - Resource: &documentdb.ThroughputSettingsResource{}, - }, - } - - if v, exists := d.GetOk("throughput"); exists { - throughputParameters.Resource.Throughput = ConvertThroughputFromResourceDataLegacy(v) - } - - if _, hasAutoscaleSettings := d.GetOk("autoscale_settings"); hasAutoscaleSettings { - // If updating the autoscale throughput, set the manual throughput to nil to ensure the autoscale throughput is applied - throughputParameters.Resource.Throughput = nil - throughputParameters.Resource.AutoscaleSettings = ExpandCosmosDbAutoscaleSettingsResourceLegacy(d) - } - - return &throughputParameters -} - -func ExpandCosmosDBThroughputSettingsUpdateParameters(d *pluginsdk.ResourceData) *cosmosdb.ThroughputSettingsUpdateParameters { +func ExpandCosmosDBThroughputSettingsUpdateParameters(d *pluginsdk.ResourceData) cosmosdb.ThroughputSettingsUpdateParameters { throughputParameters := cosmosdb.ThroughputSettingsUpdateParameters{ Properties: cosmosdb.ThroughputSettingsUpdateProperties{ Resource: cosmosdb.ThroughputSettingsResource{}, @@ -85,14 +46,7 @@ func ExpandCosmosDBThroughputSettingsUpdateParameters(d *pluginsdk.ResourceData) throughputParameters.Properties.Resource.AutoScaleSettings = ExpandCosmosDbAutoscaleSettingsResource(d) } - return &throughputParameters -} - -func SetResourceDataThroughputFromResponseLegacy(throughputResponse documentdb.ThroughputSettingsGetResults, d *pluginsdk.ResourceData) { - d.Set("throughput", GetThroughputFromResultLegacy(throughputResponse)) - - autoscaleSettings := FlattenCosmosDbAutoscaleSettingsLegacy(throughputResponse) - d.Set("autoscale_settings", autoscaleSettings) + return throughputParameters } func SetResourceDataThroughputFromResponse(throughputResponse cosmosdb.ThroughputSettingsGetResults, d *pluginsdk.ResourceData) { From a013bba9f475d17052f1b0690484e90baf4b6b1f Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:42:25 -0600 Subject: [PATCH 22/25] go mod tidy && go mod vendor --- .../mgmt/2021-10-15/documentdb/CHANGELOG.md | 7 - .../mgmt/2021-10-15/documentdb/_meta.json | 11 - .../documentdb/cassandraclusters.go | 937 -- .../documentdb/cassandradatacenters.go | 517 - .../documentdb/cassandraresources.go | 1573 --- .../mgmt/2021-10-15/documentdb/client.go | 43 - .../mgmt/2021-10-15/documentdb/collection.go | 320 - .../documentdb/collectionpartition.go | 228 - .../documentdb/collectionpartitionregion.go | 133 - .../2021-10-15/documentdb/collectionregion.go | 133 - .../mgmt/2021-10-15/documentdb/database.go | 314 - .../documentdb/databaseaccountregion.go | 128 - .../2021-10-15/documentdb/databaseaccounts.go | 1680 --- .../mgmt/2021-10-15/documentdb/enums.go | 664 - .../2021-10-15/documentdb/gremlinresources.go | 1577 --- .../mgmt/2021-10-15/documentdb/locations.go | 189 - .../mgmt/2021-10-15/documentdb/models.go | 11405 ---------------- .../2021-10-15/documentdb/mongodbresources.go | 1672 --- .../documentdb/notebookworkspaces.go | 674 - .../mgmt/2021-10-15/documentdb/operations.go | 140 - .../documentdb/partitionkeyrangeid.go | 132 - .../documentdb/partitionkeyrangeidregion.go | 134 - .../mgmt/2021-10-15/documentdb/percentile.go | 126 - .../documentdb/percentilesourcetarget.go | 133 - .../2021-10-15/documentdb/percentiletarget.go | 130 - .../documentdb/privateendpointconnections.go | 402 - .../documentdb/privatelinkresources.go | 213 - .../documentdb/restorabledatabaseaccounts.go | 275 - .../restorablemongodbcollections.go | 122 - .../documentdb/restorablemongodbdatabases.go | 117 - .../documentdb/restorablemongodbresources.go | 125 - .../documentdb/restorablesqlcontainers.go | 129 - .../documentdb/restorablesqldatabases.go | 117 - .../documentdb/restorablesqlresources.go | 125 - .../2021-10-15/documentdb/sqlresources.go | 3586 ----- .../2021-10-15/documentdb/tableresources.go | 791 -- .../mgmt/2021-10-15/documentdb/version.go | 19 - .../cosmosdb/2024-08-15/rbacs/README.md | 142 + .../cosmosdb/2024-08-15/rbacs/client.go | 26 + .../cosmosdb/2024-08-15/rbacs/constants.go | 51 + .../cosmosdb/2024-08-15/rbacs/id_account.go | 139 + .../2024-08-15/rbacs/id_databaseaccount.go | 130 + .../2024-08-15/rbacs/id_sqlroledefinition.go | 139 + ...lresourcescreateupdatesqlroleassignment.go | 75 + ...lresourcescreateupdatesqlroledefinition.go | 75 + ...hod_sqlresourcesdeletesqlroleassignment.go | 71 + ...hod_sqlresourcesdeletesqlroledefinition.go | 71 + ...method_sqlresourcesgetsqlroleassignment.go | 53 + ...method_sqlresourcesgetsqlroledefinition.go | 53 + ...thod_sqlresourceslistsqlroleassignments.go | 54 + ...thod_sqlresourceslistsqlroledefinitions.go | 54 + .../2024-08-15/rbacs/model_permission.go | 9 + ...sqlroleassignmentcreateupdateparameters.go | 8 + .../model_sqlroleassignmentgetresults.go | 11 + .../model_sqlroleassignmentlistresult.go | 8 + .../rbacs/model_sqlroleassignmentresource.go | 10 + ...sqlroledefinitioncreateupdateparameters.go | 8 + .../model_sqlroledefinitiongetresults.go | 11 + .../model_sqlroledefinitionlistresult.go | 8 + .../rbacs/model_sqlroledefinitionresource.go | 11 + .../cosmosdb/2024-08-15/rbacs/version.go | 10 + .../cosmosdb/2024-08-15/restorables/README.md | 313 + .../cosmosdb/2024-08-15/restorables/client.go | 26 + .../2024-08-15/restorables/constants.go | 468 + .../2024-08-15/restorables/id_container.go | 148 + .../2024-08-15/restorables/id_graph.go | 148 + .../2024-08-15/restorables/id_location.go | 121 + .../id_mongodbdatabasecollection.go | 148 + .../id_restorabledatabaseaccount.go | 130 + .../2024-08-15/restorables/id_table.go | 139 + ...rcesretrievecontinuousbackupinformation.go | 75 + ...rcesretrievecontinuousbackupinformation.go | 75 + ...restorabledatabaseaccountsgetbylocation.go | 53 + .../method_restorabledatabaseaccountslist.go | 55 + ...estorabledatabaseaccountslistbylocation.go | 54 + .../method_restorablegremlindatabaseslist.go | 54 + .../method_restorablegremlingraphslist.go | 91 + .../method_restorablegremlinresourceslist.go | 87 + ...method_restorablemongodbcollectionslist.go | 91 + .../method_restorablemongodbdatabaseslist.go | 54 + .../method_restorablemongodbresourceslist.go | 87 + .../method_restorablesqlcontainerslist.go | 91 + .../method_restorablesqldatabaseslist.go | 54 + .../method_restorablesqlresourceslist.go | 87 + .../method_restorabletableresourceslist.go | 87 + .../method_restorabletableslist.go | 87 + ...rcesretrievecontinuousbackupinformation.go | 75 + ...rcesretrievecontinuousbackupinformation.go | 75 + .../restorables/model_backupinformation.go | 8 + .../model_clientencryptionincludedpath.go | 11 + .../model_clientencryptionpolicy.go | 9 + .../restorables/model_compositepath.go | 9 + .../restorables/model_computedproperty.go | 9 + .../model_conflictresolutionpolicy.go | 10 + .../model_containerpartitionkey.go | 11 + .../model_continuousbackupinformation.go | 8 + .../model_continuousbackuprestorelocation.go | 8 + .../restorables/model_excludedpath.go | 8 + .../restorables/model_includedpath.go | 9 + .../2024-08-15/restorables/model_indexes.go | 10 + .../restorables/model_indexingpolicy.go | 13 + ...odel_restorabledatabaseaccountgetresult.go | 12 + ...del_restorabledatabaseaccountproperties.go | 55 + ...el_restorabledatabaseaccountslistresult.go | 8 + ...odel_restorablegremlindatabasegetresult.go | 11 + ...del_restorablegremlindatabaseproperties.go | 8 + ...orablegremlindatabasepropertiesresource.go | 14 + ...el_restorablegremlindatabaseslistresult.go | 8 + .../model_restorablegremlingraphgetresult.go | 11 + .../model_restorablegremlingraphproperties.go | 8 + ...estorablegremlingraphpropertiesresource.go | 14 + ...model_restorablegremlingraphslistresult.go | 8 + ...del_restorablegremlinresourcesgetresult.go | 12 + ...el_restorablegremlinresourceslistresult.go | 8 + .../model_restorablelocationresource.go | 41 + ...el_restorablemongodbcollectiongetresult.go | 11 + ...l_restorablemongodbcollectionproperties.go | 8 + ...ablemongodbcollectionpropertiesresource.go | 14 + ..._restorablemongodbcollectionslistresult.go | 8 + ...odel_restorablemongodbdatabasegetresult.go | 11 + ...del_restorablemongodbdatabaseproperties.go | 8 + ...orablemongodbdatabasepropertiesresource.go | 14 + ...el_restorablemongodbdatabaseslistresult.go | 8 + ...del_restorablemongodbresourcesgetresult.go | 12 + ...el_restorablemongodbresourceslistresult.go | 8 + .../model_restorablesqlcontainergetresult.go | 11 + .../model_restorablesqlcontainerproperties.go | 8 + ...estorablesqlcontainerpropertiesresource.go | 15 + ...sqlcontainerpropertiesresourcecontainer.go | 22 + ...model_restorablesqlcontainerslistresult.go | 8 + .../model_restorablesqldatabasegetresult.go | 11 + .../model_restorablesqldatabaseproperties.go | 8 + ...restorablesqldatabasepropertiesresource.go | 15 + ...lesqldatabasepropertiesresourcedatabase.go | 16 + .../model_restorablesqldatabaseslistresult.go | 8 + .../model_restorablesqlresourcesgetresult.go | 12 + .../model_restorablesqlresourceslistresult.go | 8 + .../model_restorabletablegetresult.go | 11 + .../model_restorabletableproperties.go | 8 + ...model_restorabletablepropertiesresource.go | 14 + ...model_restorabletableresourcesgetresult.go | 10 + ...odel_restorabletableresourceslistresult.go | 8 + .../model_restorabletableslistresult.go | 8 + .../model_restoreparametersbase.go | 28 + .../restorables/model_spatialspec.go | 9 + .../2024-08-15/restorables/model_uniquekey.go | 8 + .../restorables/model_uniquekeypolicy.go | 8 + .../2024-08-15/restorables/version.go | 10 + vendor/modules.txt | 3 +- 149 files changed, 4909 insertions(+), 29022 deletions(-) delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/CHANGELOG.md delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/_meta.json delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/cassandraclusters.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/cassandradatacenters.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/cassandraresources.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/client.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/collection.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/collectionpartition.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/collectionpartitionregion.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/collectionregion.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/database.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/databaseaccountregion.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/databaseaccounts.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/enums.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/gremlinresources.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/locations.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/models.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/mongodbresources.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/notebookworkspaces.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/operations.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/partitionkeyrangeid.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/partitionkeyrangeidregion.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/percentile.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/percentilesourcetarget.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/percentiletarget.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/privateendpointconnections.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/privatelinkresources.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorabledatabaseaccounts.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablemongodbcollections.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablemongodbdatabases.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablemongodbresources.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablesqlcontainers.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablesqldatabases.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablesqlresources.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/sqlresources.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/tableresources.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/version.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/id_account.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/id_databaseaccount.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/id_sqlroledefinition.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourcescreateupdatesqlroleassignment.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourcescreateupdatesqlroledefinition.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourcesdeletesqlroleassignment.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourcesdeletesqlroledefinition.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourcesgetsqlroleassignment.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourcesgetsqlroledefinition.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourceslistsqlroleassignments.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourceslistsqlroledefinitions.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_permission.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroleassignmentcreateupdateparameters.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroleassignmentgetresults.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroleassignmentlistresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroleassignmentresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroledefinitioncreateupdateparameters.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroledefinitiongetresults.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroledefinitionlistresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroledefinitionresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/version.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/id_container.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/id_graph.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/id_location.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/id_mongodbdatabasecollection.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/id_restorabledatabaseaccount.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/id_table.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_gremlinresourcesretrievecontinuousbackupinformation.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_mongodbresourcesretrievecontinuousbackupinformation.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorabledatabaseaccountsgetbylocation.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorabledatabaseaccountslist.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorabledatabaseaccountslistbylocation.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablegremlindatabaseslist.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablegremlingraphslist.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablegremlinresourceslist.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablemongodbcollectionslist.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablemongodbdatabaseslist.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablemongodbresourceslist.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablesqlcontainerslist.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablesqldatabaseslist.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablesqlresourceslist.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorabletableresourceslist.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorabletableslist.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_sqlresourcesretrievecontinuousbackupinformation.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_tableresourcesretrievecontinuousbackupinformation.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_backupinformation.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_clientencryptionincludedpath.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_clientencryptionpolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_compositepath.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_computedproperty.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_conflictresolutionpolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_containerpartitionkey.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_continuousbackupinformation.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_continuousbackuprestorelocation.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_excludedpath.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_includedpath.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_indexes.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_indexingpolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabledatabaseaccountgetresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabledatabaseaccountproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabledatabaseaccountslistresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlindatabasegetresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlindatabaseproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlindatabasepropertiesresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlindatabaseslistresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlingraphgetresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlingraphproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlingraphpropertiesresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlingraphslistresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlinresourcesgetresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlinresourceslistresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablelocationresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbcollectiongetresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbcollectionproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbcollectionpropertiesresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbcollectionslistresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbdatabasegetresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbdatabaseproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbdatabasepropertiesresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbdatabaseslistresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbresourcesgetresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbresourceslistresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqlcontainergetresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqlcontainerproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqlcontainerpropertiesresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqlcontainerpropertiesresourcecontainer.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqlcontainerslistresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqldatabasegetresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqldatabaseproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqldatabasepropertiesresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqldatabasepropertiesresourcedatabase.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqldatabaseslistresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqlresourcesgetresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqlresourceslistresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabletablegetresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabletableproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabletablepropertiesresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabletableresourcesgetresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabletableresourceslistresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabletableslistresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restoreparametersbase.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_spatialspec.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_uniquekey.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_uniquekeypolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/version.go diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/CHANGELOG.md b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/CHANGELOG.md deleted file mode 100644 index abd124fe80c1..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/CHANGELOG.md +++ /dev/null @@ -1,7 +0,0 @@ -# Change History - -## Additive Changes - -### New Constants - -1. ServerVersion.ServerVersionFourFullStopTwo diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/_meta.json b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/_meta.json deleted file mode 100644 index 07cc90fbc01c..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/_meta.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "commit": "50ed15bd61ac79f2368d769df0c207a00b9e099f", - "readme": "/_/azure-rest-api-specs/specification/cosmos-db/resource-manager/readme.md", - "tag": "package-2021-10", - "use": "@microsoft.azure/autorest.go@2.1.187", - "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-2021-10 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix /_/azure-rest-api-specs/specification/cosmos-db/resource-manager/readme.md", - "additional_properties": { - "additional_options": "--go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix" - } -} \ No newline at end of file diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/cassandraclusters.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/cassandraclusters.go deleted file mode 100644 index 94e76d8cae92..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/cassandraclusters.go +++ /dev/null @@ -1,937 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// CassandraClustersClient is the client for the CassandraClusters methods of the Documentdb service. -type CassandraClustersClient struct { - BaseClient -} - -// NewCassandraClustersClient creates an instance of the CassandraClustersClient client. -func NewCassandraClustersClient(subscriptionID string) CassandraClustersClient { - return NewCassandraClustersClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewCassandraClustersClientWithBaseURI creates an instance of the CassandraClustersClient client using a custom -// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure -// stack). -func NewCassandraClustersClientWithBaseURI(baseURI string, subscriptionID string) CassandraClustersClient { - return CassandraClustersClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateUpdate create or update a managed Cassandra cluster. When updating, you must specify all writable properties. -// To update only some properties, use PATCH. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// clusterName - managed Cassandra cluster name. -// body - the properties specifying the desired state of the managed Cassandra cluster. -func (client CassandraClustersClient) CreateUpdate(ctx context.Context, resourceGroupName string, clusterName string, body ClusterResource) (result CassandraClustersCreateUpdateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.CreateUpdate") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: clusterName, - Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, - {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraClustersClient", "CreateUpdate", err.Error()) - } - - req, err := client.CreateUpdatePreparer(ctx, resourceGroupName, clusterName, body) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "CreateUpdate", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "CreateUpdate", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdatePreparer prepares the CreateUpdate request. -func (client CassandraClustersClient) CreateUpdatePreparer(ctx context.Context, resourceGroupName string, clusterName string, body ClusterResource) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "clusterName": autorest.Encode("path", clusterName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}", pathParameters), - autorest.WithJSON(body), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateUpdateSender sends the CreateUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraClustersClient) CreateUpdateSender(req *http.Request) (future CassandraClustersCreateUpdateFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// CreateUpdateResponder handles the response to the CreateUpdate request. The method always -// closes the http.Response Body. -func (client CassandraClustersClient) CreateUpdateResponder(resp *http.Response) (result ClusterResource, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Deallocate deallocate the Managed Cassandra Cluster and Associated Data Centers. Deallocation will deallocate the -// host virtual machine of this cluster, and reserved the data disk. This won't do anything on an already deallocated -// cluster. Use Start to restart the cluster. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// clusterName - managed Cassandra cluster name. -func (client CassandraClustersClient) Deallocate(ctx context.Context, resourceGroupName string, clusterName string) (result CassandraClustersDeallocateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.Deallocate") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: clusterName, - Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, - {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraClustersClient", "Deallocate", err.Error()) - } - - req, err := client.DeallocatePreparer(ctx, resourceGroupName, clusterName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Deallocate", nil, "Failure preparing request") - return - } - - result, err = client.DeallocateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Deallocate", result.Response(), "Failure sending request") - return - } - - return -} - -// DeallocatePreparer prepares the Deallocate request. -func (client CassandraClustersClient) DeallocatePreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "clusterName": autorest.Encode("path", clusterName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/deallocate", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeallocateSender sends the Deallocate request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraClustersClient) DeallocateSender(req *http.Request) (future CassandraClustersDeallocateFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeallocateResponder handles the response to the Deallocate request. The method always -// closes the http.Response Body. -func (client CassandraClustersClient) DeallocateResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByClosing()) - result.Response = resp - return -} - -// Delete deletes a managed Cassandra cluster. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// clusterName - managed Cassandra cluster name. -func (client CassandraClustersClient) Delete(ctx context.Context, resourceGroupName string, clusterName string) (result CassandraClustersDeleteFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.Delete") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: clusterName, - Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, - {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraClustersClient", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, clusterName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Delete", result.Response(), "Failure sending request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client CassandraClustersClient) DeletePreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "clusterName": autorest.Encode("path", clusterName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraClustersClient) DeleteSender(req *http.Request) (future CassandraClustersDeleteFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client CassandraClustersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get get the properties of a managed Cassandra cluster. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// clusterName - managed Cassandra cluster name. -func (client CassandraClustersClient) Get(ctx context.Context, resourceGroupName string, clusterName string) (result ClusterResource, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: clusterName, - Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, - {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraClustersClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, clusterName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client CassandraClustersClient) GetPreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "clusterName": autorest.Encode("path", clusterName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraClustersClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client CassandraClustersClient) GetResponder(resp *http.Response) (result ClusterResource, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// InvokeCommand invoke a command like nodetool for cassandra maintenance -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// clusterName - managed Cassandra cluster name. -// body - specification which command to run where -func (client CassandraClustersClient) InvokeCommand(ctx context.Context, resourceGroupName string, clusterName string, body CommandPostBody) (result CassandraClustersInvokeCommandFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.InvokeCommand") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: clusterName, - Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, - {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$`, Chain: nil}}}, - {TargetValue: body, - Constraints: []validation.Constraint{{Target: "body.Command", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "body.Host", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraClustersClient", "InvokeCommand", err.Error()) - } - - req, err := client.InvokeCommandPreparer(ctx, resourceGroupName, clusterName, body) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "InvokeCommand", nil, "Failure preparing request") - return - } - - result, err = client.InvokeCommandSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "InvokeCommand", result.Response(), "Failure sending request") - return - } - - return -} - -// InvokeCommandPreparer prepares the InvokeCommand request. -func (client CassandraClustersClient) InvokeCommandPreparer(ctx context.Context, resourceGroupName string, clusterName string, body CommandPostBody) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "clusterName": autorest.Encode("path", clusterName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/invokeCommand", pathParameters), - autorest.WithJSON(body), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// InvokeCommandSender sends the InvokeCommand request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraClustersClient) InvokeCommandSender(req *http.Request) (future CassandraClustersInvokeCommandFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// InvokeCommandResponder handles the response to the InvokeCommand request. The method always -// closes the http.Response Body. -func (client CassandraClustersClient) InvokeCommandResponder(resp *http.Response) (result CommandOutput, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListByResourceGroup list all managed Cassandra clusters in this resource group. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -func (client CassandraClustersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ListClusters, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.ListByResourceGroup") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraClustersClient", "ListByResourceGroup", err.Error()) - } - - req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp, err := client.ListByResourceGroupSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListByResourceGroup", resp, "Failure sending request") - return - } - - result, err = client.ListByResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListByResourceGroup", resp, "Failure responding to request") - return - } - - return -} - -// ListByResourceGroupPreparer prepares the ListByResourceGroup request. -func (client CassandraClustersClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraClustersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (client CassandraClustersClient) ListByResourceGroupResponder(resp *http.Response) (result ListClusters, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListBySubscription list all managed Cassandra clusters in this subscription. -func (client CassandraClustersClient) ListBySubscription(ctx context.Context) (result ListClusters, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.ListBySubscription") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraClustersClient", "ListBySubscription", err.Error()) - } - - req, err := client.ListBySubscriptionPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp, err := client.ListBySubscriptionSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListBySubscription", resp, "Failure sending request") - return - } - - result, err = client.ListBySubscriptionResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "ListBySubscription", resp, "Failure responding to request") - return - } - - return -} - -// ListBySubscriptionPreparer prepares the ListBySubscription request. -func (client CassandraClustersClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/cassandraClusters", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListBySubscriptionSender sends the ListBySubscription request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraClustersClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always -// closes the http.Response Body. -func (client CassandraClustersClient) ListBySubscriptionResponder(resp *http.Response) (result ListClusters, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Start start the Managed Cassandra Cluster and Associated Data Centers. Start will start the host virtual machine of -// this cluster with reserved data disk. This won't do anything on an already running cluster. Use Deallocate to -// deallocate the cluster. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// clusterName - managed Cassandra cluster name. -func (client CassandraClustersClient) Start(ctx context.Context, resourceGroupName string, clusterName string) (result CassandraClustersStartFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.Start") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: clusterName, - Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, - {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraClustersClient", "Start", err.Error()) - } - - req, err := client.StartPreparer(ctx, resourceGroupName, clusterName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Start", nil, "Failure preparing request") - return - } - - result, err = client.StartSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Start", result.Response(), "Failure sending request") - return - } - - return -} - -// StartPreparer prepares the Start request. -func (client CassandraClustersClient) StartPreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "clusterName": autorest.Encode("path", clusterName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/start", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// StartSender sends the Start request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraClustersClient) StartSender(req *http.Request) (future CassandraClustersStartFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// StartResponder handles the response to the Start request. The method always -// closes the http.Response Body. -func (client CassandraClustersClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByClosing()) - result.Response = resp - return -} - -// Status gets the CPU, memory, and disk usage statistics for each Cassandra node in a cluster. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// clusterName - managed Cassandra cluster name. -func (client CassandraClustersClient) Status(ctx context.Context, resourceGroupName string, clusterName string) (result CassandraClusterPublicStatus, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.Status") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: clusterName, - Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, - {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraClustersClient", "Status", err.Error()) - } - - req, err := client.StatusPreparer(ctx, resourceGroupName, clusterName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Status", nil, "Failure preparing request") - return - } - - resp, err := client.StatusSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Status", resp, "Failure sending request") - return - } - - result, err = client.StatusResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Status", resp, "Failure responding to request") - return - } - - return -} - -// StatusPreparer prepares the Status request. -func (client CassandraClustersClient) StatusPreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "clusterName": autorest.Encode("path", clusterName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/status", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// StatusSender sends the Status request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraClustersClient) StatusSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// StatusResponder handles the response to the Status request. The method always -// closes the http.Response Body. -func (client CassandraClustersClient) StatusResponder(resp *http.Response) (result CassandraClusterPublicStatus, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Update updates some of the properties of a managed Cassandra cluster. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// clusterName - managed Cassandra cluster name. -// body - parameters to provide for specifying the managed Cassandra cluster. -func (client CassandraClustersClient) Update(ctx context.Context, resourceGroupName string, clusterName string, body ClusterResource) (result CassandraClustersUpdateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraClustersClient.Update") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: clusterName, - Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, - {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraClustersClient", "Update", err.Error()) - } - - req, err := client.UpdatePreparer(ctx, resourceGroupName, clusterName, body) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Update", nil, "Failure preparing request") - return - } - - result, err = client.UpdateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersClient", "Update", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdatePreparer prepares the Update request. -func (client CassandraClustersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, clusterName string, body ClusterResource) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "clusterName": autorest.Encode("path", clusterName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}", pathParameters), - autorest.WithJSON(body), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateSender sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraClustersClient) UpdateSender(req *http.Request) (future CassandraClustersUpdateFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// UpdateResponder handles the response to the Update request. The method always -// closes the http.Response Body. -func (client CassandraClustersClient) UpdateResponder(resp *http.Response) (result ClusterResource, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/cassandradatacenters.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/cassandradatacenters.go deleted file mode 100644 index 1f857122cd73..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/cassandradatacenters.go +++ /dev/null @@ -1,517 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// CassandraDataCentersClient is the client for the CassandraDataCenters methods of the Documentdb service. -type CassandraDataCentersClient struct { - BaseClient -} - -// NewCassandraDataCentersClient creates an instance of the CassandraDataCentersClient client. -func NewCassandraDataCentersClient(subscriptionID string) CassandraDataCentersClient { - return NewCassandraDataCentersClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewCassandraDataCentersClientWithBaseURI creates an instance of the CassandraDataCentersClient client using a custom -// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure -// stack). -func NewCassandraDataCentersClientWithBaseURI(baseURI string, subscriptionID string) CassandraDataCentersClient { - return CassandraDataCentersClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateUpdate create or update a managed Cassandra data center. When updating, overwrite all properties. To update -// only some properties, use PATCH. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// clusterName - managed Cassandra cluster name. -// dataCenterName - data center name in a managed Cassandra cluster. -// body - parameters specifying the managed Cassandra data center. -func (client CassandraDataCentersClient) CreateUpdate(ctx context.Context, resourceGroupName string, clusterName string, dataCenterName string, body DataCenterResource) (result CassandraDataCentersCreateUpdateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraDataCentersClient.CreateUpdate") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: clusterName, - Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, - {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$`, Chain: nil}}}, - {TargetValue: dataCenterName, - Constraints: []validation.Constraint{{Target: "dataCenterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, - {Target: "dataCenterName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "dataCenterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraDataCentersClient", "CreateUpdate", err.Error()) - } - - req, err := client.CreateUpdatePreparer(ctx, resourceGroupName, clusterName, dataCenterName, body) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "CreateUpdate", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "CreateUpdate", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdatePreparer prepares the CreateUpdate request. -func (client CassandraDataCentersClient) CreateUpdatePreparer(ctx context.Context, resourceGroupName string, clusterName string, dataCenterName string, body DataCenterResource) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "clusterName": autorest.Encode("path", clusterName), - "dataCenterName": autorest.Encode("path", dataCenterName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}", pathParameters), - autorest.WithJSON(body), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateUpdateSender sends the CreateUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraDataCentersClient) CreateUpdateSender(req *http.Request) (future CassandraDataCentersCreateUpdateFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// CreateUpdateResponder handles the response to the CreateUpdate request. The method always -// closes the http.Response Body. -func (client CassandraDataCentersClient) CreateUpdateResponder(resp *http.Response) (result DataCenterResource, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete delete a managed Cassandra data center. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// clusterName - managed Cassandra cluster name. -// dataCenterName - data center name in a managed Cassandra cluster. -func (client CassandraDataCentersClient) Delete(ctx context.Context, resourceGroupName string, clusterName string, dataCenterName string) (result CassandraDataCentersDeleteFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraDataCentersClient.Delete") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: clusterName, - Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, - {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$`, Chain: nil}}}, - {TargetValue: dataCenterName, - Constraints: []validation.Constraint{{Target: "dataCenterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, - {Target: "dataCenterName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "dataCenterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraDataCentersClient", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, clusterName, dataCenterName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "Delete", result.Response(), "Failure sending request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client CassandraDataCentersClient) DeletePreparer(ctx context.Context, resourceGroupName string, clusterName string, dataCenterName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "clusterName": autorest.Encode("path", clusterName), - "dataCenterName": autorest.Encode("path", dataCenterName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraDataCentersClient) DeleteSender(req *http.Request) (future CassandraDataCentersDeleteFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client CassandraDataCentersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get get the properties of a managed Cassandra data center. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// clusterName - managed Cassandra cluster name. -// dataCenterName - data center name in a managed Cassandra cluster. -func (client CassandraDataCentersClient) Get(ctx context.Context, resourceGroupName string, clusterName string, dataCenterName string) (result DataCenterResource, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraDataCentersClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: clusterName, - Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, - {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$`, Chain: nil}}}, - {TargetValue: dataCenterName, - Constraints: []validation.Constraint{{Target: "dataCenterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, - {Target: "dataCenterName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "dataCenterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraDataCentersClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, clusterName, dataCenterName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client CassandraDataCentersClient) GetPreparer(ctx context.Context, resourceGroupName string, clusterName string, dataCenterName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "clusterName": autorest.Encode("path", clusterName), - "dataCenterName": autorest.Encode("path", dataCenterName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraDataCentersClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client CassandraDataCentersClient) GetResponder(resp *http.Response) (result DataCenterResource, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List list all data centers in a particular managed Cassandra cluster. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// clusterName - managed Cassandra cluster name. -func (client CassandraDataCentersClient) List(ctx context.Context, resourceGroupName string, clusterName string) (result ListDataCenters, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraDataCentersClient.List") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: clusterName, - Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, - {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraDataCentersClient", "List", err.Error()) - } - - req, err := client.ListPreparer(ctx, resourceGroupName, clusterName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "List", resp, "Failure sending request") - return - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "List", resp, "Failure responding to request") - return - } - - return -} - -// ListPreparer prepares the List request. -func (client CassandraDataCentersClient) ListPreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "clusterName": autorest.Encode("path", clusterName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraDataCentersClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client CassandraDataCentersClient) ListResponder(resp *http.Response) (result ListDataCenters, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Update update some of the properties of a managed Cassandra data center. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// clusterName - managed Cassandra cluster name. -// dataCenterName - data center name in a managed Cassandra cluster. -// body - parameters to provide for specifying the managed Cassandra data center. -func (client CassandraDataCentersClient) Update(ctx context.Context, resourceGroupName string, clusterName string, dataCenterName string, body DataCenterResource) (result CassandraDataCentersUpdateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraDataCentersClient.Update") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: clusterName, - Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, - {Target: "clusterName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "clusterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$`, Chain: nil}}}, - {TargetValue: dataCenterName, - Constraints: []validation.Constraint{{Target: "dataCenterName", Name: validation.MaxLength, Rule: 100, Chain: nil}, - {Target: "dataCenterName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "dataCenterName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraDataCentersClient", "Update", err.Error()) - } - - req, err := client.UpdatePreparer(ctx, resourceGroupName, clusterName, dataCenterName, body) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "Update", nil, "Failure preparing request") - return - } - - result, err = client.UpdateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersClient", "Update", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdatePreparer prepares the Update request. -func (client CassandraDataCentersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, clusterName string, dataCenterName string, body DataCenterResource) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "clusterName": autorest.Encode("path", clusterName), - "dataCenterName": autorest.Encode("path", dataCenterName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}", pathParameters), - autorest.WithJSON(body), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateSender sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraDataCentersClient) UpdateSender(req *http.Request) (future CassandraDataCentersUpdateFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// UpdateResponder handles the response to the Update request. The method always -// closes the http.Response Body. -func (client CassandraDataCentersClient) UpdateResponder(resp *http.Response) (result DataCenterResource, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/cassandraresources.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/cassandraresources.go deleted file mode 100644 index 2ce9e026462d..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/cassandraresources.go +++ /dev/null @@ -1,1573 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// CassandraResourcesClient is the client for the CassandraResources methods of the Documentdb service. -type CassandraResourcesClient struct { - BaseClient -} - -// NewCassandraResourcesClient creates an instance of the CassandraResourcesClient client. -func NewCassandraResourcesClient(subscriptionID string) CassandraResourcesClient { - return NewCassandraResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewCassandraResourcesClientWithBaseURI creates an instance of the CassandraResourcesClient client using a custom -// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure -// stack). -func NewCassandraResourcesClientWithBaseURI(baseURI string, subscriptionID string) CassandraResourcesClient { - return CassandraResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateUpdateCassandraKeyspace create or update an Azure Cosmos DB Cassandra keyspace -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// keyspaceName - cosmos DB keyspace name. -// createUpdateCassandraKeyspaceParameters - the parameters to provide for the current Cassandra keyspace. -func (client CassandraResourcesClient) CreateUpdateCassandraKeyspace(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, createUpdateCassandraKeyspaceParameters CassandraKeyspaceCreateUpdateParameters) (result CassandraResourcesCreateUpdateCassandraKeyspaceFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.CreateUpdateCassandraKeyspace") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: createUpdateCassandraKeyspaceParameters, - Constraints: []validation.Constraint{{Target: "createUpdateCassandraKeyspaceParameters.CassandraKeyspaceCreateUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateCassandraKeyspaceParameters.CassandraKeyspaceCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateCassandraKeyspaceParameters.CassandraKeyspaceCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraResourcesClient", "CreateUpdateCassandraKeyspace", err.Error()) - } - - req, err := client.CreateUpdateCassandraKeyspacePreparer(ctx, resourceGroupName, accountName, keyspaceName, createUpdateCassandraKeyspaceParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "CreateUpdateCassandraKeyspace", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateCassandraKeyspaceSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "CreateUpdateCassandraKeyspace", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdateCassandraKeyspacePreparer prepares the CreateUpdateCassandraKeyspace request. -func (client CassandraResourcesClient) CreateUpdateCassandraKeyspacePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, createUpdateCassandraKeyspaceParameters CassandraKeyspaceCreateUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "keyspaceName": autorest.Encode("path", keyspaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}", pathParameters), - autorest.WithJSON(createUpdateCassandraKeyspaceParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateUpdateCassandraKeyspaceSender sends the CreateUpdateCassandraKeyspace request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraResourcesClient) CreateUpdateCassandraKeyspaceSender(req *http.Request) (future CassandraResourcesCreateUpdateCassandraKeyspaceFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// CreateUpdateCassandraKeyspaceResponder handles the response to the CreateUpdateCassandraKeyspace request. The method always -// closes the http.Response Body. -func (client CassandraResourcesClient) CreateUpdateCassandraKeyspaceResponder(resp *http.Response) (result CassandraKeyspaceGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateUpdateCassandraTable create or update an Azure Cosmos DB Cassandra Table -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// keyspaceName - cosmos DB keyspace name. -// tableName - cosmos DB table name. -// createUpdateCassandraTableParameters - the parameters to provide for the current Cassandra Table. -func (client CassandraResourcesClient) CreateUpdateCassandraTable(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string, createUpdateCassandraTableParameters CassandraTableCreateUpdateParameters) (result CassandraResourcesCreateUpdateCassandraTableFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.CreateUpdateCassandraTable") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: createUpdateCassandraTableParameters, - Constraints: []validation.Constraint{{Target: "createUpdateCassandraTableParameters.CassandraTableCreateUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateCassandraTableParameters.CassandraTableCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateCassandraTableParameters.CassandraTableCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraResourcesClient", "CreateUpdateCassandraTable", err.Error()) - } - - req, err := client.CreateUpdateCassandraTablePreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName, createUpdateCassandraTableParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "CreateUpdateCassandraTable", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateCassandraTableSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "CreateUpdateCassandraTable", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdateCassandraTablePreparer prepares the CreateUpdateCassandraTable request. -func (client CassandraResourcesClient) CreateUpdateCassandraTablePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string, createUpdateCassandraTableParameters CassandraTableCreateUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "keyspaceName": autorest.Encode("path", keyspaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "tableName": autorest.Encode("path", tableName), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}", pathParameters), - autorest.WithJSON(createUpdateCassandraTableParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateUpdateCassandraTableSender sends the CreateUpdateCassandraTable request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraResourcesClient) CreateUpdateCassandraTableSender(req *http.Request) (future CassandraResourcesCreateUpdateCassandraTableFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// CreateUpdateCassandraTableResponder handles the response to the CreateUpdateCassandraTable request. The method always -// closes the http.Response Body. -func (client CassandraResourcesClient) CreateUpdateCassandraTableResponder(resp *http.Response) (result CassandraTableGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// DeleteCassandraKeyspace deletes an existing Azure Cosmos DB Cassandra keyspace. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// keyspaceName - cosmos DB keyspace name. -func (client CassandraResourcesClient) DeleteCassandraKeyspace(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result CassandraResourcesDeleteCassandraKeyspaceFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.DeleteCassandraKeyspace") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraResourcesClient", "DeleteCassandraKeyspace", err.Error()) - } - - req, err := client.DeleteCassandraKeyspacePreparer(ctx, resourceGroupName, accountName, keyspaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "DeleteCassandraKeyspace", nil, "Failure preparing request") - return - } - - result, err = client.DeleteCassandraKeyspaceSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "DeleteCassandraKeyspace", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteCassandraKeyspacePreparer prepares the DeleteCassandraKeyspace request. -func (client CassandraResourcesClient) DeleteCassandraKeyspacePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "keyspaceName": autorest.Encode("path", keyspaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteCassandraKeyspaceSender sends the DeleteCassandraKeyspace request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraResourcesClient) DeleteCassandraKeyspaceSender(req *http.Request) (future CassandraResourcesDeleteCassandraKeyspaceFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteCassandraKeyspaceResponder handles the response to the DeleteCassandraKeyspace request. The method always -// closes the http.Response Body. -func (client CassandraResourcesClient) DeleteCassandraKeyspaceResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// DeleteCassandraTable deletes an existing Azure Cosmos DB Cassandra table. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// keyspaceName - cosmos DB keyspace name. -// tableName - cosmos DB table name. -func (client CassandraResourcesClient) DeleteCassandraTable(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result CassandraResourcesDeleteCassandraTableFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.DeleteCassandraTable") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraResourcesClient", "DeleteCassandraTable", err.Error()) - } - - req, err := client.DeleteCassandraTablePreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "DeleteCassandraTable", nil, "Failure preparing request") - return - } - - result, err = client.DeleteCassandraTableSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "DeleteCassandraTable", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteCassandraTablePreparer prepares the DeleteCassandraTable request. -func (client CassandraResourcesClient) DeleteCassandraTablePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "keyspaceName": autorest.Encode("path", keyspaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "tableName": autorest.Encode("path", tableName), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteCassandraTableSender sends the DeleteCassandraTable request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraResourcesClient) DeleteCassandraTableSender(req *http.Request) (future CassandraResourcesDeleteCassandraTableFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteCassandraTableResponder handles the response to the DeleteCassandraTable request. The method always -// closes the http.Response Body. -func (client CassandraResourcesClient) DeleteCassandraTableResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// GetCassandraKeyspace gets the Cassandra keyspaces under an existing Azure Cosmos DB database account with the -// provided name. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// keyspaceName - cosmos DB keyspace name. -func (client CassandraResourcesClient) GetCassandraKeyspace(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result CassandraKeyspaceGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.GetCassandraKeyspace") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraResourcesClient", "GetCassandraKeyspace", err.Error()) - } - - req, err := client.GetCassandraKeyspacePreparer(ctx, resourceGroupName, accountName, keyspaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraKeyspace", nil, "Failure preparing request") - return - } - - resp, err := client.GetCassandraKeyspaceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraKeyspace", resp, "Failure sending request") - return - } - - result, err = client.GetCassandraKeyspaceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraKeyspace", resp, "Failure responding to request") - return - } - - return -} - -// GetCassandraKeyspacePreparer prepares the GetCassandraKeyspace request. -func (client CassandraResourcesClient) GetCassandraKeyspacePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "keyspaceName": autorest.Encode("path", keyspaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetCassandraKeyspaceSender sends the GetCassandraKeyspace request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraResourcesClient) GetCassandraKeyspaceSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetCassandraKeyspaceResponder handles the response to the GetCassandraKeyspace request. The method always -// closes the http.Response Body. -func (client CassandraResourcesClient) GetCassandraKeyspaceResponder(resp *http.Response) (result CassandraKeyspaceGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetCassandraKeyspaceThroughput gets the RUs per second of the Cassandra Keyspace under an existing Azure Cosmos DB -// database account with the provided name. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// keyspaceName - cosmos DB keyspace name. -func (client CassandraResourcesClient) GetCassandraKeyspaceThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result ThroughputSettingsGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.GetCassandraKeyspaceThroughput") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraResourcesClient", "GetCassandraKeyspaceThroughput", err.Error()) - } - - req, err := client.GetCassandraKeyspaceThroughputPreparer(ctx, resourceGroupName, accountName, keyspaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraKeyspaceThroughput", nil, "Failure preparing request") - return - } - - resp, err := client.GetCassandraKeyspaceThroughputSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraKeyspaceThroughput", resp, "Failure sending request") - return - } - - result, err = client.GetCassandraKeyspaceThroughputResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraKeyspaceThroughput", resp, "Failure responding to request") - return - } - - return -} - -// GetCassandraKeyspaceThroughputPreparer prepares the GetCassandraKeyspaceThroughput request. -func (client CassandraResourcesClient) GetCassandraKeyspaceThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "keyspaceName": autorest.Encode("path", keyspaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetCassandraKeyspaceThroughputSender sends the GetCassandraKeyspaceThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraResourcesClient) GetCassandraKeyspaceThroughputSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetCassandraKeyspaceThroughputResponder handles the response to the GetCassandraKeyspaceThroughput request. The method always -// closes the http.Response Body. -func (client CassandraResourcesClient) GetCassandraKeyspaceThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetCassandraTable gets the Cassandra table under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// keyspaceName - cosmos DB keyspace name. -// tableName - cosmos DB table name. -func (client CassandraResourcesClient) GetCassandraTable(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result CassandraTableGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.GetCassandraTable") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraResourcesClient", "GetCassandraTable", err.Error()) - } - - req, err := client.GetCassandraTablePreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraTable", nil, "Failure preparing request") - return - } - - resp, err := client.GetCassandraTableSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraTable", resp, "Failure sending request") - return - } - - result, err = client.GetCassandraTableResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraTable", resp, "Failure responding to request") - return - } - - return -} - -// GetCassandraTablePreparer prepares the GetCassandraTable request. -func (client CassandraResourcesClient) GetCassandraTablePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "keyspaceName": autorest.Encode("path", keyspaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "tableName": autorest.Encode("path", tableName), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetCassandraTableSender sends the GetCassandraTable request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraResourcesClient) GetCassandraTableSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetCassandraTableResponder handles the response to the GetCassandraTable request. The method always -// closes the http.Response Body. -func (client CassandraResourcesClient) GetCassandraTableResponder(resp *http.Response) (result CassandraTableGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetCassandraTableThroughput gets the RUs per second of the Cassandra table under an existing Azure Cosmos DB -// database account with the provided name. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// keyspaceName - cosmos DB keyspace name. -// tableName - cosmos DB table name. -func (client CassandraResourcesClient) GetCassandraTableThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result ThroughputSettingsGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.GetCassandraTableThroughput") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraResourcesClient", "GetCassandraTableThroughput", err.Error()) - } - - req, err := client.GetCassandraTableThroughputPreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraTableThroughput", nil, "Failure preparing request") - return - } - - resp, err := client.GetCassandraTableThroughputSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraTableThroughput", resp, "Failure sending request") - return - } - - result, err = client.GetCassandraTableThroughputResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "GetCassandraTableThroughput", resp, "Failure responding to request") - return - } - - return -} - -// GetCassandraTableThroughputPreparer prepares the GetCassandraTableThroughput request. -func (client CassandraResourcesClient) GetCassandraTableThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "keyspaceName": autorest.Encode("path", keyspaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "tableName": autorest.Encode("path", tableName), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetCassandraTableThroughputSender sends the GetCassandraTableThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraResourcesClient) GetCassandraTableThroughputSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetCassandraTableThroughputResponder handles the response to the GetCassandraTableThroughput request. The method always -// closes the http.Response Body. -func (client CassandraResourcesClient) GetCassandraTableThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListCassandraKeyspaces lists the Cassandra keyspaces under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client CassandraResourcesClient) ListCassandraKeyspaces(ctx context.Context, resourceGroupName string, accountName string) (result CassandraKeyspaceListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.ListCassandraKeyspaces") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraResourcesClient", "ListCassandraKeyspaces", err.Error()) - } - - req, err := client.ListCassandraKeyspacesPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "ListCassandraKeyspaces", nil, "Failure preparing request") - return - } - - resp, err := client.ListCassandraKeyspacesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "ListCassandraKeyspaces", resp, "Failure sending request") - return - } - - result, err = client.ListCassandraKeyspacesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "ListCassandraKeyspaces", resp, "Failure responding to request") - return - } - - return -} - -// ListCassandraKeyspacesPreparer prepares the ListCassandraKeyspaces request. -func (client CassandraResourcesClient) ListCassandraKeyspacesPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListCassandraKeyspacesSender sends the ListCassandraKeyspaces request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraResourcesClient) ListCassandraKeyspacesSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListCassandraKeyspacesResponder handles the response to the ListCassandraKeyspaces request. The method always -// closes the http.Response Body. -func (client CassandraResourcesClient) ListCassandraKeyspacesResponder(resp *http.Response) (result CassandraKeyspaceListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListCassandraTables lists the Cassandra table under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// keyspaceName - cosmos DB keyspace name. -func (client CassandraResourcesClient) ListCassandraTables(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result CassandraTableListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.ListCassandraTables") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraResourcesClient", "ListCassandraTables", err.Error()) - } - - req, err := client.ListCassandraTablesPreparer(ctx, resourceGroupName, accountName, keyspaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "ListCassandraTables", nil, "Failure preparing request") - return - } - - resp, err := client.ListCassandraTablesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "ListCassandraTables", resp, "Failure sending request") - return - } - - result, err = client.ListCassandraTablesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "ListCassandraTables", resp, "Failure responding to request") - return - } - - return -} - -// ListCassandraTablesPreparer prepares the ListCassandraTables request. -func (client CassandraResourcesClient) ListCassandraTablesPreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "keyspaceName": autorest.Encode("path", keyspaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListCassandraTablesSender sends the ListCassandraTables request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraResourcesClient) ListCassandraTablesSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListCassandraTablesResponder handles the response to the ListCassandraTables request. The method always -// closes the http.Response Body. -func (client CassandraResourcesClient) ListCassandraTablesResponder(resp *http.Response) (result CassandraTableListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// MigrateCassandraKeyspaceToAutoscale migrate an Azure Cosmos DB Cassandra Keyspace from manual throughput to -// autoscale -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// keyspaceName - cosmos DB keyspace name. -func (client CassandraResourcesClient) MigrateCassandraKeyspaceToAutoscale(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.MigrateCassandraKeyspaceToAutoscale") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraResourcesClient", "MigrateCassandraKeyspaceToAutoscale", err.Error()) - } - - req, err := client.MigrateCassandraKeyspaceToAutoscalePreparer(ctx, resourceGroupName, accountName, keyspaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraKeyspaceToAutoscale", nil, "Failure preparing request") - return - } - - result, err = client.MigrateCassandraKeyspaceToAutoscaleSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraKeyspaceToAutoscale", result.Response(), "Failure sending request") - return - } - - return -} - -// MigrateCassandraKeyspaceToAutoscalePreparer prepares the MigrateCassandraKeyspaceToAutoscale request. -func (client CassandraResourcesClient) MigrateCassandraKeyspaceToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "keyspaceName": autorest.Encode("path", keyspaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default/migrateToAutoscale", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// MigrateCassandraKeyspaceToAutoscaleSender sends the MigrateCassandraKeyspaceToAutoscale request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraResourcesClient) MigrateCassandraKeyspaceToAutoscaleSender(req *http.Request) (future CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// MigrateCassandraKeyspaceToAutoscaleResponder handles the response to the MigrateCassandraKeyspaceToAutoscale request. The method always -// closes the http.Response Body. -func (client CassandraResourcesClient) MigrateCassandraKeyspaceToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// MigrateCassandraKeyspaceToManualThroughput migrate an Azure Cosmos DB Cassandra Keyspace from autoscale to manual -// throughput -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// keyspaceName - cosmos DB keyspace name. -func (client CassandraResourcesClient) MigrateCassandraKeyspaceToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.MigrateCassandraKeyspaceToManualThroughput") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraResourcesClient", "MigrateCassandraKeyspaceToManualThroughput", err.Error()) - } - - req, err := client.MigrateCassandraKeyspaceToManualThroughputPreparer(ctx, resourceGroupName, accountName, keyspaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraKeyspaceToManualThroughput", nil, "Failure preparing request") - return - } - - result, err = client.MigrateCassandraKeyspaceToManualThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraKeyspaceToManualThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// MigrateCassandraKeyspaceToManualThroughputPreparer prepares the MigrateCassandraKeyspaceToManualThroughput request. -func (client CassandraResourcesClient) MigrateCassandraKeyspaceToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "keyspaceName": autorest.Encode("path", keyspaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default/migrateToManualThroughput", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// MigrateCassandraKeyspaceToManualThroughputSender sends the MigrateCassandraKeyspaceToManualThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraResourcesClient) MigrateCassandraKeyspaceToManualThroughputSender(req *http.Request) (future CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// MigrateCassandraKeyspaceToManualThroughputResponder handles the response to the MigrateCassandraKeyspaceToManualThroughput request. The method always -// closes the http.Response Body. -func (client CassandraResourcesClient) MigrateCassandraKeyspaceToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// MigrateCassandraTableToAutoscale migrate an Azure Cosmos DB Cassandra table from manual throughput to autoscale -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// keyspaceName - cosmos DB keyspace name. -// tableName - cosmos DB table name. -func (client CassandraResourcesClient) MigrateCassandraTableToAutoscale(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result CassandraResourcesMigrateCassandraTableToAutoscaleFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.MigrateCassandraTableToAutoscale") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraResourcesClient", "MigrateCassandraTableToAutoscale", err.Error()) - } - - req, err := client.MigrateCassandraTableToAutoscalePreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraTableToAutoscale", nil, "Failure preparing request") - return - } - - result, err = client.MigrateCassandraTableToAutoscaleSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraTableToAutoscale", result.Response(), "Failure sending request") - return - } - - return -} - -// MigrateCassandraTableToAutoscalePreparer prepares the MigrateCassandraTableToAutoscale request. -func (client CassandraResourcesClient) MigrateCassandraTableToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "keyspaceName": autorest.Encode("path", keyspaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "tableName": autorest.Encode("path", tableName), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default/migrateToAutoscale", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// MigrateCassandraTableToAutoscaleSender sends the MigrateCassandraTableToAutoscale request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraResourcesClient) MigrateCassandraTableToAutoscaleSender(req *http.Request) (future CassandraResourcesMigrateCassandraTableToAutoscaleFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// MigrateCassandraTableToAutoscaleResponder handles the response to the MigrateCassandraTableToAutoscale request. The method always -// closes the http.Response Body. -func (client CassandraResourcesClient) MigrateCassandraTableToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// MigrateCassandraTableToManualThroughput migrate an Azure Cosmos DB Cassandra table from autoscale to manual -// throughput -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// keyspaceName - cosmos DB keyspace name. -// tableName - cosmos DB table name. -func (client CassandraResourcesClient) MigrateCassandraTableToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result CassandraResourcesMigrateCassandraTableToManualThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.MigrateCassandraTableToManualThroughput") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraResourcesClient", "MigrateCassandraTableToManualThroughput", err.Error()) - } - - req, err := client.MigrateCassandraTableToManualThroughputPreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraTableToManualThroughput", nil, "Failure preparing request") - return - } - - result, err = client.MigrateCassandraTableToManualThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "MigrateCassandraTableToManualThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// MigrateCassandraTableToManualThroughputPreparer prepares the MigrateCassandraTableToManualThroughput request. -func (client CassandraResourcesClient) MigrateCassandraTableToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "keyspaceName": autorest.Encode("path", keyspaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "tableName": autorest.Encode("path", tableName), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// MigrateCassandraTableToManualThroughputSender sends the MigrateCassandraTableToManualThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraResourcesClient) MigrateCassandraTableToManualThroughputSender(req *http.Request) (future CassandraResourcesMigrateCassandraTableToManualThroughputFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// MigrateCassandraTableToManualThroughputResponder handles the response to the MigrateCassandraTableToManualThroughput request. The method always -// closes the http.Response Body. -func (client CassandraResourcesClient) MigrateCassandraTableToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// UpdateCassandraKeyspaceThroughput update RUs per second of an Azure Cosmos DB Cassandra Keyspace -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// keyspaceName - cosmos DB keyspace name. -// updateThroughputParameters - the RUs per second of the parameters to provide for the current Cassandra -// Keyspace. -func (client CassandraResourcesClient) UpdateCassandraKeyspaceThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result CassandraResourcesUpdateCassandraKeyspaceThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.UpdateCassandraKeyspaceThroughput") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: updateThroughputParameters, - Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, - }}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraResourcesClient", "UpdateCassandraKeyspaceThroughput", err.Error()) - } - - req, err := client.UpdateCassandraKeyspaceThroughputPreparer(ctx, resourceGroupName, accountName, keyspaceName, updateThroughputParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "UpdateCassandraKeyspaceThroughput", nil, "Failure preparing request") - return - } - - result, err = client.UpdateCassandraKeyspaceThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "UpdateCassandraKeyspaceThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdateCassandraKeyspaceThroughputPreparer prepares the UpdateCassandraKeyspaceThroughput request. -func (client CassandraResourcesClient) UpdateCassandraKeyspaceThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "keyspaceName": autorest.Encode("path", keyspaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default", pathParameters), - autorest.WithJSON(updateThroughputParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateCassandraKeyspaceThroughputSender sends the UpdateCassandraKeyspaceThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraResourcesClient) UpdateCassandraKeyspaceThroughputSender(req *http.Request) (future CassandraResourcesUpdateCassandraKeyspaceThroughputFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// UpdateCassandraKeyspaceThroughputResponder handles the response to the UpdateCassandraKeyspaceThroughput request. The method always -// closes the http.Response Body. -func (client CassandraResourcesClient) UpdateCassandraKeyspaceThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// UpdateCassandraTableThroughput update RUs per second of an Azure Cosmos DB Cassandra table -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// keyspaceName - cosmos DB keyspace name. -// tableName - cosmos DB table name. -// updateThroughputParameters - the RUs per second of the parameters to provide for the current Cassandra -// table. -func (client CassandraResourcesClient) UpdateCassandraTableThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result CassandraResourcesUpdateCassandraTableThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CassandraResourcesClient.UpdateCassandraTableThroughput") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: updateThroughputParameters, - Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, - }}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.CassandraResourcesClient", "UpdateCassandraTableThroughput", err.Error()) - } - - req, err := client.UpdateCassandraTableThroughputPreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName, updateThroughputParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "UpdateCassandraTableThroughput", nil, "Failure preparing request") - return - } - - result, err = client.UpdateCassandraTableThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesClient", "UpdateCassandraTableThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdateCassandraTableThroughputPreparer prepares the UpdateCassandraTableThroughput request. -func (client CassandraResourcesClient) UpdateCassandraTableThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "keyspaceName": autorest.Encode("path", keyspaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "tableName": autorest.Encode("path", tableName), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default", pathParameters), - autorest.WithJSON(updateThroughputParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateCassandraTableThroughputSender sends the UpdateCassandraTableThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client CassandraResourcesClient) UpdateCassandraTableThroughputSender(req *http.Request) (future CassandraResourcesUpdateCassandraTableThroughputFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// UpdateCassandraTableThroughputResponder handles the response to the UpdateCassandraTableThroughput request. The method always -// closes the http.Response Body. -func (client CassandraResourcesClient) UpdateCassandraTableThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/client.go deleted file mode 100644 index 8553f27e14cc..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/client.go +++ /dev/null @@ -1,43 +0,0 @@ -// Deprecated: Please note, this package has been deprecated. A replacement package is available [github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cosmos/armcosmos](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cosmos/armcosmos). We strongly encourage you to upgrade to continue receiving updates. See [Migration Guide](https://aka.ms/azsdk/golang/t2/migration) for guidance on upgrading. Refer to our [deprecation policy](https://azure.github.io/azure-sdk/policies_support.html) for more details. -// -// Package documentdb implements the Azure ARM Documentdb service API version 2021-10-15. -// -// -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "github.com/Azure/go-autorest/autorest" -) - -const ( - // DefaultBaseURI is the default URI used for the service Documentdb - DefaultBaseURI = "https://management.azure.com" -) - -// BaseClient is the base client for Documentdb. -type BaseClient struct { - autorest.Client - BaseURI string - SubscriptionID string -} - -// New creates an instance of the BaseClient client. -func New(subscriptionID string) BaseClient { - return NewWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with -// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { - return BaseClient{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: baseURI, - SubscriptionID: subscriptionID, - } -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/collection.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/collection.go deleted file mode 100644 index 23c1a431e3b2..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/collection.go +++ /dev/null @@ -1,320 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// CollectionClient is the client for the Collection methods of the Documentdb service. -type CollectionClient struct { - BaseClient -} - -// NewCollectionClient creates an instance of the CollectionClient client. -func NewCollectionClient(subscriptionID string) CollectionClient { - return NewCollectionClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewCollectionClientWithBaseURI creates an instance of the CollectionClient client using a custom endpoint. Use this -// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewCollectionClientWithBaseURI(baseURI string, subscriptionID string) CollectionClient { - return CollectionClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// ListMetricDefinitions retrieves metric definitions for the given collection. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseRid - cosmos DB database rid. -// collectionRid - cosmos DB collection rid. -func (client CollectionClient) ListMetricDefinitions(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string) (result MetricDefinitionsListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CollectionClient.ListMetricDefinitions") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CollectionClient", "ListMetricDefinitions", err.Error()) - } - - req, err := client.ListMetricDefinitionsPreparer(ctx, resourceGroupName, accountName, databaseRid, collectionRid) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListMetricDefinitions", nil, "Failure preparing request") - return - } - - resp, err := client.ListMetricDefinitionsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListMetricDefinitions", resp, "Failure sending request") - return - } - - result, err = client.ListMetricDefinitionsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListMetricDefinitions", resp, "Failure responding to request") - return - } - - return -} - -// ListMetricDefinitionsPreparer prepares the ListMetricDefinitions request. -func (client CollectionClient) ListMetricDefinitionsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "collectionRid": autorest.Encode("path", collectionRid), - "databaseRid": autorest.Encode("path", databaseRid), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/metricDefinitions", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListMetricDefinitionsSender sends the ListMetricDefinitions request. The method will close the -// http.Response Body if it receives an error. -func (client CollectionClient) ListMetricDefinitionsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListMetricDefinitionsResponder handles the response to the ListMetricDefinitions request. The method always -// closes the http.Response Body. -func (client CollectionClient) ListMetricDefinitionsResponder(resp *http.Response) (result MetricDefinitionsListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListMetrics retrieves the metrics determined by the given filter for the given database account and collection. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseRid - cosmos DB database rid. -// collectionRid - cosmos DB collection rid. -// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be -// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and -// timeGrain. The supported operator is eq. -func (client CollectionClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (result MetricListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CollectionClient.ListMetrics") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CollectionClient", "ListMetrics", err.Error()) - } - - req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, databaseRid, collectionRid, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListMetrics", nil, "Failure preparing request") - return - } - - resp, err := client.ListMetricsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListMetrics", resp, "Failure sending request") - return - } - - result, err = client.ListMetricsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListMetrics", resp, "Failure responding to request") - return - } - - return -} - -// ListMetricsPreparer prepares the ListMetrics request. -func (client CollectionClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "collectionRid": autorest.Encode("path", collectionRid), - "databaseRid": autorest.Encode("path", databaseRid), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "$filter": autorest.Encode("query", filter), - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/metrics", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListMetricsSender sends the ListMetrics request. The method will close the -// http.Response Body if it receives an error. -func (client CollectionClient) ListMetricsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListMetricsResponder handles the response to the ListMetrics request. The method always -// closes the http.Response Body. -func (client CollectionClient) ListMetricsResponder(resp *http.Response) (result MetricListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListUsages retrieves the usages (most recent storage data) for the given collection. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseRid - cosmos DB database rid. -// collectionRid - cosmos DB collection rid. -// filter - an OData filter expression that describes a subset of usages to return. The supported parameter is -// name.value (name of the metric, can have an or of multiple names). -func (client CollectionClient) ListUsages(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (result UsagesResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CollectionClient.ListUsages") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CollectionClient", "ListUsages", err.Error()) - } - - req, err := client.ListUsagesPreparer(ctx, resourceGroupName, accountName, databaseRid, collectionRid, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListUsages", nil, "Failure preparing request") - return - } - - resp, err := client.ListUsagesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListUsages", resp, "Failure sending request") - return - } - - result, err = client.ListUsagesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CollectionClient", "ListUsages", resp, "Failure responding to request") - return - } - - return -} - -// ListUsagesPreparer prepares the ListUsages request. -func (client CollectionClient) ListUsagesPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "collectionRid": autorest.Encode("path", collectionRid), - "databaseRid": autorest.Encode("path", databaseRid), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/usages", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListUsagesSender sends the ListUsages request. The method will close the -// http.Response Body if it receives an error. -func (client CollectionClient) ListUsagesSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListUsagesResponder handles the response to the ListUsages request. The method always -// closes the http.Response Body. -func (client CollectionClient) ListUsagesResponder(resp *http.Response) (result UsagesResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/collectionpartition.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/collectionpartition.go deleted file mode 100644 index 980c59d99ab0..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/collectionpartition.go +++ /dev/null @@ -1,228 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// CollectionPartitionClient is the client for the CollectionPartition methods of the Documentdb service. -type CollectionPartitionClient struct { - BaseClient -} - -// NewCollectionPartitionClient creates an instance of the CollectionPartitionClient client. -func NewCollectionPartitionClient(subscriptionID string) CollectionPartitionClient { - return NewCollectionPartitionClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewCollectionPartitionClientWithBaseURI creates an instance of the CollectionPartitionClient client using a custom -// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure -// stack). -func NewCollectionPartitionClientWithBaseURI(baseURI string, subscriptionID string) CollectionPartitionClient { - return CollectionPartitionClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// ListMetrics retrieves the metrics determined by the given filter for the given collection, split by partition. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseRid - cosmos DB database rid. -// collectionRid - cosmos DB collection rid. -// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be -// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and -// timeGrain. The supported operator is eq. -func (client CollectionPartitionClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (result PartitionMetricListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CollectionPartitionClient.ListMetrics") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CollectionPartitionClient", "ListMetrics", err.Error()) - } - - req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, databaseRid, collectionRid, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionClient", "ListMetrics", nil, "Failure preparing request") - return - } - - resp, err := client.ListMetricsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionClient", "ListMetrics", resp, "Failure sending request") - return - } - - result, err = client.ListMetricsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionClient", "ListMetrics", resp, "Failure responding to request") - return - } - - return -} - -// ListMetricsPreparer prepares the ListMetrics request. -func (client CollectionPartitionClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "collectionRid": autorest.Encode("path", collectionRid), - "databaseRid": autorest.Encode("path", databaseRid), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "$filter": autorest.Encode("query", filter), - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitions/metrics", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListMetricsSender sends the ListMetrics request. The method will close the -// http.Response Body if it receives an error. -func (client CollectionPartitionClient) ListMetricsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListMetricsResponder handles the response to the ListMetrics request. The method always -// closes the http.Response Body. -func (client CollectionPartitionClient) ListMetricsResponder(resp *http.Response) (result PartitionMetricListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListUsages retrieves the usages (most recent storage data) for the given collection, split by partition. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseRid - cosmos DB database rid. -// collectionRid - cosmos DB collection rid. -// filter - an OData filter expression that describes a subset of usages to return. The supported parameter is -// name.value (name of the metric, can have an or of multiple names). -func (client CollectionPartitionClient) ListUsages(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (result PartitionUsagesResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CollectionPartitionClient.ListUsages") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CollectionPartitionClient", "ListUsages", err.Error()) - } - - req, err := client.ListUsagesPreparer(ctx, resourceGroupName, accountName, databaseRid, collectionRid, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionClient", "ListUsages", nil, "Failure preparing request") - return - } - - resp, err := client.ListUsagesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionClient", "ListUsages", resp, "Failure sending request") - return - } - - result, err = client.ListUsagesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionClient", "ListUsages", resp, "Failure responding to request") - return - } - - return -} - -// ListUsagesPreparer prepares the ListUsages request. -func (client CollectionPartitionClient) ListUsagesPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "collectionRid": autorest.Encode("path", collectionRid), - "databaseRid": autorest.Encode("path", databaseRid), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitions/usages", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListUsagesSender sends the ListUsages request. The method will close the -// http.Response Body if it receives an error. -func (client CollectionPartitionClient) ListUsagesSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListUsagesResponder handles the response to the ListUsages request. The method always -// closes the http.Response Body. -func (client CollectionPartitionClient) ListUsagesResponder(resp *http.Response) (result PartitionUsagesResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/collectionpartitionregion.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/collectionpartitionregion.go deleted file mode 100644 index 019f4ca10f17..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/collectionpartitionregion.go +++ /dev/null @@ -1,133 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// CollectionPartitionRegionClient is the client for the CollectionPartitionRegion methods of the Documentdb service. -type CollectionPartitionRegionClient struct { - BaseClient -} - -// NewCollectionPartitionRegionClient creates an instance of the CollectionPartitionRegionClient client. -func NewCollectionPartitionRegionClient(subscriptionID string) CollectionPartitionRegionClient { - return NewCollectionPartitionRegionClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewCollectionPartitionRegionClientWithBaseURI creates an instance of the CollectionPartitionRegionClient client -// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign -// clouds, Azure stack). -func NewCollectionPartitionRegionClientWithBaseURI(baseURI string, subscriptionID string) CollectionPartitionRegionClient { - return CollectionPartitionRegionClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// ListMetrics retrieves the metrics determined by the given filter for the given collection and region, split by -// partition. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// region - cosmos DB region, with spaces between words and each word capitalized. -// databaseRid - cosmos DB database rid. -// collectionRid - cosmos DB collection rid. -// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be -// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and -// timeGrain. The supported operator is eq. -func (client CollectionPartitionRegionClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, filter string) (result PartitionMetricListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CollectionPartitionRegionClient.ListMetrics") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CollectionPartitionRegionClient", "ListMetrics", err.Error()) - } - - req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, region, databaseRid, collectionRid, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionRegionClient", "ListMetrics", nil, "Failure preparing request") - return - } - - resp, err := client.ListMetricsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionRegionClient", "ListMetrics", resp, "Failure sending request") - return - } - - result, err = client.ListMetricsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CollectionPartitionRegionClient", "ListMetrics", resp, "Failure responding to request") - return - } - - return -} - -// ListMetricsPreparer prepares the ListMetrics request. -func (client CollectionPartitionRegionClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "collectionRid": autorest.Encode("path", collectionRid), - "databaseRid": autorest.Encode("path", databaseRid), - "region": autorest.Encode("path", region), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "$filter": autorest.Encode("query", filter), - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/partitions/metrics", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListMetricsSender sends the ListMetrics request. The method will close the -// http.Response Body if it receives an error. -func (client CollectionPartitionRegionClient) ListMetricsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListMetricsResponder handles the response to the ListMetrics request. The method always -// closes the http.Response Body. -func (client CollectionPartitionRegionClient) ListMetricsResponder(resp *http.Response) (result PartitionMetricListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/collectionregion.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/collectionregion.go deleted file mode 100644 index b47e029897c3..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/collectionregion.go +++ /dev/null @@ -1,133 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// CollectionRegionClient is the client for the CollectionRegion methods of the Documentdb service. -type CollectionRegionClient struct { - BaseClient -} - -// NewCollectionRegionClient creates an instance of the CollectionRegionClient client. -func NewCollectionRegionClient(subscriptionID string) CollectionRegionClient { - return NewCollectionRegionClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewCollectionRegionClientWithBaseURI creates an instance of the CollectionRegionClient client using a custom -// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure -// stack). -func NewCollectionRegionClientWithBaseURI(baseURI string, subscriptionID string) CollectionRegionClient { - return CollectionRegionClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// ListMetrics retrieves the metrics determined by the given filter for the given database account, collection and -// region. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// region - cosmos DB region, with spaces between words and each word capitalized. -// databaseRid - cosmos DB database rid. -// collectionRid - cosmos DB collection rid. -// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be -// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and -// timeGrain. The supported operator is eq. -func (client CollectionRegionClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, filter string) (result MetricListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CollectionRegionClient.ListMetrics") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.CollectionRegionClient", "ListMetrics", err.Error()) - } - - req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, region, databaseRid, collectionRid, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CollectionRegionClient", "ListMetrics", nil, "Failure preparing request") - return - } - - resp, err := client.ListMetricsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.CollectionRegionClient", "ListMetrics", resp, "Failure sending request") - return - } - - result, err = client.ListMetricsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CollectionRegionClient", "ListMetrics", resp, "Failure responding to request") - return - } - - return -} - -// ListMetricsPreparer prepares the ListMetrics request. -func (client CollectionRegionClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "collectionRid": autorest.Encode("path", collectionRid), - "databaseRid": autorest.Encode("path", databaseRid), - "region": autorest.Encode("path", region), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "$filter": autorest.Encode("query", filter), - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/metrics", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListMetricsSender sends the ListMetrics request. The method will close the -// http.Response Body if it receives an error. -func (client CollectionRegionClient) ListMetricsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListMetricsResponder handles the response to the ListMetrics request. The method always -// closes the http.Response Body. -func (client CollectionRegionClient) ListMetricsResponder(resp *http.Response) (result MetricListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/database.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/database.go deleted file mode 100644 index 408902088abd..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/database.go +++ /dev/null @@ -1,314 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// DatabaseClient is the client for the Database methods of the Documentdb service. -type DatabaseClient struct { - BaseClient -} - -// NewDatabaseClient creates an instance of the DatabaseClient client. -func NewDatabaseClient(subscriptionID string) DatabaseClient { - return NewDatabaseClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewDatabaseClientWithBaseURI creates an instance of the DatabaseClient client using a custom endpoint. Use this -// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewDatabaseClientWithBaseURI(baseURI string, subscriptionID string) DatabaseClient { - return DatabaseClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// ListMetricDefinitions retrieves metric definitions for the given database. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseRid - cosmos DB database rid. -func (client DatabaseClient) ListMetricDefinitions(ctx context.Context, resourceGroupName string, accountName string, databaseRid string) (result MetricDefinitionsListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseClient.ListMetricDefinitions") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseClient", "ListMetricDefinitions", err.Error()) - } - - req, err := client.ListMetricDefinitionsPreparer(ctx, resourceGroupName, accountName, databaseRid) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListMetricDefinitions", nil, "Failure preparing request") - return - } - - resp, err := client.ListMetricDefinitionsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListMetricDefinitions", resp, "Failure sending request") - return - } - - result, err = client.ListMetricDefinitionsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListMetricDefinitions", resp, "Failure responding to request") - return - } - - return -} - -// ListMetricDefinitionsPreparer prepares the ListMetricDefinitions request. -func (client DatabaseClient) ListMetricDefinitionsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseRid": autorest.Encode("path", databaseRid), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metricDefinitions", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListMetricDefinitionsSender sends the ListMetricDefinitions request. The method will close the -// http.Response Body if it receives an error. -func (client DatabaseClient) ListMetricDefinitionsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListMetricDefinitionsResponder handles the response to the ListMetricDefinitions request. The method always -// closes the http.Response Body. -func (client DatabaseClient) ListMetricDefinitionsResponder(resp *http.Response) (result MetricDefinitionsListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListMetrics retrieves the metrics determined by the given filter for the given database account and database. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseRid - cosmos DB database rid. -// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be -// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and -// timeGrain. The supported operator is eq. -func (client DatabaseClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, filter string) (result MetricListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseClient.ListMetrics") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseClient", "ListMetrics", err.Error()) - } - - req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, databaseRid, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListMetrics", nil, "Failure preparing request") - return - } - - resp, err := client.ListMetricsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListMetrics", resp, "Failure sending request") - return - } - - result, err = client.ListMetricsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListMetrics", resp, "Failure responding to request") - return - } - - return -} - -// ListMetricsPreparer prepares the ListMetrics request. -func (client DatabaseClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseRid": autorest.Encode("path", databaseRid), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "$filter": autorest.Encode("query", filter), - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metrics", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListMetricsSender sends the ListMetrics request. The method will close the -// http.Response Body if it receives an error. -func (client DatabaseClient) ListMetricsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListMetricsResponder handles the response to the ListMetrics request. The method always -// closes the http.Response Body. -func (client DatabaseClient) ListMetricsResponder(resp *http.Response) (result MetricListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListUsages retrieves the usages (most recent data) for the given database. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseRid - cosmos DB database rid. -// filter - an OData filter expression that describes a subset of usages to return. The supported parameter is -// name.value (name of the metric, can have an or of multiple names). -func (client DatabaseClient) ListUsages(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, filter string) (result UsagesResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseClient.ListUsages") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseClient", "ListUsages", err.Error()) - } - - req, err := client.ListUsagesPreparer(ctx, resourceGroupName, accountName, databaseRid, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListUsages", nil, "Failure preparing request") - return - } - - resp, err := client.ListUsagesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListUsages", resp, "Failure sending request") - return - } - - result, err = client.ListUsagesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseClient", "ListUsages", resp, "Failure responding to request") - return - } - - return -} - -// ListUsagesPreparer prepares the ListUsages request. -func (client DatabaseClient) ListUsagesPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseRid": autorest.Encode("path", databaseRid), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/usages", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListUsagesSender sends the ListUsages request. The method will close the -// http.Response Body if it receives an error. -func (client DatabaseClient) ListUsagesSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListUsagesResponder handles the response to the ListUsages request. The method always -// closes the http.Response Body. -func (client DatabaseClient) ListUsagesResponder(resp *http.Response) (result UsagesResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/databaseaccountregion.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/databaseaccountregion.go deleted file mode 100644 index 61b04f332d1a..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/databaseaccountregion.go +++ /dev/null @@ -1,128 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// DatabaseAccountRegionClient is the client for the DatabaseAccountRegion methods of the Documentdb service. -type DatabaseAccountRegionClient struct { - BaseClient -} - -// NewDatabaseAccountRegionClient creates an instance of the DatabaseAccountRegionClient client. -func NewDatabaseAccountRegionClient(subscriptionID string) DatabaseAccountRegionClient { - return NewDatabaseAccountRegionClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewDatabaseAccountRegionClientWithBaseURI creates an instance of the DatabaseAccountRegionClient client using a -// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, -// Azure stack). -func NewDatabaseAccountRegionClientWithBaseURI(baseURI string, subscriptionID string) DatabaseAccountRegionClient { - return DatabaseAccountRegionClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// ListMetrics retrieves the metrics determined by the given filter for the given database account and region. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// region - cosmos DB region, with spaces between words and each word capitalized. -// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be -// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and -// timeGrain. The supported operator is eq. -func (client DatabaseAccountRegionClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, region string, filter string) (result MetricListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountRegionClient.ListMetrics") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountRegionClient", "ListMetrics", err.Error()) - } - - req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, region, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountRegionClient", "ListMetrics", nil, "Failure preparing request") - return - } - - resp, err := client.ListMetricsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountRegionClient", "ListMetrics", resp, "Failure sending request") - return - } - - result, err = client.ListMetricsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountRegionClient", "ListMetrics", resp, "Failure responding to request") - return - } - - return -} - -// ListMetricsPreparer prepares the ListMetrics request. -func (client DatabaseAccountRegionClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, region string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "region": autorest.Encode("path", region), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "$filter": autorest.Encode("query", filter), - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/metrics", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListMetricsSender sends the ListMetrics request. The method will close the -// http.Response Body if it receives an error. -func (client DatabaseAccountRegionClient) ListMetricsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListMetricsResponder handles the response to the ListMetrics request. The method always -// closes the http.Response Body. -func (client DatabaseAccountRegionClient) ListMetricsResponder(resp *http.Response) (result MetricListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/databaseaccounts.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/databaseaccounts.go deleted file mode 100644 index 385f58e84e94..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/databaseaccounts.go +++ /dev/null @@ -1,1680 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// DatabaseAccountsClient is the client for the DatabaseAccounts methods of the Documentdb service. -type DatabaseAccountsClient struct { - BaseClient -} - -// NewDatabaseAccountsClient creates an instance of the DatabaseAccountsClient client. -func NewDatabaseAccountsClient(subscriptionID string) DatabaseAccountsClient { - return NewDatabaseAccountsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewDatabaseAccountsClientWithBaseURI creates an instance of the DatabaseAccountsClient client using a custom -// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure -// stack). -func NewDatabaseAccountsClientWithBaseURI(baseURI string, subscriptionID string) DatabaseAccountsClient { - return DatabaseAccountsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CheckNameExists checks that the Azure Cosmos DB account name already exists. A valid account name may contain only -// lowercase letters, numbers, and the '-' character, and must be between 3 and 50 characters. -// Parameters: -// accountName - cosmos DB database account name. -func (client DatabaseAccountsClient) CheckNameExists(ctx context.Context, accountName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.CheckNameExists") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "CheckNameExists", err.Error()) - } - - req, err := client.CheckNameExistsPreparer(ctx, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CheckNameExists", nil, "Failure preparing request") - return - } - - resp, err := client.CheckNameExistsSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CheckNameExists", resp, "Failure sending request") - return - } - - result, err = client.CheckNameExistsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CheckNameExists", resp, "Failure responding to request") - return - } - - return -} - -// CheckNameExistsPreparer prepares the CheckNameExists request. -func (client DatabaseAccountsClient) CheckNameExistsPreparer(ctx context.Context, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsHead(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/providers/Microsoft.DocumentDB/databaseAccountNames/{accountName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CheckNameExistsSender sends the CheckNameExists request. The method will close the -// http.Response Body if it receives an error. -func (client DatabaseAccountsClient) CheckNameExistsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// CheckNameExistsResponder handles the response to the CheckNameExists request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) CheckNameExistsResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound), - autorest.ByClosing()) - result.Response = resp - return -} - -// CreateOrUpdate creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when -// performing updates on an account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// createUpdateParameters - the parameters to provide for the current database account. -func (client DatabaseAccountsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, createUpdateParameters DatabaseAccountCreateUpdateParameters) (result DatabaseAccountsCreateOrUpdateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.CreateOrUpdate") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: createUpdateParameters, - Constraints: []validation.Constraint{{Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties.ConsistencyPolicy", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties.ConsistencyPolicy.MaxStalenessPrefix", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties.ConsistencyPolicy.MaxStalenessPrefix", Name: validation.InclusiveMaximum, Rule: int64(2147483647), Chain: nil}, - {Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties.ConsistencyPolicy.MaxStalenessPrefix", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, - }}, - {Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties.ConsistencyPolicy.MaxIntervalInSeconds", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties.ConsistencyPolicy.MaxIntervalInSeconds", Name: validation.InclusiveMaximum, Rule: int64(86400), Chain: nil}, - {Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties.ConsistencyPolicy.MaxIntervalInSeconds", Name: validation.InclusiveMinimum, Rule: int64(5), Chain: nil}, - }}, - }}, - {Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties.Locations", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties.DatabaseAccountOfferType", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties.Capacity", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties.Capacity.TotalThroughputLimit", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "createUpdateParameters.DatabaseAccountCreateUpdateProperties.Capacity.TotalThroughputLimit", Name: validation.InclusiveMinimum, Rule: int64(-1), Chain: nil}}}, - }}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "CreateOrUpdate", err.Error()) - } - - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, accountName, createUpdateParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = client.CreateOrUpdateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateOrUpdate", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client DatabaseAccountsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, createUpdateParameters DatabaseAccountCreateUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}", pathParameters), - autorest.WithJSON(createUpdateParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client DatabaseAccountsClient) CreateOrUpdateSender(req *http.Request) (future DatabaseAccountsCreateOrUpdateFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) CreateOrUpdateResponder(resp *http.Response) (result DatabaseAccountGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete deletes an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client DatabaseAccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string) (result DatabaseAccountsDeleteFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.Delete") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Delete", result.Response(), "Failure sending request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client DatabaseAccountsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client DatabaseAccountsClient) DeleteSender(req *http.Request) (future DatabaseAccountsDeleteFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// FailoverPriorityChange changes the failover priority for the Azure Cosmos DB database account. A failover priority -// of 0 indicates a write region. The maximum value for a failover priority = (total number of regions - 1). Failover -// priority values must be unique for each of the regions in which the database account exists. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// failoverParameters - the new failover policies for the database account. -func (client DatabaseAccountsClient) FailoverPriorityChange(ctx context.Context, resourceGroupName string, accountName string, failoverParameters FailoverPolicies) (result DatabaseAccountsFailoverPriorityChangeFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.FailoverPriorityChange") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: failoverParameters, - Constraints: []validation.Constraint{{Target: "failoverParameters.FailoverPolicies", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "FailoverPriorityChange", err.Error()) - } - - req, err := client.FailoverPriorityChangePreparer(ctx, resourceGroupName, accountName, failoverParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "FailoverPriorityChange", nil, "Failure preparing request") - return - } - - result, err = client.FailoverPriorityChangeSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "FailoverPriorityChange", result.Response(), "Failure sending request") - return - } - - return -} - -// FailoverPriorityChangePreparer prepares the FailoverPriorityChange request. -func (client DatabaseAccountsClient) FailoverPriorityChangePreparer(ctx context.Context, resourceGroupName string, accountName string, failoverParameters FailoverPolicies) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/failoverPriorityChange", pathParameters), - autorest.WithJSON(failoverParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// FailoverPriorityChangeSender sends the FailoverPriorityChange request. The method will close the -// http.Response Body if it receives an error. -func (client DatabaseAccountsClient) FailoverPriorityChangeSender(req *http.Request) (future DatabaseAccountsFailoverPriorityChangeFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// FailoverPriorityChangeResponder handles the response to the FailoverPriorityChange request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) FailoverPriorityChangeResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get retrieves the properties of an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client DatabaseAccountsClient) Get(ctx context.Context, resourceGroupName string, accountName string) (result DatabaseAccountGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client DatabaseAccountsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client DatabaseAccountsClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) GetResponder(resp *http.Response) (result DatabaseAccountGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetReadOnlyKeys lists the read-only access keys for the specified Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client DatabaseAccountsClient) GetReadOnlyKeys(ctx context.Context, resourceGroupName string, accountName string) (result DatabaseAccountListReadOnlyKeysResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.GetReadOnlyKeys") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "GetReadOnlyKeys", err.Error()) - } - - req, err := client.GetReadOnlyKeysPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetReadOnlyKeys", nil, "Failure preparing request") - return - } - - resp, err := client.GetReadOnlyKeysSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetReadOnlyKeys", resp, "Failure sending request") - return - } - - result, err = client.GetReadOnlyKeysResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetReadOnlyKeys", resp, "Failure responding to request") - return - } - - return -} - -// GetReadOnlyKeysPreparer prepares the GetReadOnlyKeys request. -func (client DatabaseAccountsClient) GetReadOnlyKeysPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetReadOnlyKeysSender sends the GetReadOnlyKeys request. The method will close the -// http.Response Body if it receives an error. -func (client DatabaseAccountsClient) GetReadOnlyKeysSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetReadOnlyKeysResponder handles the response to the GetReadOnlyKeys request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) GetReadOnlyKeysResponder(resp *http.Response) (result DatabaseAccountListReadOnlyKeysResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List lists all the Azure Cosmos DB database accounts available under the subscription. -func (client DatabaseAccountsClient) List(ctx context.Context) (result DatabaseAccountsListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.List") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "List", err.Error()) - } - - req, err := client.ListPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "List", resp, "Failure sending request") - return - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "List", resp, "Failure responding to request") - return - } - - return -} - -// ListPreparer prepares the List request. -func (client DatabaseAccountsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/databaseAccounts", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client DatabaseAccountsClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) ListResponder(resp *http.Response) (result DatabaseAccountsListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListByResourceGroup lists all the Azure Cosmos DB database accounts available under the given resource group. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -func (client DatabaseAccountsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result DatabaseAccountsListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.ListByResourceGroup") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "ListByResourceGroup", err.Error()) - } - - req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp, err := client.ListByResourceGroupSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListByResourceGroup", resp, "Failure sending request") - return - } - - result, err = client.ListByResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListByResourceGroup", resp, "Failure responding to request") - return - } - - return -} - -// ListByResourceGroupPreparer prepares the ListByResourceGroup request. -func (client DatabaseAccountsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the -// http.Response Body if it receives an error. -func (client DatabaseAccountsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) ListByResourceGroupResponder(resp *http.Response) (result DatabaseAccountsListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListConnectionStrings lists the connection strings for the specified Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client DatabaseAccountsClient) ListConnectionStrings(ctx context.Context, resourceGroupName string, accountName string) (result DatabaseAccountListConnectionStringsResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.ListConnectionStrings") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "ListConnectionStrings", err.Error()) - } - - req, err := client.ListConnectionStringsPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListConnectionStrings", nil, "Failure preparing request") - return - } - - resp, err := client.ListConnectionStringsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListConnectionStrings", resp, "Failure sending request") - return - } - - result, err = client.ListConnectionStringsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListConnectionStrings", resp, "Failure responding to request") - return - } - - return -} - -// ListConnectionStringsPreparer prepares the ListConnectionStrings request. -func (client DatabaseAccountsClient) ListConnectionStringsPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listConnectionStrings", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListConnectionStringsSender sends the ListConnectionStrings request. The method will close the -// http.Response Body if it receives an error. -func (client DatabaseAccountsClient) ListConnectionStringsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListConnectionStringsResponder handles the response to the ListConnectionStrings request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) ListConnectionStringsResponder(resp *http.Response) (result DatabaseAccountListConnectionStringsResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListKeys lists the access keys for the specified Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client DatabaseAccountsClient) ListKeys(ctx context.Context, resourceGroupName string, accountName string) (result DatabaseAccountListKeysResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.ListKeys") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "ListKeys", err.Error()) - } - - req, err := client.ListKeysPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListKeys", nil, "Failure preparing request") - return - } - - resp, err := client.ListKeysSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListKeys", resp, "Failure sending request") - return - } - - result, err = client.ListKeysResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListKeys", resp, "Failure responding to request") - return - } - - return -} - -// ListKeysPreparer prepares the ListKeys request. -func (client DatabaseAccountsClient) ListKeysPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listKeys", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListKeysSender sends the ListKeys request. The method will close the -// http.Response Body if it receives an error. -func (client DatabaseAccountsClient) ListKeysSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListKeysResponder handles the response to the ListKeys request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) ListKeysResponder(resp *http.Response) (result DatabaseAccountListKeysResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListMetricDefinitions retrieves metric definitions for the given database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client DatabaseAccountsClient) ListMetricDefinitions(ctx context.Context, resourceGroupName string, accountName string) (result MetricDefinitionsListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.ListMetricDefinitions") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "ListMetricDefinitions", err.Error()) - } - - req, err := client.ListMetricDefinitionsPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListMetricDefinitions", nil, "Failure preparing request") - return - } - - resp, err := client.ListMetricDefinitionsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListMetricDefinitions", resp, "Failure sending request") - return - } - - result, err = client.ListMetricDefinitionsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListMetricDefinitions", resp, "Failure responding to request") - return - } - - return -} - -// ListMetricDefinitionsPreparer prepares the ListMetricDefinitions request. -func (client DatabaseAccountsClient) ListMetricDefinitionsPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metricDefinitions", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListMetricDefinitionsSender sends the ListMetricDefinitions request. The method will close the -// http.Response Body if it receives an error. -func (client DatabaseAccountsClient) ListMetricDefinitionsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListMetricDefinitionsResponder handles the response to the ListMetricDefinitions request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) ListMetricDefinitionsResponder(resp *http.Response) (result MetricDefinitionsListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListMetrics retrieves the metrics determined by the given filter for the given database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be -// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and -// timeGrain. The supported operator is eq. -func (client DatabaseAccountsClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, filter string) (result MetricListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.ListMetrics") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "ListMetrics", err.Error()) - } - - req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListMetrics", nil, "Failure preparing request") - return - } - - resp, err := client.ListMetricsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListMetrics", resp, "Failure sending request") - return - } - - result, err = client.ListMetricsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListMetrics", resp, "Failure responding to request") - return - } - - return -} - -// ListMetricsPreparer prepares the ListMetrics request. -func (client DatabaseAccountsClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "$filter": autorest.Encode("query", filter), - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metrics", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListMetricsSender sends the ListMetrics request. The method will close the -// http.Response Body if it receives an error. -func (client DatabaseAccountsClient) ListMetricsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListMetricsResponder handles the response to the ListMetrics request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) ListMetricsResponder(resp *http.Response) (result MetricListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListReadOnlyKeys lists the read-only access keys for the specified Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client DatabaseAccountsClient) ListReadOnlyKeys(ctx context.Context, resourceGroupName string, accountName string) (result DatabaseAccountListReadOnlyKeysResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.ListReadOnlyKeys") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "ListReadOnlyKeys", err.Error()) - } - - req, err := client.ListReadOnlyKeysPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListReadOnlyKeys", nil, "Failure preparing request") - return - } - - resp, err := client.ListReadOnlyKeysSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListReadOnlyKeys", resp, "Failure sending request") - return - } - - result, err = client.ListReadOnlyKeysResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListReadOnlyKeys", resp, "Failure responding to request") - return - } - - return -} - -// ListReadOnlyKeysPreparer prepares the ListReadOnlyKeys request. -func (client DatabaseAccountsClient) ListReadOnlyKeysPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListReadOnlyKeysSender sends the ListReadOnlyKeys request. The method will close the -// http.Response Body if it receives an error. -func (client DatabaseAccountsClient) ListReadOnlyKeysSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListReadOnlyKeysResponder handles the response to the ListReadOnlyKeys request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) ListReadOnlyKeysResponder(resp *http.Response) (result DatabaseAccountListReadOnlyKeysResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListUsages retrieves the usages (most recent data) for the given database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// filter - an OData filter expression that describes a subset of usages to return. The supported parameter is -// name.value (name of the metric, can have an or of multiple names). -func (client DatabaseAccountsClient) ListUsages(ctx context.Context, resourceGroupName string, accountName string, filter string) (result UsagesResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.ListUsages") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "ListUsages", err.Error()) - } - - req, err := client.ListUsagesPreparer(ctx, resourceGroupName, accountName, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListUsages", nil, "Failure preparing request") - return - } - - resp, err := client.ListUsagesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListUsages", resp, "Failure sending request") - return - } - - result, err = client.ListUsagesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListUsages", resp, "Failure responding to request") - return - } - - return -} - -// ListUsagesPreparer prepares the ListUsages request. -func (client DatabaseAccountsClient) ListUsagesPreparer(ctx context.Context, resourceGroupName string, accountName string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/usages", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListUsagesSender sends the ListUsages request. The method will close the -// http.Response Body if it receives an error. -func (client DatabaseAccountsClient) ListUsagesSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListUsagesResponder handles the response to the ListUsages request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) ListUsagesResponder(resp *http.Response) (result UsagesResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// OfflineRegion offline the specified region for the specified Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// regionParameterForOffline - cosmos DB region to offline for the database account. -func (client DatabaseAccountsClient) OfflineRegion(ctx context.Context, resourceGroupName string, accountName string, regionParameterForOffline RegionForOnlineOffline) (result DatabaseAccountsOfflineRegionFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.OfflineRegion") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: regionParameterForOffline, - Constraints: []validation.Constraint{{Target: "regionParameterForOffline.Region", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "OfflineRegion", err.Error()) - } - - req, err := client.OfflineRegionPreparer(ctx, resourceGroupName, accountName, regionParameterForOffline) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "OfflineRegion", nil, "Failure preparing request") - return - } - - result, err = client.OfflineRegionSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "OfflineRegion", result.Response(), "Failure sending request") - return - } - - return -} - -// OfflineRegionPreparer prepares the OfflineRegion request. -func (client DatabaseAccountsClient) OfflineRegionPreparer(ctx context.Context, resourceGroupName string, accountName string, regionParameterForOffline RegionForOnlineOffline) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/offlineRegion", pathParameters), - autorest.WithJSON(regionParameterForOffline), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// OfflineRegionSender sends the OfflineRegion request. The method will close the -// http.Response Body if it receives an error. -func (client DatabaseAccountsClient) OfflineRegionSender(req *http.Request) (future DatabaseAccountsOfflineRegionFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// OfflineRegionResponder handles the response to the OfflineRegion request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) OfflineRegionResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByClosing()) - result.Response = resp - return -} - -// OnlineRegion online the specified region for the specified Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// regionParameterForOnline - cosmos DB region to online for the database account. -func (client DatabaseAccountsClient) OnlineRegion(ctx context.Context, resourceGroupName string, accountName string, regionParameterForOnline RegionForOnlineOffline) (result DatabaseAccountsOnlineRegionFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.OnlineRegion") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: regionParameterForOnline, - Constraints: []validation.Constraint{{Target: "regionParameterForOnline.Region", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "OnlineRegion", err.Error()) - } - - req, err := client.OnlineRegionPreparer(ctx, resourceGroupName, accountName, regionParameterForOnline) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "OnlineRegion", nil, "Failure preparing request") - return - } - - result, err = client.OnlineRegionSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "OnlineRegion", result.Response(), "Failure sending request") - return - } - - return -} - -// OnlineRegionPreparer prepares the OnlineRegion request. -func (client DatabaseAccountsClient) OnlineRegionPreparer(ctx context.Context, resourceGroupName string, accountName string, regionParameterForOnline RegionForOnlineOffline) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/onlineRegion", pathParameters), - autorest.WithJSON(regionParameterForOnline), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// OnlineRegionSender sends the OnlineRegion request. The method will close the -// http.Response Body if it receives an error. -func (client DatabaseAccountsClient) OnlineRegionSender(req *http.Request) (future DatabaseAccountsOnlineRegionFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// OnlineRegionResponder handles the response to the OnlineRegion request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) OnlineRegionResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByClosing()) - result.Response = resp - return -} - -// RegenerateKey regenerates an access key for the specified Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// keyToRegenerate - the name of the key to regenerate. -func (client DatabaseAccountsClient) RegenerateKey(ctx context.Context, resourceGroupName string, accountName string, keyToRegenerate DatabaseAccountRegenerateKeyParameters) (result DatabaseAccountsRegenerateKeyFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.RegenerateKey") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "RegenerateKey", err.Error()) - } - - req, err := client.RegenerateKeyPreparer(ctx, resourceGroupName, accountName, keyToRegenerate) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "RegenerateKey", nil, "Failure preparing request") - return - } - - result, err = client.RegenerateKeySender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "RegenerateKey", result.Response(), "Failure sending request") - return - } - - return -} - -// RegenerateKeyPreparer prepares the RegenerateKey request. -func (client DatabaseAccountsClient) RegenerateKeyPreparer(ctx context.Context, resourceGroupName string, accountName string, keyToRegenerate DatabaseAccountRegenerateKeyParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/regenerateKey", pathParameters), - autorest.WithJSON(keyToRegenerate), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// RegenerateKeySender sends the RegenerateKey request. The method will close the -// http.Response Body if it receives an error. -func (client DatabaseAccountsClient) RegenerateKeySender(req *http.Request) (future DatabaseAccountsRegenerateKeyFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// RegenerateKeyResponder handles the response to the RegenerateKey request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) RegenerateKeyResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByClosing()) - result.Response = resp - return -} - -// Update updates the properties of an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// updateParameters - the parameters to provide for the current database account. -func (client DatabaseAccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, updateParameters DatabaseAccountUpdateParameters) (result DatabaseAccountsUpdateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.Update") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "Update", err.Error()) - } - - req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, updateParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Update", nil, "Failure preparing request") - return - } - - result, err = client.UpdateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Update", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdatePreparer prepares the Update request. -func (client DatabaseAccountsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, updateParameters DatabaseAccountUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}", pathParameters), - autorest.WithJSON(updateParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateSender sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (client DatabaseAccountsClient) UpdateSender(req *http.Request) (future DatabaseAccountsUpdateFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// UpdateResponder handles the response to the Update request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) UpdateResponder(resp *http.Response) (result DatabaseAccountGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/enums.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/enums.go deleted file mode 100644 index c917d293c231..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/enums.go +++ /dev/null @@ -1,664 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -// AnalyticalStorageSchemaType enumerates the values for analytical storage schema type. -type AnalyticalStorageSchemaType string - -const ( - // AnalyticalStorageSchemaTypeFullFidelity ... - AnalyticalStorageSchemaTypeFullFidelity AnalyticalStorageSchemaType = "FullFidelity" - // AnalyticalStorageSchemaTypeWellDefined ... - AnalyticalStorageSchemaTypeWellDefined AnalyticalStorageSchemaType = "WellDefined" -) - -// PossibleAnalyticalStorageSchemaTypeValues returns an array of possible values for the AnalyticalStorageSchemaType const type. -func PossibleAnalyticalStorageSchemaTypeValues() []AnalyticalStorageSchemaType { - return []AnalyticalStorageSchemaType{AnalyticalStorageSchemaTypeFullFidelity, AnalyticalStorageSchemaTypeWellDefined} -} - -// APIType enumerates the values for api type. -type APIType string - -const ( - // APITypeCassandra ... - APITypeCassandra APIType = "Cassandra" - // APITypeGremlin ... - APITypeGremlin APIType = "Gremlin" - // APITypeGremlinV2 ... - APITypeGremlinV2 APIType = "GremlinV2" - // APITypeMongoDB ... - APITypeMongoDB APIType = "MongoDB" - // APITypeSQL ... - APITypeSQL APIType = "Sql" - // APITypeTable ... - APITypeTable APIType = "Table" -) - -// PossibleAPITypeValues returns an array of possible values for the APIType const type. -func PossibleAPITypeValues() []APIType { - return []APIType{APITypeCassandra, APITypeGremlin, APITypeGremlinV2, APITypeMongoDB, APITypeSQL, APITypeTable} -} - -// AuthenticationMethod enumerates the values for authentication method. -type AuthenticationMethod string - -const ( - // AuthenticationMethodCassandra ... - AuthenticationMethodCassandra AuthenticationMethod = "Cassandra" - // AuthenticationMethodNone ... - AuthenticationMethodNone AuthenticationMethod = "None" -) - -// PossibleAuthenticationMethodValues returns an array of possible values for the AuthenticationMethod const type. -func PossibleAuthenticationMethodValues() []AuthenticationMethod { - return []AuthenticationMethod{AuthenticationMethodCassandra, AuthenticationMethodNone} -} - -// BackupPolicyMigrationStatus enumerates the values for backup policy migration status. -type BackupPolicyMigrationStatus string - -const ( - // BackupPolicyMigrationStatusCompleted ... - BackupPolicyMigrationStatusCompleted BackupPolicyMigrationStatus = "Completed" - // BackupPolicyMigrationStatusFailed ... - BackupPolicyMigrationStatusFailed BackupPolicyMigrationStatus = "Failed" - // BackupPolicyMigrationStatusInProgress ... - BackupPolicyMigrationStatusInProgress BackupPolicyMigrationStatus = "InProgress" - // BackupPolicyMigrationStatusInvalid ... - BackupPolicyMigrationStatusInvalid BackupPolicyMigrationStatus = "Invalid" -) - -// PossibleBackupPolicyMigrationStatusValues returns an array of possible values for the BackupPolicyMigrationStatus const type. -func PossibleBackupPolicyMigrationStatusValues() []BackupPolicyMigrationStatus { - return []BackupPolicyMigrationStatus{BackupPolicyMigrationStatusCompleted, BackupPolicyMigrationStatusFailed, BackupPolicyMigrationStatusInProgress, BackupPolicyMigrationStatusInvalid} -} - -// BackupPolicyType enumerates the values for backup policy type. -type BackupPolicyType string - -const ( - // BackupPolicyTypeContinuous ... - BackupPolicyTypeContinuous BackupPolicyType = "Continuous" - // BackupPolicyTypePeriodic ... - BackupPolicyTypePeriodic BackupPolicyType = "Periodic" -) - -// PossibleBackupPolicyTypeValues returns an array of possible values for the BackupPolicyType const type. -func PossibleBackupPolicyTypeValues() []BackupPolicyType { - return []BackupPolicyType{BackupPolicyTypeContinuous, BackupPolicyTypePeriodic} -} - -// BackupStorageRedundancy enumerates the values for backup storage redundancy. -type BackupStorageRedundancy string - -const ( - // BackupStorageRedundancyGeo ... - BackupStorageRedundancyGeo BackupStorageRedundancy = "Geo" - // BackupStorageRedundancyLocal ... - BackupStorageRedundancyLocal BackupStorageRedundancy = "Local" - // BackupStorageRedundancyZone ... - BackupStorageRedundancyZone BackupStorageRedundancy = "Zone" -) - -// PossibleBackupStorageRedundancyValues returns an array of possible values for the BackupStorageRedundancy const type. -func PossibleBackupStorageRedundancyValues() []BackupStorageRedundancy { - return []BackupStorageRedundancy{BackupStorageRedundancyGeo, BackupStorageRedundancyLocal, BackupStorageRedundancyZone} -} - -// CompositePathSortOrder enumerates the values for composite path sort order. -type CompositePathSortOrder string - -const ( - // CompositePathSortOrderAscending ... - CompositePathSortOrderAscending CompositePathSortOrder = "ascending" - // CompositePathSortOrderDescending ... - CompositePathSortOrderDescending CompositePathSortOrder = "descending" -) - -// PossibleCompositePathSortOrderValues returns an array of possible values for the CompositePathSortOrder const type. -func PossibleCompositePathSortOrderValues() []CompositePathSortOrder { - return []CompositePathSortOrder{CompositePathSortOrderAscending, CompositePathSortOrderDescending} -} - -// ConflictResolutionMode enumerates the values for conflict resolution mode. -type ConflictResolutionMode string - -const ( - // ConflictResolutionModeCustom ... - ConflictResolutionModeCustom ConflictResolutionMode = "Custom" - // ConflictResolutionModeLastWriterWins ... - ConflictResolutionModeLastWriterWins ConflictResolutionMode = "LastWriterWins" -) - -// PossibleConflictResolutionModeValues returns an array of possible values for the ConflictResolutionMode const type. -func PossibleConflictResolutionModeValues() []ConflictResolutionMode { - return []ConflictResolutionMode{ConflictResolutionModeCustom, ConflictResolutionModeLastWriterWins} -} - -// ConnectionState enumerates the values for connection state. -type ConnectionState string - -const ( - // ConnectionStateDatacenterToDatacenterNetworkError ... - ConnectionStateDatacenterToDatacenterNetworkError ConnectionState = "DatacenterToDatacenterNetworkError" - // ConnectionStateInternalError ... - ConnectionStateInternalError ConnectionState = "InternalError" - // ConnectionStateInternalOperatorToDataCenterCertificateError ... - ConnectionStateInternalOperatorToDataCenterCertificateError ConnectionState = "InternalOperatorToDataCenterCertificateError" - // ConnectionStateOK ... - ConnectionStateOK ConnectionState = "OK" - // ConnectionStateOperatorToDataCenterNetworkError ... - ConnectionStateOperatorToDataCenterNetworkError ConnectionState = "OperatorToDataCenterNetworkError" - // ConnectionStateUnknown ... - ConnectionStateUnknown ConnectionState = "Unknown" -) - -// PossibleConnectionStateValues returns an array of possible values for the ConnectionState const type. -func PossibleConnectionStateValues() []ConnectionState { - return []ConnectionState{ConnectionStateDatacenterToDatacenterNetworkError, ConnectionStateInternalError, ConnectionStateInternalOperatorToDataCenterCertificateError, ConnectionStateOK, ConnectionStateOperatorToDataCenterNetworkError, ConnectionStateUnknown} -} - -// ConnectorOffer enumerates the values for connector offer. -type ConnectorOffer string - -const ( - // ConnectorOfferSmall ... - ConnectorOfferSmall ConnectorOffer = "Small" -) - -// PossibleConnectorOfferValues returns an array of possible values for the ConnectorOffer const type. -func PossibleConnectorOfferValues() []ConnectorOffer { - return []ConnectorOffer{ConnectorOfferSmall} -} - -// CreatedByType enumerates the values for created by type. -type CreatedByType string - -const ( - // CreatedByTypeApplication ... - CreatedByTypeApplication CreatedByType = "Application" - // CreatedByTypeKey ... - CreatedByTypeKey CreatedByType = "Key" - // CreatedByTypeManagedIdentity ... - CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" - // CreatedByTypeUser ... - CreatedByTypeUser CreatedByType = "User" -) - -// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. -func PossibleCreatedByTypeValues() []CreatedByType { - return []CreatedByType{CreatedByTypeApplication, CreatedByTypeKey, CreatedByTypeManagedIdentity, CreatedByTypeUser} -} - -// CreateMode enumerates the values for create mode. -type CreateMode string - -const ( - // CreateModeDefault ... - CreateModeDefault CreateMode = "Default" - // CreateModeRestore ... - CreateModeRestore CreateMode = "Restore" -) - -// PossibleCreateModeValues returns an array of possible values for the CreateMode const type. -func PossibleCreateModeValues() []CreateMode { - return []CreateMode{CreateModeDefault, CreateModeRestore} -} - -// DatabaseAccountKind enumerates the values for database account kind. -type DatabaseAccountKind string - -const ( - // DatabaseAccountKindGlobalDocumentDB ... - DatabaseAccountKindGlobalDocumentDB DatabaseAccountKind = "GlobalDocumentDB" - // DatabaseAccountKindMongoDB ... - DatabaseAccountKindMongoDB DatabaseAccountKind = "MongoDB" - // DatabaseAccountKindParse ... - DatabaseAccountKindParse DatabaseAccountKind = "Parse" -) - -// PossibleDatabaseAccountKindValues returns an array of possible values for the DatabaseAccountKind const type. -func PossibleDatabaseAccountKindValues() []DatabaseAccountKind { - return []DatabaseAccountKind{DatabaseAccountKindGlobalDocumentDB, DatabaseAccountKindMongoDB, DatabaseAccountKindParse} -} - -// DatabaseAccountOfferType enumerates the values for database account offer type. -type DatabaseAccountOfferType string - -const ( - // DatabaseAccountOfferTypeStandard ... - DatabaseAccountOfferTypeStandard DatabaseAccountOfferType = "Standard" -) - -// PossibleDatabaseAccountOfferTypeValues returns an array of possible values for the DatabaseAccountOfferType const type. -func PossibleDatabaseAccountOfferTypeValues() []DatabaseAccountOfferType { - return []DatabaseAccountOfferType{DatabaseAccountOfferTypeStandard} -} - -// DataType enumerates the values for data type. -type DataType string - -const ( - // DataTypeLineString ... - DataTypeLineString DataType = "LineString" - // DataTypeMultiPolygon ... - DataTypeMultiPolygon DataType = "MultiPolygon" - // DataTypeNumber ... - DataTypeNumber DataType = "Number" - // DataTypePoint ... - DataTypePoint DataType = "Point" - // DataTypePolygon ... - DataTypePolygon DataType = "Polygon" - // DataTypeString ... - DataTypeString DataType = "String" -) - -// PossibleDataTypeValues returns an array of possible values for the DataType const type. -func PossibleDataTypeValues() []DataType { - return []DataType{DataTypeLineString, DataTypeMultiPolygon, DataTypeNumber, DataTypePoint, DataTypePolygon, DataTypeString} -} - -// DefaultConsistencyLevel enumerates the values for default consistency level. -type DefaultConsistencyLevel string - -const ( - // DefaultConsistencyLevelBoundedStaleness ... - DefaultConsistencyLevelBoundedStaleness DefaultConsistencyLevel = "BoundedStaleness" - // DefaultConsistencyLevelConsistentPrefix ... - DefaultConsistencyLevelConsistentPrefix DefaultConsistencyLevel = "ConsistentPrefix" - // DefaultConsistencyLevelEventual ... - DefaultConsistencyLevelEventual DefaultConsistencyLevel = "Eventual" - // DefaultConsistencyLevelSession ... - DefaultConsistencyLevelSession DefaultConsistencyLevel = "Session" - // DefaultConsistencyLevelStrong ... - DefaultConsistencyLevelStrong DefaultConsistencyLevel = "Strong" -) - -// PossibleDefaultConsistencyLevelValues returns an array of possible values for the DefaultConsistencyLevel const type. -func PossibleDefaultConsistencyLevelValues() []DefaultConsistencyLevel { - return []DefaultConsistencyLevel{DefaultConsistencyLevelBoundedStaleness, DefaultConsistencyLevelConsistentPrefix, DefaultConsistencyLevelEventual, DefaultConsistencyLevelSession, DefaultConsistencyLevelStrong} -} - -// IndexingMode enumerates the values for indexing mode. -type IndexingMode string - -const ( - // IndexingModeConsistent ... - IndexingModeConsistent IndexingMode = "consistent" - // IndexingModeLazy ... - IndexingModeLazy IndexingMode = "lazy" - // IndexingModeNone ... - IndexingModeNone IndexingMode = "none" -) - -// PossibleIndexingModeValues returns an array of possible values for the IndexingMode const type. -func PossibleIndexingModeValues() []IndexingMode { - return []IndexingMode{IndexingModeConsistent, IndexingModeLazy, IndexingModeNone} -} - -// IndexKind enumerates the values for index kind. -type IndexKind string - -const ( - // IndexKindHash ... - IndexKindHash IndexKind = "Hash" - // IndexKindRange ... - IndexKindRange IndexKind = "Range" - // IndexKindSpatial ... - IndexKindSpatial IndexKind = "Spatial" -) - -// PossibleIndexKindValues returns an array of possible values for the IndexKind const type. -func PossibleIndexKindValues() []IndexKind { - return []IndexKind{IndexKindHash, IndexKindRange, IndexKindSpatial} -} - -// KeyKind enumerates the values for key kind. -type KeyKind string - -const ( - // KeyKindPrimary ... - KeyKindPrimary KeyKind = "primary" - // KeyKindPrimaryReadonly ... - KeyKindPrimaryReadonly KeyKind = "primaryReadonly" - // KeyKindSecondary ... - KeyKindSecondary KeyKind = "secondary" - // KeyKindSecondaryReadonly ... - KeyKindSecondaryReadonly KeyKind = "secondaryReadonly" -) - -// PossibleKeyKindValues returns an array of possible values for the KeyKind const type. -func PossibleKeyKindValues() []KeyKind { - return []KeyKind{KeyKindPrimary, KeyKindPrimaryReadonly, KeyKindSecondary, KeyKindSecondaryReadonly} -} - -// ManagedCassandraProvisioningState enumerates the values for managed cassandra provisioning state. -type ManagedCassandraProvisioningState string - -const ( - // ManagedCassandraProvisioningStateCanceled ... - ManagedCassandraProvisioningStateCanceled ManagedCassandraProvisioningState = "Canceled" - // ManagedCassandraProvisioningStateCreating ... - ManagedCassandraProvisioningStateCreating ManagedCassandraProvisioningState = "Creating" - // ManagedCassandraProvisioningStateDeleting ... - ManagedCassandraProvisioningStateDeleting ManagedCassandraProvisioningState = "Deleting" - // ManagedCassandraProvisioningStateFailed ... - ManagedCassandraProvisioningStateFailed ManagedCassandraProvisioningState = "Failed" - // ManagedCassandraProvisioningStateSucceeded ... - ManagedCassandraProvisioningStateSucceeded ManagedCassandraProvisioningState = "Succeeded" - // ManagedCassandraProvisioningStateUpdating ... - ManagedCassandraProvisioningStateUpdating ManagedCassandraProvisioningState = "Updating" -) - -// PossibleManagedCassandraProvisioningStateValues returns an array of possible values for the ManagedCassandraProvisioningState const type. -func PossibleManagedCassandraProvisioningStateValues() []ManagedCassandraProvisioningState { - return []ManagedCassandraProvisioningState{ManagedCassandraProvisioningStateCanceled, ManagedCassandraProvisioningStateCreating, ManagedCassandraProvisioningStateDeleting, ManagedCassandraProvisioningStateFailed, ManagedCassandraProvisioningStateSucceeded, ManagedCassandraProvisioningStateUpdating} -} - -// ManagedCassandraResourceIdentityType enumerates the values for managed cassandra resource identity type. -type ManagedCassandraResourceIdentityType string - -const ( - // ManagedCassandraResourceIdentityTypeNone ... - ManagedCassandraResourceIdentityTypeNone ManagedCassandraResourceIdentityType = "None" - // ManagedCassandraResourceIdentityTypeSystemAssigned ... - ManagedCassandraResourceIdentityTypeSystemAssigned ManagedCassandraResourceIdentityType = "SystemAssigned" -) - -// PossibleManagedCassandraResourceIdentityTypeValues returns an array of possible values for the ManagedCassandraResourceIdentityType const type. -func PossibleManagedCassandraResourceIdentityTypeValues() []ManagedCassandraResourceIdentityType { - return []ManagedCassandraResourceIdentityType{ManagedCassandraResourceIdentityTypeNone, ManagedCassandraResourceIdentityTypeSystemAssigned} -} - -// NetworkACLBypass enumerates the values for network acl bypass. -type NetworkACLBypass string - -const ( - // NetworkACLBypassAzureServices ... - NetworkACLBypassAzureServices NetworkACLBypass = "AzureServices" - // NetworkACLBypassNone ... - NetworkACLBypassNone NetworkACLBypass = "None" -) - -// PossibleNetworkACLBypassValues returns an array of possible values for the NetworkACLBypass const type. -func PossibleNetworkACLBypassValues() []NetworkACLBypass { - return []NetworkACLBypass{NetworkACLBypassAzureServices, NetworkACLBypassNone} -} - -// NodeState enumerates the values for node state. -type NodeState string - -const ( - // NodeStateJoining ... - NodeStateJoining NodeState = "Joining" - // NodeStateLeaving ... - NodeStateLeaving NodeState = "Leaving" - // NodeStateMoving ... - NodeStateMoving NodeState = "Moving" - // NodeStateNormal ... - NodeStateNormal NodeState = "Normal" - // NodeStateStopped ... - NodeStateStopped NodeState = "Stopped" -) - -// PossibleNodeStateValues returns an array of possible values for the NodeState const type. -func PossibleNodeStateValues() []NodeState { - return []NodeState{NodeStateJoining, NodeStateLeaving, NodeStateMoving, NodeStateNormal, NodeStateStopped} -} - -// NodeStatus enumerates the values for node status. -type NodeStatus string - -const ( - // NodeStatusDown ... - NodeStatusDown NodeStatus = "Down" - // NodeStatusUp ... - NodeStatusUp NodeStatus = "Up" -) - -// PossibleNodeStatusValues returns an array of possible values for the NodeStatus const type. -func PossibleNodeStatusValues() []NodeStatus { - return []NodeStatus{NodeStatusDown, NodeStatusUp} -} - -// OperationType enumerates the values for operation type. -type OperationType string - -const ( - // OperationTypeCreate ... - OperationTypeCreate OperationType = "Create" - // OperationTypeDelete ... - OperationTypeDelete OperationType = "Delete" - // OperationTypeReplace ... - OperationTypeReplace OperationType = "Replace" - // OperationTypeSystemOperation ... - OperationTypeSystemOperation OperationType = "SystemOperation" -) - -// PossibleOperationTypeValues returns an array of possible values for the OperationType const type. -func PossibleOperationTypeValues() []OperationType { - return []OperationType{OperationTypeCreate, OperationTypeDelete, OperationTypeReplace, OperationTypeSystemOperation} -} - -// PartitionKind enumerates the values for partition kind. -type PartitionKind string - -const ( - // PartitionKindHash ... - PartitionKindHash PartitionKind = "Hash" - // PartitionKindMultiHash ... - PartitionKindMultiHash PartitionKind = "MultiHash" - // PartitionKindRange ... - PartitionKindRange PartitionKind = "Range" -) - -// PossiblePartitionKindValues returns an array of possible values for the PartitionKind const type. -func PossiblePartitionKindValues() []PartitionKind { - return []PartitionKind{PartitionKindHash, PartitionKindMultiHash, PartitionKindRange} -} - -// PrimaryAggregationType enumerates the values for primary aggregation type. -type PrimaryAggregationType string - -const ( - // PrimaryAggregationTypeAverage ... - PrimaryAggregationTypeAverage PrimaryAggregationType = "Average" - // PrimaryAggregationTypeLast ... - PrimaryAggregationTypeLast PrimaryAggregationType = "Last" - // PrimaryAggregationTypeMaximum ... - PrimaryAggregationTypeMaximum PrimaryAggregationType = "Maximum" - // PrimaryAggregationTypeMinimum ... - PrimaryAggregationTypeMinimum PrimaryAggregationType = "Minimum" - // PrimaryAggregationTypeNone ... - PrimaryAggregationTypeNone PrimaryAggregationType = "None" - // PrimaryAggregationTypeTotal ... - PrimaryAggregationTypeTotal PrimaryAggregationType = "Total" -) - -// PossiblePrimaryAggregationTypeValues returns an array of possible values for the PrimaryAggregationType const type. -func PossiblePrimaryAggregationTypeValues() []PrimaryAggregationType { - return []PrimaryAggregationType{PrimaryAggregationTypeAverage, PrimaryAggregationTypeLast, PrimaryAggregationTypeMaximum, PrimaryAggregationTypeMinimum, PrimaryAggregationTypeNone, PrimaryAggregationTypeTotal} -} - -// PublicNetworkAccess enumerates the values for public network access. -type PublicNetworkAccess string - -const ( - // PublicNetworkAccessDisabled ... - PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" - // PublicNetworkAccessEnabled ... - PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" -) - -// PossiblePublicNetworkAccessValues returns an array of possible values for the PublicNetworkAccess const type. -func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { - return []PublicNetworkAccess{PublicNetworkAccessDisabled, PublicNetworkAccessEnabled} -} - -// ResourceIdentityType enumerates the values for resource identity type. -type ResourceIdentityType string - -const ( - // ResourceIdentityTypeNone ... - ResourceIdentityTypeNone ResourceIdentityType = "None" - // ResourceIdentityTypeSystemAssigned ... - ResourceIdentityTypeSystemAssigned ResourceIdentityType = "SystemAssigned" - // ResourceIdentityTypeSystemAssignedUserAssigned ... - ResourceIdentityTypeSystemAssignedUserAssigned ResourceIdentityType = "SystemAssigned,UserAssigned" - // ResourceIdentityTypeUserAssigned ... - ResourceIdentityTypeUserAssigned ResourceIdentityType = "UserAssigned" -) - -// PossibleResourceIdentityTypeValues returns an array of possible values for the ResourceIdentityType const type. -func PossibleResourceIdentityTypeValues() []ResourceIdentityType { - return []ResourceIdentityType{ResourceIdentityTypeNone, ResourceIdentityTypeSystemAssigned, ResourceIdentityTypeSystemAssignedUserAssigned, ResourceIdentityTypeUserAssigned} -} - -// RestoreMode enumerates the values for restore mode. -type RestoreMode string - -const ( - // RestoreModePointInTime ... - RestoreModePointInTime RestoreMode = "PointInTime" -) - -// PossibleRestoreModeValues returns an array of possible values for the RestoreMode const type. -func PossibleRestoreModeValues() []RestoreMode { - return []RestoreMode{RestoreModePointInTime} -} - -// RoleDefinitionType enumerates the values for role definition type. -type RoleDefinitionType string - -const ( - // RoleDefinitionTypeBuiltInRole ... - RoleDefinitionTypeBuiltInRole RoleDefinitionType = "BuiltInRole" - // RoleDefinitionTypeCustomRole ... - RoleDefinitionTypeCustomRole RoleDefinitionType = "CustomRole" -) - -// PossibleRoleDefinitionTypeValues returns an array of possible values for the RoleDefinitionType const type. -func PossibleRoleDefinitionTypeValues() []RoleDefinitionType { - return []RoleDefinitionType{RoleDefinitionTypeBuiltInRole, RoleDefinitionTypeCustomRole} -} - -// ServerVersion enumerates the values for server version. -type ServerVersion string - -const ( - // ServerVersionFourFullStopTwo ... - ServerVersionFourFullStopTwo ServerVersion = "4.2" - // ServerVersionFourFullStopZero ... - ServerVersionFourFullStopZero ServerVersion = "4.0" - // ServerVersionThreeFullStopSix ... - ServerVersionThreeFullStopSix ServerVersion = "3.6" - // ServerVersionThreeFullStopTwo ... - ServerVersionThreeFullStopTwo ServerVersion = "3.2" -) - -// PossibleServerVersionValues returns an array of possible values for the ServerVersion const type. -func PossibleServerVersionValues() []ServerVersion { - return []ServerVersion{ServerVersionFourFullStopTwo, ServerVersionFourFullStopZero, ServerVersionThreeFullStopSix, ServerVersionThreeFullStopTwo} -} - -// SpatialType enumerates the values for spatial type. -type SpatialType string - -const ( - // SpatialTypeLineString ... - SpatialTypeLineString SpatialType = "LineString" - // SpatialTypeMultiPolygon ... - SpatialTypeMultiPolygon SpatialType = "MultiPolygon" - // SpatialTypePoint ... - SpatialTypePoint SpatialType = "Point" - // SpatialTypePolygon ... - SpatialTypePolygon SpatialType = "Polygon" -) - -// PossibleSpatialTypeValues returns an array of possible values for the SpatialType const type. -func PossibleSpatialTypeValues() []SpatialType { - return []SpatialType{SpatialTypeLineString, SpatialTypeMultiPolygon, SpatialTypePoint, SpatialTypePolygon} -} - -// TriggerOperation enumerates the values for trigger operation. -type TriggerOperation string - -const ( - // TriggerOperationAll ... - TriggerOperationAll TriggerOperation = "All" - // TriggerOperationCreate ... - TriggerOperationCreate TriggerOperation = "Create" - // TriggerOperationDelete ... - TriggerOperationDelete TriggerOperation = "Delete" - // TriggerOperationReplace ... - TriggerOperationReplace TriggerOperation = "Replace" - // TriggerOperationUpdate ... - TriggerOperationUpdate TriggerOperation = "Update" -) - -// PossibleTriggerOperationValues returns an array of possible values for the TriggerOperation const type. -func PossibleTriggerOperationValues() []TriggerOperation { - return []TriggerOperation{TriggerOperationAll, TriggerOperationCreate, TriggerOperationDelete, TriggerOperationReplace, TriggerOperationUpdate} -} - -// TriggerType enumerates the values for trigger type. -type TriggerType string - -const ( - // TriggerTypePost ... - TriggerTypePost TriggerType = "Post" - // TriggerTypePre ... - TriggerTypePre TriggerType = "Pre" -) - -// PossibleTriggerTypeValues returns an array of possible values for the TriggerType const type. -func PossibleTriggerTypeValues() []TriggerType { - return []TriggerType{TriggerTypePost, TriggerTypePre} -} - -// Type enumerates the values for type. -type Type string - -const ( - // TypeBackupPolicy ... - TypeBackupPolicy Type = "BackupPolicy" - // TypeContinuous ... - TypeContinuous Type = "Continuous" - // TypePeriodic ... - TypePeriodic Type = "Periodic" -) - -// PossibleTypeValues returns an array of possible values for the Type const type. -func PossibleTypeValues() []Type { - return []Type{TypeBackupPolicy, TypeContinuous, TypePeriodic} -} - -// UnitType enumerates the values for unit type. -type UnitType string - -const ( - // UnitTypeBytes ... - UnitTypeBytes UnitType = "Bytes" - // UnitTypeBytesPerSecond ... - UnitTypeBytesPerSecond UnitType = "BytesPerSecond" - // UnitTypeCount ... - UnitTypeCount UnitType = "Count" - // UnitTypeCountPerSecond ... - UnitTypeCountPerSecond UnitType = "CountPerSecond" - // UnitTypeMilliseconds ... - UnitTypeMilliseconds UnitType = "Milliseconds" - // UnitTypePercent ... - UnitTypePercent UnitType = "Percent" - // UnitTypeSeconds ... - UnitTypeSeconds UnitType = "Seconds" -) - -// PossibleUnitTypeValues returns an array of possible values for the UnitType const type. -func PossibleUnitTypeValues() []UnitType { - return []UnitType{UnitTypeBytes, UnitTypeBytesPerSecond, UnitTypeCount, UnitTypeCountPerSecond, UnitTypeMilliseconds, UnitTypePercent, UnitTypeSeconds} -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/gremlinresources.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/gremlinresources.go deleted file mode 100644 index 4e2bf31809f3..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/gremlinresources.go +++ /dev/null @@ -1,1577 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// GremlinResourcesClient is the client for the GremlinResources methods of the Documentdb service. -type GremlinResourcesClient struct { - BaseClient -} - -// NewGremlinResourcesClient creates an instance of the GremlinResourcesClient client. -func NewGremlinResourcesClient(subscriptionID string) GremlinResourcesClient { - return NewGremlinResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewGremlinResourcesClientWithBaseURI creates an instance of the GremlinResourcesClient client using a custom -// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure -// stack). -func NewGremlinResourcesClientWithBaseURI(baseURI string, subscriptionID string) GremlinResourcesClient { - return GremlinResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateUpdateGremlinDatabase create or update an Azure Cosmos DB Gremlin database -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// createUpdateGremlinDatabaseParameters - the parameters to provide for the current Gremlin database. -func (client GremlinResourcesClient) CreateUpdateGremlinDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateGremlinDatabaseParameters GremlinDatabaseCreateUpdateParameters) (result GremlinResourcesCreateUpdateGremlinDatabaseFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.CreateUpdateGremlinDatabase") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: createUpdateGremlinDatabaseParameters, - Constraints: []validation.Constraint{{Target: "createUpdateGremlinDatabaseParameters.GremlinDatabaseCreateUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateGremlinDatabaseParameters.GremlinDatabaseCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateGremlinDatabaseParameters.GremlinDatabaseCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.GremlinResourcesClient", "CreateUpdateGremlinDatabase", err.Error()) - } - - req, err := client.CreateUpdateGremlinDatabasePreparer(ctx, resourceGroupName, accountName, databaseName, createUpdateGremlinDatabaseParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "CreateUpdateGremlinDatabase", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateGremlinDatabaseSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "CreateUpdateGremlinDatabase", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdateGremlinDatabasePreparer prepares the CreateUpdateGremlinDatabase request. -func (client GremlinResourcesClient) CreateUpdateGremlinDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateGremlinDatabaseParameters GremlinDatabaseCreateUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}", pathParameters), - autorest.WithJSON(createUpdateGremlinDatabaseParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateUpdateGremlinDatabaseSender sends the CreateUpdateGremlinDatabase request. The method will close the -// http.Response Body if it receives an error. -func (client GremlinResourcesClient) CreateUpdateGremlinDatabaseSender(req *http.Request) (future GremlinResourcesCreateUpdateGremlinDatabaseFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// CreateUpdateGremlinDatabaseResponder handles the response to the CreateUpdateGremlinDatabase request. The method always -// closes the http.Response Body. -func (client GremlinResourcesClient) CreateUpdateGremlinDatabaseResponder(resp *http.Response) (result GremlinDatabaseGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateUpdateGremlinGraph create or update an Azure Cosmos DB Gremlin graph -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// graphName - cosmos DB graph name. -// createUpdateGremlinGraphParameters - the parameters to provide for the current Gremlin graph. -func (client GremlinResourcesClient) CreateUpdateGremlinGraph(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string, createUpdateGremlinGraphParameters GremlinGraphCreateUpdateParameters) (result GremlinResourcesCreateUpdateGremlinGraphFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.CreateUpdateGremlinGraph") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: createUpdateGremlinGraphParameters, - Constraints: []validation.Constraint{{Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource.PartitionKey", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource.PartitionKey.Version", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource.PartitionKey.Version", Name: validation.InclusiveMaximum, Rule: int64(2), Chain: nil}, - {Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Resource.PartitionKey.Version", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, - }}, - }}, - }}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.GremlinResourcesClient", "CreateUpdateGremlinGraph", err.Error()) - } - - req, err := client.CreateUpdateGremlinGraphPreparer(ctx, resourceGroupName, accountName, databaseName, graphName, createUpdateGremlinGraphParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "CreateUpdateGremlinGraph", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateGremlinGraphSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "CreateUpdateGremlinGraph", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdateGremlinGraphPreparer prepares the CreateUpdateGremlinGraph request. -func (client GremlinResourcesClient) CreateUpdateGremlinGraphPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string, createUpdateGremlinGraphParameters GremlinGraphCreateUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "graphName": autorest.Encode("path", graphName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}", pathParameters), - autorest.WithJSON(createUpdateGremlinGraphParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateUpdateGremlinGraphSender sends the CreateUpdateGremlinGraph request. The method will close the -// http.Response Body if it receives an error. -func (client GremlinResourcesClient) CreateUpdateGremlinGraphSender(req *http.Request) (future GremlinResourcesCreateUpdateGremlinGraphFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// CreateUpdateGremlinGraphResponder handles the response to the CreateUpdateGremlinGraph request. The method always -// closes the http.Response Body. -func (client GremlinResourcesClient) CreateUpdateGremlinGraphResponder(resp *http.Response) (result GremlinGraphGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// DeleteGremlinDatabase deletes an existing Azure Cosmos DB Gremlin database. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client GremlinResourcesClient) DeleteGremlinDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result GremlinResourcesDeleteGremlinDatabaseFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.DeleteGremlinDatabase") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.GremlinResourcesClient", "DeleteGremlinDatabase", err.Error()) - } - - req, err := client.DeleteGremlinDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "DeleteGremlinDatabase", nil, "Failure preparing request") - return - } - - result, err = client.DeleteGremlinDatabaseSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "DeleteGremlinDatabase", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteGremlinDatabasePreparer prepares the DeleteGremlinDatabase request. -func (client GremlinResourcesClient) DeleteGremlinDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteGremlinDatabaseSender sends the DeleteGremlinDatabase request. The method will close the -// http.Response Body if it receives an error. -func (client GremlinResourcesClient) DeleteGremlinDatabaseSender(req *http.Request) (future GremlinResourcesDeleteGremlinDatabaseFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteGremlinDatabaseResponder handles the response to the DeleteGremlinDatabase request. The method always -// closes the http.Response Body. -func (client GremlinResourcesClient) DeleteGremlinDatabaseResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// DeleteGremlinGraph deletes an existing Azure Cosmos DB Gremlin graph. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// graphName - cosmos DB graph name. -func (client GremlinResourcesClient) DeleteGremlinGraph(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result GremlinResourcesDeleteGremlinGraphFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.DeleteGremlinGraph") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.GremlinResourcesClient", "DeleteGremlinGraph", err.Error()) - } - - req, err := client.DeleteGremlinGraphPreparer(ctx, resourceGroupName, accountName, databaseName, graphName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "DeleteGremlinGraph", nil, "Failure preparing request") - return - } - - result, err = client.DeleteGremlinGraphSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "DeleteGremlinGraph", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteGremlinGraphPreparer prepares the DeleteGremlinGraph request. -func (client GremlinResourcesClient) DeleteGremlinGraphPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "graphName": autorest.Encode("path", graphName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteGremlinGraphSender sends the DeleteGremlinGraph request. The method will close the -// http.Response Body if it receives an error. -func (client GremlinResourcesClient) DeleteGremlinGraphSender(req *http.Request) (future GremlinResourcesDeleteGremlinGraphFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteGremlinGraphResponder handles the response to the DeleteGremlinGraph request. The method always -// closes the http.Response Body. -func (client GremlinResourcesClient) DeleteGremlinGraphResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// GetGremlinDatabase gets the Gremlin databases under an existing Azure Cosmos DB database account with the provided -// name. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client GremlinResourcesClient) GetGremlinDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result GremlinDatabaseGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.GetGremlinDatabase") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.GremlinResourcesClient", "GetGremlinDatabase", err.Error()) - } - - req, err := client.GetGremlinDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabase", nil, "Failure preparing request") - return - } - - resp, err := client.GetGremlinDatabaseSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabase", resp, "Failure sending request") - return - } - - result, err = client.GetGremlinDatabaseResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabase", resp, "Failure responding to request") - return - } - - return -} - -// GetGremlinDatabasePreparer prepares the GetGremlinDatabase request. -func (client GremlinResourcesClient) GetGremlinDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetGremlinDatabaseSender sends the GetGremlinDatabase request. The method will close the -// http.Response Body if it receives an error. -func (client GremlinResourcesClient) GetGremlinDatabaseSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetGremlinDatabaseResponder handles the response to the GetGremlinDatabase request. The method always -// closes the http.Response Body. -func (client GremlinResourcesClient) GetGremlinDatabaseResponder(resp *http.Response) (result GremlinDatabaseGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetGremlinDatabaseThroughput gets the RUs per second of the Gremlin database under an existing Azure Cosmos DB -// database account with the provided name. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client GremlinResourcesClient) GetGremlinDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result ThroughputSettingsGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.GetGremlinDatabaseThroughput") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.GremlinResourcesClient", "GetGremlinDatabaseThroughput", err.Error()) - } - - req, err := client.GetGremlinDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabaseThroughput", nil, "Failure preparing request") - return - } - - resp, err := client.GetGremlinDatabaseThroughputSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabaseThroughput", resp, "Failure sending request") - return - } - - result, err = client.GetGremlinDatabaseThroughputResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinDatabaseThroughput", resp, "Failure responding to request") - return - } - - return -} - -// GetGremlinDatabaseThroughputPreparer prepares the GetGremlinDatabaseThroughput request. -func (client GremlinResourcesClient) GetGremlinDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetGremlinDatabaseThroughputSender sends the GetGremlinDatabaseThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client GremlinResourcesClient) GetGremlinDatabaseThroughputSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetGremlinDatabaseThroughputResponder handles the response to the GetGremlinDatabaseThroughput request. The method always -// closes the http.Response Body. -func (client GremlinResourcesClient) GetGremlinDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetGremlinGraph gets the Gremlin graph under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// graphName - cosmos DB graph name. -func (client GremlinResourcesClient) GetGremlinGraph(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result GremlinGraphGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.GetGremlinGraph") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.GremlinResourcesClient", "GetGremlinGraph", err.Error()) - } - - req, err := client.GetGremlinGraphPreparer(ctx, resourceGroupName, accountName, databaseName, graphName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraph", nil, "Failure preparing request") - return - } - - resp, err := client.GetGremlinGraphSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraph", resp, "Failure sending request") - return - } - - result, err = client.GetGremlinGraphResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraph", resp, "Failure responding to request") - return - } - - return -} - -// GetGremlinGraphPreparer prepares the GetGremlinGraph request. -func (client GremlinResourcesClient) GetGremlinGraphPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "graphName": autorest.Encode("path", graphName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetGremlinGraphSender sends the GetGremlinGraph request. The method will close the -// http.Response Body if it receives an error. -func (client GremlinResourcesClient) GetGremlinGraphSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetGremlinGraphResponder handles the response to the GetGremlinGraph request. The method always -// closes the http.Response Body. -func (client GremlinResourcesClient) GetGremlinGraphResponder(resp *http.Response) (result GremlinGraphGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetGremlinGraphThroughput gets the Gremlin graph throughput under an existing Azure Cosmos DB database account with -// the provided name. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// graphName - cosmos DB graph name. -func (client GremlinResourcesClient) GetGremlinGraphThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result ThroughputSettingsGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.GetGremlinGraphThroughput") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.GremlinResourcesClient", "GetGremlinGraphThroughput", err.Error()) - } - - req, err := client.GetGremlinGraphThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, graphName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraphThroughput", nil, "Failure preparing request") - return - } - - resp, err := client.GetGremlinGraphThroughputSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraphThroughput", resp, "Failure sending request") - return - } - - result, err = client.GetGremlinGraphThroughputResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "GetGremlinGraphThroughput", resp, "Failure responding to request") - return - } - - return -} - -// GetGremlinGraphThroughputPreparer prepares the GetGremlinGraphThroughput request. -func (client GremlinResourcesClient) GetGremlinGraphThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "graphName": autorest.Encode("path", graphName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetGremlinGraphThroughputSender sends the GetGremlinGraphThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client GremlinResourcesClient) GetGremlinGraphThroughputSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetGremlinGraphThroughputResponder handles the response to the GetGremlinGraphThroughput request. The method always -// closes the http.Response Body. -func (client GremlinResourcesClient) GetGremlinGraphThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListGremlinDatabases lists the Gremlin databases under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client GremlinResourcesClient) ListGremlinDatabases(ctx context.Context, resourceGroupName string, accountName string) (result GremlinDatabaseListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.ListGremlinDatabases") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.GremlinResourcesClient", "ListGremlinDatabases", err.Error()) - } - - req, err := client.ListGremlinDatabasesPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinDatabases", nil, "Failure preparing request") - return - } - - resp, err := client.ListGremlinDatabasesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinDatabases", resp, "Failure sending request") - return - } - - result, err = client.ListGremlinDatabasesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinDatabases", resp, "Failure responding to request") - return - } - - return -} - -// ListGremlinDatabasesPreparer prepares the ListGremlinDatabases request. -func (client GremlinResourcesClient) ListGremlinDatabasesPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListGremlinDatabasesSender sends the ListGremlinDatabases request. The method will close the -// http.Response Body if it receives an error. -func (client GremlinResourcesClient) ListGremlinDatabasesSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListGremlinDatabasesResponder handles the response to the ListGremlinDatabases request. The method always -// closes the http.Response Body. -func (client GremlinResourcesClient) ListGremlinDatabasesResponder(resp *http.Response) (result GremlinDatabaseListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListGremlinGraphs lists the Gremlin graph under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client GremlinResourcesClient) ListGremlinGraphs(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result GremlinGraphListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.ListGremlinGraphs") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.GremlinResourcesClient", "ListGremlinGraphs", err.Error()) - } - - req, err := client.ListGremlinGraphsPreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinGraphs", nil, "Failure preparing request") - return - } - - resp, err := client.ListGremlinGraphsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinGraphs", resp, "Failure sending request") - return - } - - result, err = client.ListGremlinGraphsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "ListGremlinGraphs", resp, "Failure responding to request") - return - } - - return -} - -// ListGremlinGraphsPreparer prepares the ListGremlinGraphs request. -func (client GremlinResourcesClient) ListGremlinGraphsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListGremlinGraphsSender sends the ListGremlinGraphs request. The method will close the -// http.Response Body if it receives an error. -func (client GremlinResourcesClient) ListGremlinGraphsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListGremlinGraphsResponder handles the response to the ListGremlinGraphs request. The method always -// closes the http.Response Body. -func (client GremlinResourcesClient) ListGremlinGraphsResponder(resp *http.Response) (result GremlinGraphListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// MigrateGremlinDatabaseToAutoscale migrate an Azure Cosmos DB Gremlin database from manual throughput to autoscale -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client GremlinResourcesClient) MigrateGremlinDatabaseToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.MigrateGremlinDatabaseToAutoscale") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.GremlinResourcesClient", "MigrateGremlinDatabaseToAutoscale", err.Error()) - } - - req, err := client.MigrateGremlinDatabaseToAutoscalePreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinDatabaseToAutoscale", nil, "Failure preparing request") - return - } - - result, err = client.MigrateGremlinDatabaseToAutoscaleSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinDatabaseToAutoscale", result.Response(), "Failure sending request") - return - } - - return -} - -// MigrateGremlinDatabaseToAutoscalePreparer prepares the MigrateGremlinDatabaseToAutoscale request. -func (client GremlinResourcesClient) MigrateGremlinDatabaseToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// MigrateGremlinDatabaseToAutoscaleSender sends the MigrateGremlinDatabaseToAutoscale request. The method will close the -// http.Response Body if it receives an error. -func (client GremlinResourcesClient) MigrateGremlinDatabaseToAutoscaleSender(req *http.Request) (future GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// MigrateGremlinDatabaseToAutoscaleResponder handles the response to the MigrateGremlinDatabaseToAutoscale request. The method always -// closes the http.Response Body. -func (client GremlinResourcesClient) MigrateGremlinDatabaseToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// MigrateGremlinDatabaseToManualThroughput migrate an Azure Cosmos DB Gremlin database from autoscale to manual -// throughput -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client GremlinResourcesClient) MigrateGremlinDatabaseToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.MigrateGremlinDatabaseToManualThroughput") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.GremlinResourcesClient", "MigrateGremlinDatabaseToManualThroughput", err.Error()) - } - - req, err := client.MigrateGremlinDatabaseToManualThroughputPreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinDatabaseToManualThroughput", nil, "Failure preparing request") - return - } - - result, err = client.MigrateGremlinDatabaseToManualThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinDatabaseToManualThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// MigrateGremlinDatabaseToManualThroughputPreparer prepares the MigrateGremlinDatabaseToManualThroughput request. -func (client GremlinResourcesClient) MigrateGremlinDatabaseToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// MigrateGremlinDatabaseToManualThroughputSender sends the MigrateGremlinDatabaseToManualThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client GremlinResourcesClient) MigrateGremlinDatabaseToManualThroughputSender(req *http.Request) (future GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// MigrateGremlinDatabaseToManualThroughputResponder handles the response to the MigrateGremlinDatabaseToManualThroughput request. The method always -// closes the http.Response Body. -func (client GremlinResourcesClient) MigrateGremlinDatabaseToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// MigrateGremlinGraphToAutoscale migrate an Azure Cosmos DB Gremlin graph from manual throughput to autoscale -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// graphName - cosmos DB graph name. -func (client GremlinResourcesClient) MigrateGremlinGraphToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result GremlinResourcesMigrateGremlinGraphToAutoscaleFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.MigrateGremlinGraphToAutoscale") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.GremlinResourcesClient", "MigrateGremlinGraphToAutoscale", err.Error()) - } - - req, err := client.MigrateGremlinGraphToAutoscalePreparer(ctx, resourceGroupName, accountName, databaseName, graphName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinGraphToAutoscale", nil, "Failure preparing request") - return - } - - result, err = client.MigrateGremlinGraphToAutoscaleSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinGraphToAutoscale", result.Response(), "Failure sending request") - return - } - - return -} - -// MigrateGremlinGraphToAutoscalePreparer prepares the MigrateGremlinGraphToAutoscale request. -func (client GremlinResourcesClient) MigrateGremlinGraphToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "graphName": autorest.Encode("path", graphName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default/migrateToAutoscale", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// MigrateGremlinGraphToAutoscaleSender sends the MigrateGremlinGraphToAutoscale request. The method will close the -// http.Response Body if it receives an error. -func (client GremlinResourcesClient) MigrateGremlinGraphToAutoscaleSender(req *http.Request) (future GremlinResourcesMigrateGremlinGraphToAutoscaleFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// MigrateGremlinGraphToAutoscaleResponder handles the response to the MigrateGremlinGraphToAutoscale request. The method always -// closes the http.Response Body. -func (client GremlinResourcesClient) MigrateGremlinGraphToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// MigrateGremlinGraphToManualThroughput migrate an Azure Cosmos DB Gremlin graph from autoscale to manual throughput -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// graphName - cosmos DB graph name. -func (client GremlinResourcesClient) MigrateGremlinGraphToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result GremlinResourcesMigrateGremlinGraphToManualThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.MigrateGremlinGraphToManualThroughput") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.GremlinResourcesClient", "MigrateGremlinGraphToManualThroughput", err.Error()) - } - - req, err := client.MigrateGremlinGraphToManualThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, graphName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinGraphToManualThroughput", nil, "Failure preparing request") - return - } - - result, err = client.MigrateGremlinGraphToManualThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "MigrateGremlinGraphToManualThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// MigrateGremlinGraphToManualThroughputPreparer prepares the MigrateGremlinGraphToManualThroughput request. -func (client GremlinResourcesClient) MigrateGremlinGraphToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "graphName": autorest.Encode("path", graphName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default/migrateToManualThroughput", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// MigrateGremlinGraphToManualThroughputSender sends the MigrateGremlinGraphToManualThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client GremlinResourcesClient) MigrateGremlinGraphToManualThroughputSender(req *http.Request) (future GremlinResourcesMigrateGremlinGraphToManualThroughputFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// MigrateGremlinGraphToManualThroughputResponder handles the response to the MigrateGremlinGraphToManualThroughput request. The method always -// closes the http.Response Body. -func (client GremlinResourcesClient) MigrateGremlinGraphToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// UpdateGremlinDatabaseThroughput update RUs per second of an Azure Cosmos DB Gremlin database -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// updateThroughputParameters - the RUs per second of the parameters to provide for the current Gremlin -// database. -func (client GremlinResourcesClient) UpdateGremlinDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result GremlinResourcesUpdateGremlinDatabaseThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.UpdateGremlinDatabaseThroughput") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: updateThroughputParameters, - Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, - }}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.GremlinResourcesClient", "UpdateGremlinDatabaseThroughput", err.Error()) - } - - req, err := client.UpdateGremlinDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, updateThroughputParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "UpdateGremlinDatabaseThroughput", nil, "Failure preparing request") - return - } - - result, err = client.UpdateGremlinDatabaseThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "UpdateGremlinDatabaseThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdateGremlinDatabaseThroughputPreparer prepares the UpdateGremlinDatabaseThroughput request. -func (client GremlinResourcesClient) UpdateGremlinDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default", pathParameters), - autorest.WithJSON(updateThroughputParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateGremlinDatabaseThroughputSender sends the UpdateGremlinDatabaseThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client GremlinResourcesClient) UpdateGremlinDatabaseThroughputSender(req *http.Request) (future GremlinResourcesUpdateGremlinDatabaseThroughputFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// UpdateGremlinDatabaseThroughputResponder handles the response to the UpdateGremlinDatabaseThroughput request. The method always -// closes the http.Response Body. -func (client GremlinResourcesClient) UpdateGremlinDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// UpdateGremlinGraphThroughput update RUs per second of an Azure Cosmos DB Gremlin graph -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// graphName - cosmos DB graph name. -// updateThroughputParameters - the RUs per second of the parameters to provide for the current Gremlin graph. -func (client GremlinResourcesClient) UpdateGremlinGraphThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result GremlinResourcesUpdateGremlinGraphThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/GremlinResourcesClient.UpdateGremlinGraphThroughput") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: updateThroughputParameters, - Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, - }}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.GremlinResourcesClient", "UpdateGremlinGraphThroughput", err.Error()) - } - - req, err := client.UpdateGremlinGraphThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, graphName, updateThroughputParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "UpdateGremlinGraphThroughput", nil, "Failure preparing request") - return - } - - result, err = client.UpdateGremlinGraphThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesClient", "UpdateGremlinGraphThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdateGremlinGraphThroughputPreparer prepares the UpdateGremlinGraphThroughput request. -func (client GremlinResourcesClient) UpdateGremlinGraphThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "graphName": autorest.Encode("path", graphName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default", pathParameters), - autorest.WithJSON(updateThroughputParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateGremlinGraphThroughputSender sends the UpdateGremlinGraphThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client GremlinResourcesClient) UpdateGremlinGraphThroughputSender(req *http.Request) (future GremlinResourcesUpdateGremlinGraphThroughputFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// UpdateGremlinGraphThroughputResponder handles the response to the UpdateGremlinGraphThroughput request. The method always -// closes the http.Response Body. -func (client GremlinResourcesClient) UpdateGremlinGraphThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/locations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/locations.go deleted file mode 100644 index fc78a6590337..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/locations.go +++ /dev/null @@ -1,189 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// LocationsClient is the client for the Locations methods of the Documentdb service. -type LocationsClient struct { - BaseClient -} - -// NewLocationsClient creates an instance of the LocationsClient client. -func NewLocationsClient(subscriptionID string) LocationsClient { - return NewLocationsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewLocationsClientWithBaseURI creates an instance of the LocationsClient client using a custom endpoint. Use this -// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewLocationsClientWithBaseURI(baseURI string, subscriptionID string) LocationsClient { - return LocationsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// Get get the properties of an existing Cosmos DB location -// Parameters: -// location - cosmos DB region, with spaces between words and each word capitalized. -func (client LocationsClient) Get(ctx context.Context, location string) (result LocationGetResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/LocationsClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.LocationsClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, location) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.LocationsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.LocationsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.LocationsClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client LocationsClient) GetPreparer(ctx context.Context, location string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "location": autorest.Encode("path", location), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client LocationsClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client LocationsClient) GetResponder(resp *http.Response) (result LocationGetResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List list Cosmos DB locations and their properties -func (client LocationsClient) List(ctx context.Context) (result LocationListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/LocationsClient.List") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.LocationsClient", "List", err.Error()) - } - - req, err := client.ListPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.LocationsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.LocationsClient", "List", resp, "Failure sending request") - return - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.LocationsClient", "List", resp, "Failure responding to request") - return - } - - return -} - -// ListPreparer prepares the List request. -func (client LocationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client LocationsClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client LocationsClient) ListResponder(resp *http.Response) (result LocationListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/models.go deleted file mode 100644 index 59261f7efc42..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/models.go +++ /dev/null @@ -1,11405 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "encoding/json" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/date" - "github.com/Azure/go-autorest/autorest/to" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// The package's fully qualified name. -const fqdn = "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb" - -// AnalyticalStorageConfiguration analytical storage specific properties. -type AnalyticalStorageConfiguration struct { - // SchemaType - Possible values include: 'AnalyticalStorageSchemaTypeWellDefined', 'AnalyticalStorageSchemaTypeFullFidelity' - SchemaType AnalyticalStorageSchemaType `json:"schemaType,omitempty"` -} - -// APIProperties ... -type APIProperties struct { - // ServerVersion - Describes the ServerVersion of an a MongoDB account. Possible values include: 'ServerVersionThreeFullStopTwo', 'ServerVersionThreeFullStopSix', 'ServerVersionFourFullStopZero', 'ServerVersionFourFullStopTwo' - ServerVersion ServerVersion `json:"serverVersion,omitempty"` -} - -// ARMProxyResource the resource model definition for a ARM proxy resource. It will have everything other -// than required location and tags -type ARMProxyResource struct { - // ID - READ-ONLY; The unique resource identifier of the database account. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the database account. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for ARMProxyResource. -func (apr ARMProxyResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// ARMResourceProperties the core properties of ARM resources. -type ARMResourceProperties struct { - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for ARMResourceProperties. -func (arp ARMResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if arp.Location != nil { - objectMap["location"] = arp.Location - } - if arp.Tags != nil { - objectMap["tags"] = arp.Tags - } - return json.Marshal(objectMap) -} - -// AutoscaleSettings ... -type AutoscaleSettings struct { - // MaxThroughput - Represents maximum throughput, the resource can scale up to. - MaxThroughput *int32 `json:"maxThroughput,omitempty"` -} - -// AutoscaleSettingsResource cosmos DB provisioned throughput settings object -type AutoscaleSettingsResource struct { - // MaxThroughput - Represents maximum throughput container can scale up to. - MaxThroughput *int32 `json:"maxThroughput,omitempty"` - // AutoUpgradePolicy - Cosmos DB resource auto-upgrade policy - AutoUpgradePolicy *AutoUpgradePolicyResource `json:"autoUpgradePolicy,omitempty"` - // TargetMaxThroughput - READ-ONLY; Represents target maximum throughput container can scale up to once offer is no longer in pending state. - TargetMaxThroughput *int32 `json:"targetMaxThroughput,omitempty"` -} - -// MarshalJSON is the custom marshaler for AutoscaleSettingsResource. -func (asr AutoscaleSettingsResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if asr.MaxThroughput != nil { - objectMap["maxThroughput"] = asr.MaxThroughput - } - if asr.AutoUpgradePolicy != nil { - objectMap["autoUpgradePolicy"] = asr.AutoUpgradePolicy - } - return json.Marshal(objectMap) -} - -// AutoUpgradePolicyResource cosmos DB resource auto-upgrade policy -type AutoUpgradePolicyResource struct { - // ThroughputPolicy - Represents throughput policy which service must adhere to for auto-upgrade - ThroughputPolicy *ThroughputPolicyResource `json:"throughputPolicy,omitempty"` -} - -// AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag. -type AzureEntityResource struct { - // Etag - READ-ONLY; Resource Etag. - Etag *string `json:"etag,omitempty"` - // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the resource - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for AzureEntityResource. -func (aer AzureEntityResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// BackupInformation backup information of a resource. -type BackupInformation struct { - autorest.Response `json:"-"` - // ContinuousBackupInformation - Information about the status of continuous backups. - ContinuousBackupInformation *ContinuousBackupInformation `json:"continuousBackupInformation,omitempty"` -} - -// BasicBackupPolicy the object representing the policy for taking backups on an account. -type BasicBackupPolicy interface { - AsPeriodicModeBackupPolicy() (*PeriodicModeBackupPolicy, bool) - AsContinuousModeBackupPolicy() (*ContinuousModeBackupPolicy, bool) - AsBackupPolicy() (*BackupPolicy, bool) -} - -// BackupPolicy the object representing the policy for taking backups on an account. -type BackupPolicy struct { - // MigrationState - The object representing the state of the migration between the backup policies. - MigrationState *BackupPolicyMigrationState `json:"migrationState,omitempty"` - // Type - Possible values include: 'TypeBackupPolicy', 'TypePeriodic', 'TypeContinuous' - Type Type `json:"type,omitempty"` -} - -func unmarshalBasicBackupPolicy(body []byte) (BasicBackupPolicy, error) { - var m map[string]interface{} - err := json.Unmarshal(body, &m) - if err != nil { - return nil, err - } - - switch m["type"] { - case string(TypePeriodic): - var pmbp PeriodicModeBackupPolicy - err := json.Unmarshal(body, &pmbp) - return pmbp, err - case string(TypeContinuous): - var cmbp ContinuousModeBackupPolicy - err := json.Unmarshal(body, &cmbp) - return cmbp, err - default: - var bp BackupPolicy - err := json.Unmarshal(body, &bp) - return bp, err - } -} -func unmarshalBasicBackupPolicyArray(body []byte) ([]BasicBackupPolicy, error) { - var rawMessages []*json.RawMessage - err := json.Unmarshal(body, &rawMessages) - if err != nil { - return nil, err - } - - bpArray := make([]BasicBackupPolicy, len(rawMessages)) - - for index, rawMessage := range rawMessages { - bp, err := unmarshalBasicBackupPolicy(*rawMessage) - if err != nil { - return nil, err - } - bpArray[index] = bp - } - return bpArray, nil -} - -// MarshalJSON is the custom marshaler for BackupPolicy. -func (bp BackupPolicy) MarshalJSON() ([]byte, error) { - bp.Type = TypeBackupPolicy - objectMap := make(map[string]interface{}) - if bp.MigrationState != nil { - objectMap["migrationState"] = bp.MigrationState - } - if bp.Type != "" { - objectMap["type"] = bp.Type - } - return json.Marshal(objectMap) -} - -// AsPeriodicModeBackupPolicy is the BasicBackupPolicy implementation for BackupPolicy. -func (bp BackupPolicy) AsPeriodicModeBackupPolicy() (*PeriodicModeBackupPolicy, bool) { - return nil, false -} - -// AsContinuousModeBackupPolicy is the BasicBackupPolicy implementation for BackupPolicy. -func (bp BackupPolicy) AsContinuousModeBackupPolicy() (*ContinuousModeBackupPolicy, bool) { - return nil, false -} - -// AsBackupPolicy is the BasicBackupPolicy implementation for BackupPolicy. -func (bp BackupPolicy) AsBackupPolicy() (*BackupPolicy, bool) { - return &bp, true -} - -// AsBasicBackupPolicy is the BasicBackupPolicy implementation for BackupPolicy. -func (bp BackupPolicy) AsBasicBackupPolicy() (BasicBackupPolicy, bool) { - return &bp, true -} - -// BackupPolicyMigrationState the object representing the state of the migration between the backup -// policies. -type BackupPolicyMigrationState struct { - // Status - Describes the status of migration between backup policy types. Possible values include: 'BackupPolicyMigrationStatusInvalid', 'BackupPolicyMigrationStatusInProgress', 'BackupPolicyMigrationStatusCompleted', 'BackupPolicyMigrationStatusFailed' - Status BackupPolicyMigrationStatus `json:"status,omitempty"` - // TargetType - Describes the target backup policy type of the backup policy migration. Possible values include: 'BackupPolicyTypePeriodic', 'BackupPolicyTypeContinuous' - TargetType BackupPolicyType `json:"targetType,omitempty"` - // StartTime - Time at which the backup policy migration started (ISO-8601 format). - StartTime *date.Time `json:"startTime,omitempty"` -} - -// Capability cosmos DB capability object -type Capability struct { - // Name - Name of the Cosmos DB capability. For example, "name": "EnableCassandra". Current values also include "EnableTable" and "EnableGremlin". - Name *string `json:"name,omitempty"` -} - -// Capacity the object that represents all properties related to capacity enforcement on an account. -type Capacity struct { - // TotalThroughputLimit - The total throughput limit imposed on the account. A totalThroughputLimit of 2000 imposes a strict limit of max throughput that can be provisioned on that account to be 2000. A totalThroughputLimit of -1 indicates no limits on provisioning of throughput. - TotalThroughputLimit *int32 `json:"totalThroughputLimit,omitempty"` -} - -// CassandraClusterPublicStatus properties of a managed Cassandra cluster public status. -type CassandraClusterPublicStatus struct { - autorest.Response `json:"-"` - ETag *string `json:"eTag,omitempty"` - ReaperStatus *ManagedCassandraReaperStatus `json:"reaperStatus,omitempty"` - // ConnectionErrors - List relevant information about any connection errors to the Datacenters. - ConnectionErrors *[]ConnectionError `json:"connectionErrors,omitempty"` - // DataCenters - List of the status of each datacenter in this cluster. - DataCenters *[]CassandraClusterPublicStatusDataCentersItem `json:"dataCenters,omitempty"` -} - -// CassandraClusterPublicStatusDataCentersItem ... -type CassandraClusterPublicStatusDataCentersItem struct { - // Name - The name of this Datacenter. - Name *string `json:"name,omitempty"` - // SeedNodes - A list of all seed nodes in the cluster, managed and unmanaged. - SeedNodes *[]string `json:"seedNodes,omitempty"` - Nodes *[]CassandraClusterPublicStatusDataCentersItemNodesItem `json:"nodes,omitempty"` -} - -// CassandraClusterPublicStatusDataCentersItemNodesItem ... -type CassandraClusterPublicStatusDataCentersItemNodesItem struct { - // Address - The node's IP address. - Address *string `json:"address,omitempty"` - // State - Possible values include: 'NodeStateNormal', 'NodeStateLeaving', 'NodeStateJoining', 'NodeStateMoving', 'NodeStateStopped' - State NodeState `json:"state,omitempty"` - Status *string `json:"status,omitempty"` - // Load - The amount of file system data in the data directory (e.g., 47.66 kB), excluding all content in the snapshots subdirectories. Because all SSTable data files are included, any data that is not cleaned up (such as TTL-expired cells or tombstones) is counted. - Load *string `json:"load,omitempty"` - // Tokens - List of tokens this node covers. - Tokens *[]string `json:"tokens,omitempty"` - Size *int32 `json:"size,omitempty"` - // HostID - The network ID of the node. - HostID *string `json:"hostID,omitempty"` - // Rack - The rack this node is part of. - Rack *string `json:"rack,omitempty"` - // Timestamp - The timestamp when these statistics were captured. - Timestamp *string `json:"timestamp,omitempty"` - // DiskUsedKB - The amount of disk used, in kB, of the directory /var/lib/cassandra. - DiskUsedKB *int64 `json:"diskUsedKB,omitempty"` - // DiskFreeKB - The amount of disk free, in kB, of the directory /var/lib/cassandra. - DiskFreeKB *int64 `json:"diskFreeKB,omitempty"` - // MemoryUsedKB - Used memory (calculated as total - free - buffers - cache), in kB. - MemoryUsedKB *int64 `json:"memoryUsedKB,omitempty"` - // MemoryBuffersAndCachedKB - Memory used by kernel buffers (Buffers in /proc/meminfo) and page cache and slabs (Cached and SReclaimable in /proc/meminfo), in kB. - MemoryBuffersAndCachedKB *int64 `json:"memoryBuffersAndCachedKB,omitempty"` - // MemoryFreeKB - Unused memory (MemFree and SwapFree in /proc/meminfo), in kB. - MemoryFreeKB *int64 `json:"memoryFreeKB,omitempty"` - // MemoryTotalKB - Total installed memory (MemTotal and SwapTotal in /proc/meminfo), in kB. - MemoryTotalKB *int64 `json:"memoryTotalKB,omitempty"` - // CPUUsage - A float representing the current system-wide CPU utilization as a percentage. - CPUUsage *float64 `json:"cpuUsage,omitempty"` -} - -// CassandraClustersCreateUpdateFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type CassandraClustersCreateUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(CassandraClustersClient) (ClusterResource, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *CassandraClustersCreateUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for CassandraClustersCreateUpdateFuture.Result. -func (future *CassandraClustersCreateUpdateFuture) result(client CassandraClustersClient) (cr ClusterResource, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersCreateUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - cr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.CassandraClustersCreateUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if cr.Response.Response, err = future.GetResult(sender); err == nil && cr.Response.Response.StatusCode != http.StatusNoContent { - cr, err = client.CreateUpdateResponder(cr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersCreateUpdateFuture", "Result", cr.Response.Response, "Failure responding to request") - } - } - return -} - -// CassandraClustersDeallocateFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type CassandraClustersDeallocateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(CassandraClustersClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *CassandraClustersDeallocateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for CassandraClustersDeallocateFuture.Result. -func (future *CassandraClustersDeallocateFuture) result(client CassandraClustersClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersDeallocateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.CassandraClustersDeallocateFuture") - return - } - ar.Response = future.Response() - return -} - -// CassandraClustersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type CassandraClustersDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(CassandraClustersClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *CassandraClustersDeleteFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for CassandraClustersDeleteFuture.Result. -func (future *CassandraClustersDeleteFuture) result(client CassandraClustersClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.CassandraClustersDeleteFuture") - return - } - ar.Response = future.Response() - return -} - -// CassandraClustersInvokeCommandFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type CassandraClustersInvokeCommandFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(CassandraClustersClient) (CommandOutput, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *CassandraClustersInvokeCommandFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for CassandraClustersInvokeCommandFuture.Result. -func (future *CassandraClustersInvokeCommandFuture) result(client CassandraClustersClient) (co CommandOutput, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersInvokeCommandFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - co.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.CassandraClustersInvokeCommandFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if co.Response.Response, err = future.GetResult(sender); err == nil && co.Response.Response.StatusCode != http.StatusNoContent { - co, err = client.InvokeCommandResponder(co.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersInvokeCommandFuture", "Result", co.Response.Response, "Failure responding to request") - } - } - return -} - -// CassandraClustersStartFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type CassandraClustersStartFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(CassandraClustersClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *CassandraClustersStartFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for CassandraClustersStartFuture.Result. -func (future *CassandraClustersStartFuture) result(client CassandraClustersClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersStartFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.CassandraClustersStartFuture") - return - } - ar.Response = future.Response() - return -} - -// CassandraClustersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type CassandraClustersUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(CassandraClustersClient) (ClusterResource, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *CassandraClustersUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for CassandraClustersUpdateFuture.Result. -func (future *CassandraClustersUpdateFuture) result(client CassandraClustersClient) (cr ClusterResource, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - cr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.CassandraClustersUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if cr.Response.Response, err = future.GetResult(sender); err == nil && cr.Response.Response.StatusCode != http.StatusNoContent { - cr, err = client.UpdateResponder(cr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraClustersUpdateFuture", "Result", cr.Response.Response, "Failure responding to request") - } - } - return -} - -// CassandraDataCentersCreateUpdateFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type CassandraDataCentersCreateUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(CassandraDataCentersClient) (DataCenterResource, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *CassandraDataCentersCreateUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for CassandraDataCentersCreateUpdateFuture.Result. -func (future *CassandraDataCentersCreateUpdateFuture) result(client CassandraDataCentersClient) (dcr DataCenterResource, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersCreateUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - dcr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.CassandraDataCentersCreateUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if dcr.Response.Response, err = future.GetResult(sender); err == nil && dcr.Response.Response.StatusCode != http.StatusNoContent { - dcr, err = client.CreateUpdateResponder(dcr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersCreateUpdateFuture", "Result", dcr.Response.Response, "Failure responding to request") - } - } - return -} - -// CassandraDataCentersDeleteFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type CassandraDataCentersDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(CassandraDataCentersClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *CassandraDataCentersDeleteFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for CassandraDataCentersDeleteFuture.Result. -func (future *CassandraDataCentersDeleteFuture) result(client CassandraDataCentersClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.CassandraDataCentersDeleteFuture") - return - } - ar.Response = future.Response() - return -} - -// CassandraDataCentersUpdateFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type CassandraDataCentersUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(CassandraDataCentersClient) (DataCenterResource, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *CassandraDataCentersUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for CassandraDataCentersUpdateFuture.Result. -func (future *CassandraDataCentersUpdateFuture) result(client CassandraDataCentersClient) (dcr DataCenterResource, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - dcr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.CassandraDataCentersUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if dcr.Response.Response, err = future.GetResult(sender); err == nil && dcr.Response.Response.StatusCode != http.StatusNoContent { - dcr, err = client.UpdateResponder(dcr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraDataCentersUpdateFuture", "Result", dcr.Response.Response, "Failure responding to request") - } - } - return -} - -// CassandraKeyspaceCreateUpdateParameters parameters to create and update Cosmos DB Cassandra keyspace. -type CassandraKeyspaceCreateUpdateParameters struct { - // CassandraKeyspaceCreateUpdateProperties - Properties to create and update Azure Cosmos DB Cassandra keyspace. - *CassandraKeyspaceCreateUpdateProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for CassandraKeyspaceCreateUpdateParameters. -func (ckcup CassandraKeyspaceCreateUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ckcup.CassandraKeyspaceCreateUpdateProperties != nil { - objectMap["properties"] = ckcup.CassandraKeyspaceCreateUpdateProperties - } - if ckcup.Location != nil { - objectMap["location"] = ckcup.Location - } - if ckcup.Tags != nil { - objectMap["tags"] = ckcup.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for CassandraKeyspaceCreateUpdateParameters struct. -func (ckcup *CassandraKeyspaceCreateUpdateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var cassandraKeyspaceCreateUpdateProperties CassandraKeyspaceCreateUpdateProperties - err = json.Unmarshal(*v, &cassandraKeyspaceCreateUpdateProperties) - if err != nil { - return err - } - ckcup.CassandraKeyspaceCreateUpdateProperties = &cassandraKeyspaceCreateUpdateProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - ckcup.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - ckcup.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - ckcup.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - ckcup.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - ckcup.Tags = tags - } - } - } - - return nil -} - -// CassandraKeyspaceCreateUpdateProperties properties to create and update Azure Cosmos DB Cassandra -// keyspace. -type CassandraKeyspaceCreateUpdateProperties struct { - // Resource - The standard JSON format of a Cassandra keyspace - Resource *CassandraKeyspaceResource `json:"resource,omitempty"` - // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - Options *CreateUpdateOptions `json:"options,omitempty"` -} - -// CassandraKeyspaceGetProperties the properties of an Azure Cosmos DB Cassandra keyspace -type CassandraKeyspaceGetProperties struct { - Resource *CassandraKeyspaceGetPropertiesResource `json:"resource,omitempty"` - Options *CassandraKeyspaceGetPropertiesOptions `json:"options,omitempty"` -} - -// CassandraKeyspaceGetPropertiesOptions ... -type CassandraKeyspaceGetPropertiesOptions struct { - // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. - Throughput *int32 `json:"throughput,omitempty"` - // AutoscaleSettings - Specifies the Autoscale settings. - AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` -} - -// CassandraKeyspaceGetPropertiesResource ... -type CassandraKeyspaceGetPropertiesResource struct { - // ID - Name of the Cosmos DB Cassandra keyspace - ID *string `json:"id,omitempty"` - // Rid - READ-ONLY; A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. - Ts *float64 `json:"_ts,omitempty"` - // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. - Etag *string `json:"_etag,omitempty"` -} - -// MarshalJSON is the custom marshaler for CassandraKeyspaceGetPropertiesResource. -func (ckgp CassandraKeyspaceGetPropertiesResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ckgp.ID != nil { - objectMap["id"] = ckgp.ID - } - return json.Marshal(objectMap) -} - -// CassandraKeyspaceGetResults an Azure Cosmos DB Cassandra keyspace. -type CassandraKeyspaceGetResults struct { - autorest.Response `json:"-"` - // CassandraKeyspaceGetProperties - The properties of an Azure Cosmos DB Cassandra keyspace - *CassandraKeyspaceGetProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for CassandraKeyspaceGetResults. -func (ckgr CassandraKeyspaceGetResults) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ckgr.CassandraKeyspaceGetProperties != nil { - objectMap["properties"] = ckgr.CassandraKeyspaceGetProperties - } - if ckgr.Location != nil { - objectMap["location"] = ckgr.Location - } - if ckgr.Tags != nil { - objectMap["tags"] = ckgr.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for CassandraKeyspaceGetResults struct. -func (ckgr *CassandraKeyspaceGetResults) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var cassandraKeyspaceGetProperties CassandraKeyspaceGetProperties - err = json.Unmarshal(*v, &cassandraKeyspaceGetProperties) - if err != nil { - return err - } - ckgr.CassandraKeyspaceGetProperties = &cassandraKeyspaceGetProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - ckgr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - ckgr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - ckgr.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - ckgr.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - ckgr.Tags = tags - } - } - } - - return nil -} - -// CassandraKeyspaceListResult the List operation response, that contains the Cassandra keyspaces and their -// properties. -type CassandraKeyspaceListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of Cassandra keyspaces and their properties. - Value *[]CassandraKeyspaceGetResults `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for CassandraKeyspaceListResult. -func (cklr CassandraKeyspaceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// CassandraKeyspaceResource cosmos DB Cassandra keyspace resource object -type CassandraKeyspaceResource struct { - // ID - Name of the Cosmos DB Cassandra keyspace - ID *string `json:"id,omitempty"` -} - -// CassandraPartitionKey cosmos DB Cassandra table partition key -type CassandraPartitionKey struct { - // Name - Name of the Cosmos DB Cassandra table partition key - Name *string `json:"name,omitempty"` -} - -// CassandraResourcesCreateUpdateCassandraKeyspaceFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type CassandraResourcesCreateUpdateCassandraKeyspaceFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(CassandraResourcesClient) (CassandraKeyspaceGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *CassandraResourcesCreateUpdateCassandraKeyspaceFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for CassandraResourcesCreateUpdateCassandraKeyspaceFuture.Result. -func (future *CassandraResourcesCreateUpdateCassandraKeyspaceFuture) result(client CassandraResourcesClient) (ckgr CassandraKeyspaceGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesCreateUpdateCassandraKeyspaceFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ckgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesCreateUpdateCassandraKeyspaceFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if ckgr.Response.Response, err = future.GetResult(sender); err == nil && ckgr.Response.Response.StatusCode != http.StatusNoContent { - ckgr, err = client.CreateUpdateCassandraKeyspaceResponder(ckgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesCreateUpdateCassandraKeyspaceFuture", "Result", ckgr.Response.Response, "Failure responding to request") - } - } - return -} - -// CassandraResourcesCreateUpdateCassandraTableFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type CassandraResourcesCreateUpdateCassandraTableFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(CassandraResourcesClient) (CassandraTableGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *CassandraResourcesCreateUpdateCassandraTableFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for CassandraResourcesCreateUpdateCassandraTableFuture.Result. -func (future *CassandraResourcesCreateUpdateCassandraTableFuture) result(client CassandraResourcesClient) (ctgr CassandraTableGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesCreateUpdateCassandraTableFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ctgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesCreateUpdateCassandraTableFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if ctgr.Response.Response, err = future.GetResult(sender); err == nil && ctgr.Response.Response.StatusCode != http.StatusNoContent { - ctgr, err = client.CreateUpdateCassandraTableResponder(ctgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesCreateUpdateCassandraTableFuture", "Result", ctgr.Response.Response, "Failure responding to request") - } - } - return -} - -// CassandraResourcesDeleteCassandraKeyspaceFuture an abstraction for monitoring and retrieving the results -// of a long-running operation. -type CassandraResourcesDeleteCassandraKeyspaceFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(CassandraResourcesClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *CassandraResourcesDeleteCassandraKeyspaceFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for CassandraResourcesDeleteCassandraKeyspaceFuture.Result. -func (future *CassandraResourcesDeleteCassandraKeyspaceFuture) result(client CassandraResourcesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesDeleteCassandraKeyspaceFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesDeleteCassandraKeyspaceFuture") - return - } - ar.Response = future.Response() - return -} - -// CassandraResourcesDeleteCassandraTableFuture an abstraction for monitoring and retrieving the results of -// a long-running operation. -type CassandraResourcesDeleteCassandraTableFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(CassandraResourcesClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *CassandraResourcesDeleteCassandraTableFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for CassandraResourcesDeleteCassandraTableFuture.Result. -func (future *CassandraResourcesDeleteCassandraTableFuture) result(client CassandraResourcesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesDeleteCassandraTableFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesDeleteCassandraTableFuture") - return - } - ar.Response = future.Response() - return -} - -// CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture an abstraction for monitoring and retrieving -// the results of a long-running operation. -type CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(CassandraResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture.Result. -func (future *CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture) result(client CassandraResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.MigrateCassandraKeyspaceToAutoscaleResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraKeyspaceToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture an abstraction for monitoring and -// retrieving the results of a long-running operation. -type CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(CassandraResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture.Result. -func (future *CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture) result(client CassandraResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.MigrateCassandraKeyspaceToManualThroughputResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraKeyspaceToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// CassandraResourcesMigrateCassandraTableToAutoscaleFuture an abstraction for monitoring and retrieving -// the results of a long-running operation. -type CassandraResourcesMigrateCassandraTableToAutoscaleFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(CassandraResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *CassandraResourcesMigrateCassandraTableToAutoscaleFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for CassandraResourcesMigrateCassandraTableToAutoscaleFuture.Result. -func (future *CassandraResourcesMigrateCassandraTableToAutoscaleFuture) result(client CassandraResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraTableToAutoscaleFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesMigrateCassandraTableToAutoscaleFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.MigrateCassandraTableToAutoscaleResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraTableToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// CassandraResourcesMigrateCassandraTableToManualThroughputFuture an abstraction for monitoring and -// retrieving the results of a long-running operation. -type CassandraResourcesMigrateCassandraTableToManualThroughputFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(CassandraResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *CassandraResourcesMigrateCassandraTableToManualThroughputFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for CassandraResourcesMigrateCassandraTableToManualThroughputFuture.Result. -func (future *CassandraResourcesMigrateCassandraTableToManualThroughputFuture) result(client CassandraResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraTableToManualThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesMigrateCassandraTableToManualThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.MigrateCassandraTableToManualThroughputResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesMigrateCassandraTableToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// CassandraResourcesUpdateCassandraKeyspaceThroughputFuture an abstraction for monitoring and retrieving -// the results of a long-running operation. -type CassandraResourcesUpdateCassandraKeyspaceThroughputFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(CassandraResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *CassandraResourcesUpdateCassandraKeyspaceThroughputFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for CassandraResourcesUpdateCassandraKeyspaceThroughputFuture.Result. -func (future *CassandraResourcesUpdateCassandraKeyspaceThroughputFuture) result(client CassandraResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesUpdateCassandraKeyspaceThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesUpdateCassandraKeyspaceThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.UpdateCassandraKeyspaceThroughputResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesUpdateCassandraKeyspaceThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// CassandraResourcesUpdateCassandraTableThroughputFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type CassandraResourcesUpdateCassandraTableThroughputFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(CassandraResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *CassandraResourcesUpdateCassandraTableThroughputFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for CassandraResourcesUpdateCassandraTableThroughputFuture.Result. -func (future *CassandraResourcesUpdateCassandraTableThroughputFuture) result(client CassandraResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesUpdateCassandraTableThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesUpdateCassandraTableThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.UpdateCassandraTableThroughputResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.CassandraResourcesUpdateCassandraTableThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// CassandraSchema cosmos DB Cassandra table schema -type CassandraSchema struct { - // Columns - List of Cassandra table columns. - Columns *[]Column `json:"columns,omitempty"` - // PartitionKeys - List of partition key. - PartitionKeys *[]CassandraPartitionKey `json:"partitionKeys,omitempty"` - // ClusterKeys - List of cluster key. - ClusterKeys *[]ClusterKey `json:"clusterKeys,omitempty"` -} - -// CassandraTableCreateUpdateParameters parameters to create and update Cosmos DB Cassandra table. -type CassandraTableCreateUpdateParameters struct { - // CassandraTableCreateUpdateProperties - Properties to create and update Azure Cosmos DB Cassandra table. - *CassandraTableCreateUpdateProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for CassandraTableCreateUpdateParameters. -func (ctcup CassandraTableCreateUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ctcup.CassandraTableCreateUpdateProperties != nil { - objectMap["properties"] = ctcup.CassandraTableCreateUpdateProperties - } - if ctcup.Location != nil { - objectMap["location"] = ctcup.Location - } - if ctcup.Tags != nil { - objectMap["tags"] = ctcup.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for CassandraTableCreateUpdateParameters struct. -func (ctcup *CassandraTableCreateUpdateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var cassandraTableCreateUpdateProperties CassandraTableCreateUpdateProperties - err = json.Unmarshal(*v, &cassandraTableCreateUpdateProperties) - if err != nil { - return err - } - ctcup.CassandraTableCreateUpdateProperties = &cassandraTableCreateUpdateProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - ctcup.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - ctcup.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - ctcup.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - ctcup.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - ctcup.Tags = tags - } - } - } - - return nil -} - -// CassandraTableCreateUpdateProperties properties to create and update Azure Cosmos DB Cassandra table. -type CassandraTableCreateUpdateProperties struct { - // Resource - The standard JSON format of a Cassandra table - Resource *CassandraTableResource `json:"resource,omitempty"` - // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - Options *CreateUpdateOptions `json:"options,omitempty"` -} - -// CassandraTableGetProperties the properties of an Azure Cosmos DB Cassandra table -type CassandraTableGetProperties struct { - Resource *CassandraTableGetPropertiesResource `json:"resource,omitempty"` - Options *CassandraTableGetPropertiesOptions `json:"options,omitempty"` -} - -// CassandraTableGetPropertiesOptions ... -type CassandraTableGetPropertiesOptions struct { - // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. - Throughput *int32 `json:"throughput,omitempty"` - // AutoscaleSettings - Specifies the Autoscale settings. - AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` -} - -// CassandraTableGetPropertiesResource ... -type CassandraTableGetPropertiesResource struct { - // ID - Name of the Cosmos DB Cassandra table - ID *string `json:"id,omitempty"` - // DefaultTTL - Time to live of the Cosmos DB Cassandra table - DefaultTTL *int32 `json:"defaultTtl,omitempty"` - // Schema - Schema of the Cosmos DB Cassandra table - Schema *CassandraSchema `json:"schema,omitempty"` - // AnalyticalStorageTTL - Analytical TTL. - AnalyticalStorageTTL *int32 `json:"analyticalStorageTtl,omitempty"` - // Rid - READ-ONLY; A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. - Ts *float64 `json:"_ts,omitempty"` - // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. - Etag *string `json:"_etag,omitempty"` -} - -// MarshalJSON is the custom marshaler for CassandraTableGetPropertiesResource. -func (ctgp CassandraTableGetPropertiesResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ctgp.ID != nil { - objectMap["id"] = ctgp.ID - } - if ctgp.DefaultTTL != nil { - objectMap["defaultTtl"] = ctgp.DefaultTTL - } - if ctgp.Schema != nil { - objectMap["schema"] = ctgp.Schema - } - if ctgp.AnalyticalStorageTTL != nil { - objectMap["analyticalStorageTtl"] = ctgp.AnalyticalStorageTTL - } - return json.Marshal(objectMap) -} - -// CassandraTableGetResults an Azure Cosmos DB Cassandra table. -type CassandraTableGetResults struct { - autorest.Response `json:"-"` - // CassandraTableGetProperties - The properties of an Azure Cosmos DB Cassandra table - *CassandraTableGetProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for CassandraTableGetResults. -func (ctgr CassandraTableGetResults) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ctgr.CassandraTableGetProperties != nil { - objectMap["properties"] = ctgr.CassandraTableGetProperties - } - if ctgr.Location != nil { - objectMap["location"] = ctgr.Location - } - if ctgr.Tags != nil { - objectMap["tags"] = ctgr.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for CassandraTableGetResults struct. -func (ctgr *CassandraTableGetResults) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var cassandraTableGetProperties CassandraTableGetProperties - err = json.Unmarshal(*v, &cassandraTableGetProperties) - if err != nil { - return err - } - ctgr.CassandraTableGetProperties = &cassandraTableGetProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - ctgr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - ctgr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - ctgr.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - ctgr.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - ctgr.Tags = tags - } - } - } - - return nil -} - -// CassandraTableListResult the List operation response, that contains the Cassandra tables and their -// properties. -type CassandraTableListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of Cassandra tables and their properties. - Value *[]CassandraTableGetResults `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for CassandraTableListResult. -func (ctlr CassandraTableListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// CassandraTableResource cosmos DB Cassandra table resource object -type CassandraTableResource struct { - // ID - Name of the Cosmos DB Cassandra table - ID *string `json:"id,omitempty"` - // DefaultTTL - Time to live of the Cosmos DB Cassandra table - DefaultTTL *int32 `json:"defaultTtl,omitempty"` - // Schema - Schema of the Cosmos DB Cassandra table - Schema *CassandraSchema `json:"schema,omitempty"` - // AnalyticalStorageTTL - Analytical TTL. - AnalyticalStorageTTL *int32 `json:"analyticalStorageTtl,omitempty"` -} - -// Certificate ... -type Certificate struct { - // Pem - PEM formatted public key. - Pem *string `json:"pem,omitempty"` -} - -// CloudError an error response from the service. -type CloudError struct { - Error *ErrorResponse `json:"error,omitempty"` -} - -// ClusterKey cosmos DB Cassandra table cluster key -type ClusterKey struct { - // Name - Name of the Cosmos DB Cassandra table cluster key - Name *string `json:"name,omitempty"` - // OrderBy - Order of the Cosmos DB Cassandra table cluster key, only support "Asc" and "Desc" - OrderBy *string `json:"orderBy,omitempty"` -} - -// ClusterResource representation of a managed Cassandra cluster. -type ClusterResource struct { - autorest.Response `json:"-"` - // Properties - Properties of a managed Cassandra cluster. - Properties *ClusterResourceProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` - Identity *ManagedCassandraManagedServiceIdentity `json:"identity,omitempty"` -} - -// MarshalJSON is the custom marshaler for ClusterResource. -func (cr ClusterResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if cr.Properties != nil { - objectMap["properties"] = cr.Properties - } - if cr.Location != nil { - objectMap["location"] = cr.Location - } - if cr.Tags != nil { - objectMap["tags"] = cr.Tags - } - if cr.Identity != nil { - objectMap["identity"] = cr.Identity - } - return json.Marshal(objectMap) -} - -// ClusterResourceProperties properties of a managed Cassandra cluster. -type ClusterResourceProperties struct { - // ProvisioningState - Possible values include: 'ManagedCassandraProvisioningStateCreating', 'ManagedCassandraProvisioningStateUpdating', 'ManagedCassandraProvisioningStateDeleting', 'ManagedCassandraProvisioningStateSucceeded', 'ManagedCassandraProvisioningStateFailed', 'ManagedCassandraProvisioningStateCanceled' - ProvisioningState ManagedCassandraProvisioningState `json:"provisioningState,omitempty"` - // RestoreFromBackupID - To create an empty cluster, omit this field or set it to null. To restore a backup into a new cluster, set this field to the resource id of the backup. - RestoreFromBackupID *string `json:"restoreFromBackupId,omitempty"` - // DelegatedManagementSubnetID - Resource id of a subnet that this cluster's management service should have its network interface attached to. The subnet must be routable to all subnets that will be delegated to data centers. The resource id must be of the form '/subscriptions//resourceGroups//providers/Microsoft.Network/virtualNetworks//subnets/' - DelegatedManagementSubnetID *string `json:"delegatedManagementSubnetId,omitempty"` - // CassandraVersion - Which version of Cassandra should this cluster converge to running (e.g., 3.11). When updated, the cluster may take some time to migrate to the new version. - CassandraVersion *string `json:"cassandraVersion,omitempty"` - // ClusterNameOverride - If you need to set the clusterName property in cassandra.yaml to something besides the resource name of the cluster, set the value to use on this property. - ClusterNameOverride *string `json:"clusterNameOverride,omitempty"` - // AuthenticationMethod - Which authentication method Cassandra should use to authenticate clients. 'None' turns off authentication, so should not be used except in emergencies. 'Cassandra' is the default password based authentication. The default is 'Cassandra'. Possible values include: 'AuthenticationMethodNone', 'AuthenticationMethodCassandra' - AuthenticationMethod AuthenticationMethod `json:"authenticationMethod,omitempty"` - // InitialCassandraAdminPassword - Initial password for clients connecting as admin to the cluster. Should be changed after cluster creation. Returns null on GET. This field only applies when the authenticationMethod field is 'Cassandra'. - InitialCassandraAdminPassword *string `json:"initialCassandraAdminPassword,omitempty"` - // PrometheusEndpoint - Hostname or IP address where the Prometheus endpoint containing data about the managed Cassandra nodes can be reached. - PrometheusEndpoint *SeedNode `json:"prometheusEndpoint,omitempty"` - // RepairEnabled - Should automatic repairs run on this cluster? If omitted, this is true, and should stay true unless you are running a hybrid cluster where you are already doing your own repairs. - RepairEnabled *bool `json:"repairEnabled,omitempty"` - // ClientCertificates - List of TLS certificates used to authorize clients connecting to the cluster. All connections are TLS encrypted whether clientCertificates is set or not, but if clientCertificates is set, the managed Cassandra cluster will reject all connections not bearing a TLS client certificate that can be validated from one or more of the public certificates in this property. - ClientCertificates *[]Certificate `json:"clientCertificates,omitempty"` - // ExternalGossipCertificates - List of TLS certificates used to authorize gossip from unmanaged data centers. The TLS certificates of all nodes in unmanaged data centers must be verifiable using one of the certificates provided in this property. - ExternalGossipCertificates *[]Certificate `json:"externalGossipCertificates,omitempty"` - // GossipCertificates - READ-ONLY; List of TLS certificates that unmanaged nodes must trust for gossip with managed nodes. All managed nodes will present TLS client certificates that are verifiable using one of the certificates provided in this property. - GossipCertificates *[]Certificate `json:"gossipCertificates,omitempty"` - // ExternalSeedNodes - List of IP addresses of seed nodes in unmanaged data centers. These will be added to the seed node lists of all managed nodes. - ExternalSeedNodes *[]SeedNode `json:"externalSeedNodes,omitempty"` - // SeedNodes - READ-ONLY; List of IP addresses of seed nodes in the managed data centers. These should be added to the seed node lists of all unmanaged nodes. - SeedNodes *[]SeedNode `json:"seedNodes,omitempty"` - // HoursBetweenBackups - Number of hours to wait between taking a backup of the cluster. To disable backups, set this property to 0. - HoursBetweenBackups *int32 `json:"hoursBetweenBackups,omitempty"` - // Deallocated - Whether the cluster and associated data centers has been deallocated. - Deallocated *bool `json:"deallocated,omitempty"` - // CassandraAuditLoggingEnabled - Whether Cassandra audit logging is enabled - CassandraAuditLoggingEnabled *bool `json:"cassandraAuditLoggingEnabled,omitempty"` -} - -// MarshalJSON is the custom marshaler for ClusterResourceProperties. -func (cr ClusterResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if cr.ProvisioningState != "" { - objectMap["provisioningState"] = cr.ProvisioningState - } - if cr.RestoreFromBackupID != nil { - objectMap["restoreFromBackupId"] = cr.RestoreFromBackupID - } - if cr.DelegatedManagementSubnetID != nil { - objectMap["delegatedManagementSubnetId"] = cr.DelegatedManagementSubnetID - } - if cr.CassandraVersion != nil { - objectMap["cassandraVersion"] = cr.CassandraVersion - } - if cr.ClusterNameOverride != nil { - objectMap["clusterNameOverride"] = cr.ClusterNameOverride - } - if cr.AuthenticationMethod != "" { - objectMap["authenticationMethod"] = cr.AuthenticationMethod - } - if cr.InitialCassandraAdminPassword != nil { - objectMap["initialCassandraAdminPassword"] = cr.InitialCassandraAdminPassword - } - if cr.PrometheusEndpoint != nil { - objectMap["prometheusEndpoint"] = cr.PrometheusEndpoint - } - if cr.RepairEnabled != nil { - objectMap["repairEnabled"] = cr.RepairEnabled - } - if cr.ClientCertificates != nil { - objectMap["clientCertificates"] = cr.ClientCertificates - } - if cr.ExternalGossipCertificates != nil { - objectMap["externalGossipCertificates"] = cr.ExternalGossipCertificates - } - if cr.ExternalSeedNodes != nil { - objectMap["externalSeedNodes"] = cr.ExternalSeedNodes - } - if cr.HoursBetweenBackups != nil { - objectMap["hoursBetweenBackups"] = cr.HoursBetweenBackups - } - if cr.Deallocated != nil { - objectMap["deallocated"] = cr.Deallocated - } - if cr.CassandraAuditLoggingEnabled != nil { - objectMap["cassandraAuditLoggingEnabled"] = cr.CassandraAuditLoggingEnabled - } - return json.Marshal(objectMap) -} - -// Column cosmos DB Cassandra table column -type Column struct { - // Name - Name of the Cosmos DB Cassandra table column - Name *string `json:"name,omitempty"` - // Type - Type of the Cosmos DB Cassandra table column - Type *string `json:"type,omitempty"` -} - -// CommandOutput response of /command api -type CommandOutput struct { - autorest.Response `json:"-"` - // CommandOutput - Output of the command. - CommandOutput *string `json:"commandOutput,omitempty"` -} - -// CommandPostBody specification of which command to run where -type CommandPostBody struct { - // Command - The command which should be run - Command *string `json:"command,omitempty"` - // Arguments - The arguments for the command to be run - Arguments map[string]*string `json:"arguments"` - // Host - IP address of the cassandra host to run the command on - Host *string `json:"host,omitempty"` - // CassandraStopStart - If true, stops cassandra before executing the command and then start it again - CassandraStopStart *bool `json:"cassandra-stop-start,omitempty"` - // Readwrite - If true, allows the command to *write* to the cassandra directory, otherwise read-only. - Readwrite *bool `json:"readwrite,omitempty"` -} - -// MarshalJSON is the custom marshaler for CommandPostBody. -func (cpb CommandPostBody) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if cpb.Command != nil { - objectMap["command"] = cpb.Command - } - if cpb.Arguments != nil { - objectMap["arguments"] = cpb.Arguments - } - if cpb.Host != nil { - objectMap["host"] = cpb.Host - } - if cpb.CassandraStopStart != nil { - objectMap["cassandra-stop-start"] = cpb.CassandraStopStart - } - if cpb.Readwrite != nil { - objectMap["readwrite"] = cpb.Readwrite - } - return json.Marshal(objectMap) -} - -// CompositePath ... -type CompositePath struct { - // Path - The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) - Path *string `json:"path,omitempty"` - // Order - Sort order for composite paths. Possible values include: 'CompositePathSortOrderAscending', 'CompositePathSortOrderDescending' - Order CompositePathSortOrder `json:"order,omitempty"` -} - -// ConflictResolutionPolicy the conflict resolution policy for the container. -type ConflictResolutionPolicy struct { - // Mode - Indicates the conflict resolution mode. Possible values include: 'ConflictResolutionModeLastWriterWins', 'ConflictResolutionModeCustom' - Mode ConflictResolutionMode `json:"mode,omitempty"` - // ConflictResolutionPath - The conflict resolution path in the case of LastWriterWins mode. - ConflictResolutionPath *string `json:"conflictResolutionPath,omitempty"` - // ConflictResolutionProcedure - The procedure to resolve conflicts in the case of custom mode. - ConflictResolutionProcedure *string `json:"conflictResolutionProcedure,omitempty"` -} - -// ConnectionError ... -type ConnectionError struct { - // ConnectionState - The kind of connection error that occurred. Possible values include: 'ConnectionStateUnknown', 'ConnectionStateOK', 'ConnectionStateOperatorToDataCenterNetworkError', 'ConnectionStateDatacenterToDatacenterNetworkError', 'ConnectionStateInternalOperatorToDataCenterCertificateError', 'ConnectionStateInternalError' - ConnectionState ConnectionState `json:"connectionState,omitempty"` - // IPFrom - The IP of host that originated the failed connection. - IPFrom *string `json:"iPFrom,omitempty"` - // IPTo - The IP that the connection attempted to reach. - IPTo *string `json:"iPTo,omitempty"` - // Port - The TCP port the connection was attempted on. - Port *int32 `json:"port,omitempty"` - // Exception - Detailed error message about the failed connection. - Exception *string `json:"exception,omitempty"` -} - -// ConsistencyPolicy the consistency policy for the Cosmos DB database account. -type ConsistencyPolicy struct { - // DefaultConsistencyLevel - The default consistency level and configuration settings of the Cosmos DB account. Possible values include: 'DefaultConsistencyLevelEventual', 'DefaultConsistencyLevelSession', 'DefaultConsistencyLevelBoundedStaleness', 'DefaultConsistencyLevelStrong', 'DefaultConsistencyLevelConsistentPrefix' - DefaultConsistencyLevel DefaultConsistencyLevel `json:"defaultConsistencyLevel,omitempty"` - // MaxStalenessPrefix - When used with the Bounded Staleness consistency level, this value represents the number of stale requests tolerated. Accepted range for this value is 1 – 2,147,483,647. Required when defaultConsistencyPolicy is set to 'BoundedStaleness'. - MaxStalenessPrefix *int64 `json:"maxStalenessPrefix,omitempty"` - // MaxIntervalInSeconds - When used with the Bounded Staleness consistency level, this value represents the time amount of staleness (in seconds) tolerated. Accepted range for this value is 5 - 86400. Required when defaultConsistencyPolicy is set to 'BoundedStaleness'. - MaxIntervalInSeconds *int32 `json:"maxIntervalInSeconds,omitempty"` -} - -// ContainerPartitionKey the configuration of the partition key to be used for partitioning data into -// multiple partitions -type ContainerPartitionKey struct { - // Paths - List of paths using which data within the container can be partitioned - Paths *[]string `json:"paths,omitempty"` - // Kind - Indicates the kind of algorithm used for partitioning. For MultiHash, multiple partition keys (upto three maximum) are supported for container create. Possible values include: 'PartitionKindHash', 'PartitionKindRange', 'PartitionKindMultiHash' - Kind PartitionKind `json:"kind,omitempty"` - // Version - Indicates the version of the partition key definition - Version *int32 `json:"version,omitempty"` - // SystemKey - READ-ONLY; Indicates if the container is using a system generated partition key - SystemKey *bool `json:"systemKey,omitempty"` -} - -// MarshalJSON is the custom marshaler for ContainerPartitionKey. -func (cpk ContainerPartitionKey) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if cpk.Paths != nil { - objectMap["paths"] = cpk.Paths - } - if cpk.Kind != "" { - objectMap["kind"] = cpk.Kind - } - if cpk.Version != nil { - objectMap["version"] = cpk.Version - } - return json.Marshal(objectMap) -} - -// ContinuousBackupInformation information about the status of continuous backups. -type ContinuousBackupInformation struct { - // LatestRestorableTimestamp - The latest restorable timestamp for a resource. - LatestRestorableTimestamp *string `json:"latestRestorableTimestamp,omitempty"` -} - -// ContinuousBackupRestoreLocation properties of the regional restorable account. -type ContinuousBackupRestoreLocation struct { - // Location - The name of the continuous backup restore location. - Location *string `json:"location,omitempty"` -} - -// ContinuousModeBackupPolicy the object representing continuous mode backup policy. -type ContinuousModeBackupPolicy struct { - // MigrationState - The object representing the state of the migration between the backup policies. - MigrationState *BackupPolicyMigrationState `json:"migrationState,omitempty"` - // Type - Possible values include: 'TypeBackupPolicy', 'TypePeriodic', 'TypeContinuous' - Type Type `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for ContinuousModeBackupPolicy. -func (cmbp ContinuousModeBackupPolicy) MarshalJSON() ([]byte, error) { - cmbp.Type = TypeContinuous - objectMap := make(map[string]interface{}) - if cmbp.MigrationState != nil { - objectMap["migrationState"] = cmbp.MigrationState - } - if cmbp.Type != "" { - objectMap["type"] = cmbp.Type - } - return json.Marshal(objectMap) -} - -// AsPeriodicModeBackupPolicy is the BasicBackupPolicy implementation for ContinuousModeBackupPolicy. -func (cmbp ContinuousModeBackupPolicy) AsPeriodicModeBackupPolicy() (*PeriodicModeBackupPolicy, bool) { - return nil, false -} - -// AsContinuousModeBackupPolicy is the BasicBackupPolicy implementation for ContinuousModeBackupPolicy. -func (cmbp ContinuousModeBackupPolicy) AsContinuousModeBackupPolicy() (*ContinuousModeBackupPolicy, bool) { - return &cmbp, true -} - -// AsBackupPolicy is the BasicBackupPolicy implementation for ContinuousModeBackupPolicy. -func (cmbp ContinuousModeBackupPolicy) AsBackupPolicy() (*BackupPolicy, bool) { - return nil, false -} - -// AsBasicBackupPolicy is the BasicBackupPolicy implementation for ContinuousModeBackupPolicy. -func (cmbp ContinuousModeBackupPolicy) AsBasicBackupPolicy() (BasicBackupPolicy, bool) { - return &cmbp, true -} - -// CorsPolicy the CORS policy for the Cosmos DB database account. -type CorsPolicy struct { - // AllowedOrigins - The origin domains that are permitted to make a request against the service via CORS. - AllowedOrigins *string `json:"allowedOrigins,omitempty"` - // AllowedMethods - The methods (HTTP request verbs) that the origin domain may use for a CORS request. - AllowedMethods *string `json:"allowedMethods,omitempty"` - // AllowedHeaders - The request headers that the origin domain may specify on the CORS request. - AllowedHeaders *string `json:"allowedHeaders,omitempty"` - // ExposedHeaders - The response headers that may be sent in the response to the CORS request and exposed by the browser to the request issuer. - ExposedHeaders *string `json:"exposedHeaders,omitempty"` - // MaxAgeInSeconds - The maximum amount time that a browser should cache the preflight OPTIONS request. - MaxAgeInSeconds *int64 `json:"maxAgeInSeconds,omitempty"` -} - -// CreateUpdateOptions createUpdateOptions are a list of key-value pairs that describe the resource. -// Supported keys are "If-Match", "If-None-Match", "Session-Token" and "Throughput" -type CreateUpdateOptions struct { - // Throughput - Request Units per second. For example, "throughput": 10000. - Throughput *int32 `json:"throughput,omitempty"` - // AutoscaleSettings - Specifies the Autoscale settings. - AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` -} - -// DatabaseAccountConnectionString connection string for the Cosmos DB account -type DatabaseAccountConnectionString struct { - // ConnectionString - READ-ONLY; Value of the connection string - ConnectionString *string `json:"connectionString,omitempty"` - // Description - READ-ONLY; Description of the connection string - Description *string `json:"description,omitempty"` -} - -// MarshalJSON is the custom marshaler for DatabaseAccountConnectionString. -func (dacs DatabaseAccountConnectionString) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// DatabaseAccountCreateUpdateParameters parameters to create and update Cosmos DB database accounts. -type DatabaseAccountCreateUpdateParameters struct { - // Kind - Indicates the type of database account. This can only be set at database account creation. Possible values include: 'DatabaseAccountKindGlobalDocumentDB', 'DatabaseAccountKindMongoDB', 'DatabaseAccountKindParse' - Kind DatabaseAccountKind `json:"kind,omitempty"` - Identity *ManagedServiceIdentity `json:"identity,omitempty"` - *DatabaseAccountCreateUpdateProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for DatabaseAccountCreateUpdateParameters. -func (dacup DatabaseAccountCreateUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if dacup.Kind != "" { - objectMap["kind"] = dacup.Kind - } - if dacup.Identity != nil { - objectMap["identity"] = dacup.Identity - } - if dacup.DatabaseAccountCreateUpdateProperties != nil { - objectMap["properties"] = dacup.DatabaseAccountCreateUpdateProperties - } - if dacup.Location != nil { - objectMap["location"] = dacup.Location - } - if dacup.Tags != nil { - objectMap["tags"] = dacup.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for DatabaseAccountCreateUpdateParameters struct. -func (dacup *DatabaseAccountCreateUpdateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "kind": - if v != nil { - var kind DatabaseAccountKind - err = json.Unmarshal(*v, &kind) - if err != nil { - return err - } - dacup.Kind = kind - } - case "identity": - if v != nil { - var identity ManagedServiceIdentity - err = json.Unmarshal(*v, &identity) - if err != nil { - return err - } - dacup.Identity = &identity - } - case "properties": - if v != nil { - var databaseAccountCreateUpdateProperties DatabaseAccountCreateUpdateProperties - err = json.Unmarshal(*v, &databaseAccountCreateUpdateProperties) - if err != nil { - return err - } - dacup.DatabaseAccountCreateUpdateProperties = &databaseAccountCreateUpdateProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - dacup.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - dacup.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - dacup.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - dacup.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - dacup.Tags = tags - } - } - } - - return nil -} - -// DatabaseAccountCreateUpdateProperties properties to create and update Azure Cosmos DB database accounts. -type DatabaseAccountCreateUpdateProperties struct { - // ConsistencyPolicy - The consistency policy for the Cosmos DB account. - ConsistencyPolicy *ConsistencyPolicy `json:"consistencyPolicy,omitempty"` - // Locations - An array that contains the georeplication locations enabled for the Cosmos DB account. - Locations *[]Location `json:"locations,omitempty"` - // DatabaseAccountOfferType - The offer type for the database - DatabaseAccountOfferType *string `json:"databaseAccountOfferType,omitempty"` - // IPRules - List of IpRules. - IPRules *[]IPAddressOrRange `json:"ipRules,omitempty"` - // IsVirtualNetworkFilterEnabled - Flag to indicate whether to enable/disable Virtual Network ACL rules. - IsVirtualNetworkFilterEnabled *bool `json:"isVirtualNetworkFilterEnabled,omitempty"` - // EnableAutomaticFailover - Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account. - EnableAutomaticFailover *bool `json:"enableAutomaticFailover,omitempty"` - // Capabilities - List of Cosmos DB capabilities for the account - Capabilities *[]Capability `json:"capabilities,omitempty"` - // VirtualNetworkRules - List of Virtual Network ACL rules configured for the Cosmos DB account. - VirtualNetworkRules *[]VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` - // EnableMultipleWriteLocations - Enables the account to write in multiple locations - EnableMultipleWriteLocations *bool `json:"enableMultipleWriteLocations,omitempty"` - // EnableCassandraConnector - Enables the cassandra connector on the Cosmos DB C* account - EnableCassandraConnector *bool `json:"enableCassandraConnector,omitempty"` - // ConnectorOffer - The cassandra connector offer type for the Cosmos DB database C* account. Possible values include: 'ConnectorOfferSmall' - ConnectorOffer ConnectorOffer `json:"connectorOffer,omitempty"` - // DisableKeyBasedMetadataWriteAccess - Disable write operations on metadata resources (databases, containers, throughput) via account keys - DisableKeyBasedMetadataWriteAccess *bool `json:"disableKeyBasedMetadataWriteAccess,omitempty"` - // KeyVaultKeyURI - The URI of the key vault - KeyVaultKeyURI *string `json:"keyVaultKeyUri,omitempty"` - // DefaultIdentity - The default identity for accessing key vault used in features like customer managed keys. The default identity needs to be explicitly set by the users. It can be "FirstPartyIdentity", "SystemAssignedIdentity" and more. - DefaultIdentity *string `json:"defaultIdentity,omitempty"` - // PublicNetworkAccess - Whether requests from Public Network are allowed. Possible values include: 'PublicNetworkAccessEnabled', 'PublicNetworkAccessDisabled' - PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` - // EnableFreeTier - Flag to indicate whether Free Tier is enabled. - EnableFreeTier *bool `json:"enableFreeTier,omitempty"` - // APIProperties - API specific properties. Currently, supported only for MongoDB API. - APIProperties *APIProperties `json:"apiProperties,omitempty"` - // EnableAnalyticalStorage - Flag to indicate whether to enable storage analytics. - EnableAnalyticalStorage *bool `json:"enableAnalyticalStorage,omitempty"` - // AnalyticalStorageConfiguration - Analytical storage specific properties. - AnalyticalStorageConfiguration *AnalyticalStorageConfiguration `json:"analyticalStorageConfiguration,omitempty"` - // CreateMode - Enum to indicate the mode of account creation. Possible values include: 'CreateModeDefault', 'CreateModeRestore' - CreateMode CreateMode `json:"createMode,omitempty"` - // BackupPolicy - The object representing the policy for taking backups on an account. - BackupPolicy BasicBackupPolicy `json:"backupPolicy,omitempty"` - // Cors - The CORS policy for the Cosmos DB database account. - Cors *[]CorsPolicy `json:"cors,omitempty"` - // NetworkACLBypass - Indicates what services are allowed to bypass firewall checks. Possible values include: 'NetworkACLBypassNone', 'NetworkACLBypassAzureServices' - NetworkACLBypass NetworkACLBypass `json:"networkAclBypass,omitempty"` - // NetworkACLBypassResourceIds - An array that contains the Resource Ids for Network Acl Bypass for the Cosmos DB account. - NetworkACLBypassResourceIds *[]string `json:"networkAclBypassResourceIds,omitempty"` - // DisableLocalAuth - Opt-out of local authentication and ensure only MSI and AAD can be used exclusively for authentication. - DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` - // RestoreParameters - Parameters to indicate the information about the restore. - RestoreParameters *RestoreParameters `json:"restoreParameters,omitempty"` - // Capacity - The object that represents all properties related to capacity enforcement on an account. - Capacity *Capacity `json:"capacity,omitempty"` -} - -// UnmarshalJSON is the custom unmarshaler for DatabaseAccountCreateUpdateProperties struct. -func (dacup *DatabaseAccountCreateUpdateProperties) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "consistencyPolicy": - if v != nil { - var consistencyPolicy ConsistencyPolicy - err = json.Unmarshal(*v, &consistencyPolicy) - if err != nil { - return err - } - dacup.ConsistencyPolicy = &consistencyPolicy - } - case "locations": - if v != nil { - var locations []Location - err = json.Unmarshal(*v, &locations) - if err != nil { - return err - } - dacup.Locations = &locations - } - case "databaseAccountOfferType": - if v != nil { - var databaseAccountOfferType string - err = json.Unmarshal(*v, &databaseAccountOfferType) - if err != nil { - return err - } - dacup.DatabaseAccountOfferType = &databaseAccountOfferType - } - case "ipRules": - if v != nil { - var IPRules []IPAddressOrRange - err = json.Unmarshal(*v, &IPRules) - if err != nil { - return err - } - dacup.IPRules = &IPRules - } - case "isVirtualNetworkFilterEnabled": - if v != nil { - var isVirtualNetworkFilterEnabled bool - err = json.Unmarshal(*v, &isVirtualNetworkFilterEnabled) - if err != nil { - return err - } - dacup.IsVirtualNetworkFilterEnabled = &isVirtualNetworkFilterEnabled - } - case "enableAutomaticFailover": - if v != nil { - var enableAutomaticFailover bool - err = json.Unmarshal(*v, &enableAutomaticFailover) - if err != nil { - return err - } - dacup.EnableAutomaticFailover = &enableAutomaticFailover - } - case "capabilities": - if v != nil { - var capabilities []Capability - err = json.Unmarshal(*v, &capabilities) - if err != nil { - return err - } - dacup.Capabilities = &capabilities - } - case "virtualNetworkRules": - if v != nil { - var virtualNetworkRules []VirtualNetworkRule - err = json.Unmarshal(*v, &virtualNetworkRules) - if err != nil { - return err - } - dacup.VirtualNetworkRules = &virtualNetworkRules - } - case "enableMultipleWriteLocations": - if v != nil { - var enableMultipleWriteLocations bool - err = json.Unmarshal(*v, &enableMultipleWriteLocations) - if err != nil { - return err - } - dacup.EnableMultipleWriteLocations = &enableMultipleWriteLocations - } - case "enableCassandraConnector": - if v != nil { - var enableCassandraConnector bool - err = json.Unmarshal(*v, &enableCassandraConnector) - if err != nil { - return err - } - dacup.EnableCassandraConnector = &enableCassandraConnector - } - case "connectorOffer": - if v != nil { - var connectorOffer ConnectorOffer - err = json.Unmarshal(*v, &connectorOffer) - if err != nil { - return err - } - dacup.ConnectorOffer = connectorOffer - } - case "disableKeyBasedMetadataWriteAccess": - if v != nil { - var disableKeyBasedMetadataWriteAccess bool - err = json.Unmarshal(*v, &disableKeyBasedMetadataWriteAccess) - if err != nil { - return err - } - dacup.DisableKeyBasedMetadataWriteAccess = &disableKeyBasedMetadataWriteAccess - } - case "keyVaultKeyUri": - if v != nil { - var keyVaultKeyURI string - err = json.Unmarshal(*v, &keyVaultKeyURI) - if err != nil { - return err - } - dacup.KeyVaultKeyURI = &keyVaultKeyURI - } - case "defaultIdentity": - if v != nil { - var defaultIdentity string - err = json.Unmarshal(*v, &defaultIdentity) - if err != nil { - return err - } - dacup.DefaultIdentity = &defaultIdentity - } - case "publicNetworkAccess": - if v != nil { - var publicNetworkAccess PublicNetworkAccess - err = json.Unmarshal(*v, &publicNetworkAccess) - if err != nil { - return err - } - dacup.PublicNetworkAccess = publicNetworkAccess - } - case "enableFreeTier": - if v != nil { - var enableFreeTier bool - err = json.Unmarshal(*v, &enableFreeTier) - if err != nil { - return err - } - dacup.EnableFreeTier = &enableFreeTier - } - case "apiProperties": - if v != nil { - var APIProperties APIProperties - err = json.Unmarshal(*v, &APIProperties) - if err != nil { - return err - } - dacup.APIProperties = &APIProperties - } - case "enableAnalyticalStorage": - if v != nil { - var enableAnalyticalStorage bool - err = json.Unmarshal(*v, &enableAnalyticalStorage) - if err != nil { - return err - } - dacup.EnableAnalyticalStorage = &enableAnalyticalStorage - } - case "analyticalStorageConfiguration": - if v != nil { - var analyticalStorageConfiguration AnalyticalStorageConfiguration - err = json.Unmarshal(*v, &analyticalStorageConfiguration) - if err != nil { - return err - } - dacup.AnalyticalStorageConfiguration = &analyticalStorageConfiguration - } - case "createMode": - if v != nil { - var createMode CreateMode - err = json.Unmarshal(*v, &createMode) - if err != nil { - return err - } - dacup.CreateMode = createMode - } - case "backupPolicy": - if v != nil { - backupPolicy, err := unmarshalBasicBackupPolicy(*v) - if err != nil { - return err - } - dacup.BackupPolicy = backupPolicy - } - case "cors": - if v != nil { - var cors []CorsPolicy - err = json.Unmarshal(*v, &cors) - if err != nil { - return err - } - dacup.Cors = &cors - } - case "networkAclBypass": - if v != nil { - var networkACLBypass NetworkACLBypass - err = json.Unmarshal(*v, &networkACLBypass) - if err != nil { - return err - } - dacup.NetworkACLBypass = networkACLBypass - } - case "networkAclBypassResourceIds": - if v != nil { - var networkACLBypassResourceIds []string - err = json.Unmarshal(*v, &networkACLBypassResourceIds) - if err != nil { - return err - } - dacup.NetworkACLBypassResourceIds = &networkACLBypassResourceIds - } - case "disableLocalAuth": - if v != nil { - var disableLocalAuth bool - err = json.Unmarshal(*v, &disableLocalAuth) - if err != nil { - return err - } - dacup.DisableLocalAuth = &disableLocalAuth - } - case "restoreParameters": - if v != nil { - var restoreParameters RestoreParameters - err = json.Unmarshal(*v, &restoreParameters) - if err != nil { - return err - } - dacup.RestoreParameters = &restoreParameters - } - case "capacity": - if v != nil { - var capacity Capacity - err = json.Unmarshal(*v, &capacity) - if err != nil { - return err - } - dacup.Capacity = &capacity - } - } - } - - return nil -} - -// DatabaseAccountGetProperties properties for the database account. -type DatabaseAccountGetProperties struct { - ProvisioningState *string `json:"provisioningState,omitempty"` - // DocumentEndpoint - READ-ONLY; The connection endpoint for the Cosmos DB database account. - DocumentEndpoint *string `json:"documentEndpoint,omitempty"` - // DatabaseAccountOfferType - READ-ONLY; The offer type for the Cosmos DB database account. Default value: Standard. Possible values include: 'DatabaseAccountOfferTypeStandard' - DatabaseAccountOfferType DatabaseAccountOfferType `json:"databaseAccountOfferType,omitempty"` - // IPRules - List of IpRules. - IPRules *[]IPAddressOrRange `json:"ipRules,omitempty"` - // IsVirtualNetworkFilterEnabled - Flag to indicate whether to enable/disable Virtual Network ACL rules. - IsVirtualNetworkFilterEnabled *bool `json:"isVirtualNetworkFilterEnabled,omitempty"` - // EnableAutomaticFailover - Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account. - EnableAutomaticFailover *bool `json:"enableAutomaticFailover,omitempty"` - // ConsistencyPolicy - The consistency policy for the Cosmos DB database account. - ConsistencyPolicy *ConsistencyPolicy `json:"consistencyPolicy,omitempty"` - // Capabilities - List of Cosmos DB capabilities for the account - Capabilities *[]Capability `json:"capabilities,omitempty"` - // WriteLocations - READ-ONLY; An array that contains the write location for the Cosmos DB account. - WriteLocations *[]Location `json:"writeLocations,omitempty"` - // ReadLocations - READ-ONLY; An array that contains of the read locations enabled for the Cosmos DB account. - ReadLocations *[]Location `json:"readLocations,omitempty"` - // Locations - READ-ONLY; An array that contains all of the locations enabled for the Cosmos DB account. - Locations *[]Location `json:"locations,omitempty"` - // FailoverPolicies - READ-ONLY; An array that contains the regions ordered by their failover priorities. - FailoverPolicies *[]FailoverPolicy `json:"failoverPolicies,omitempty"` - // VirtualNetworkRules - List of Virtual Network ACL rules configured for the Cosmos DB account. - VirtualNetworkRules *[]VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` - // PrivateEndpointConnections - READ-ONLY; List of Private Endpoint Connections configured for the Cosmos DB account. - PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` - // EnableMultipleWriteLocations - Enables the account to write in multiple locations - EnableMultipleWriteLocations *bool `json:"enableMultipleWriteLocations,omitempty"` - // EnableCassandraConnector - Enables the cassandra connector on the Cosmos DB C* account - EnableCassandraConnector *bool `json:"enableCassandraConnector,omitempty"` - // ConnectorOffer - The cassandra connector offer type for the Cosmos DB database C* account. Possible values include: 'ConnectorOfferSmall' - ConnectorOffer ConnectorOffer `json:"connectorOffer,omitempty"` - // DisableKeyBasedMetadataWriteAccess - Disable write operations on metadata resources (databases, containers, throughput) via account keys - DisableKeyBasedMetadataWriteAccess *bool `json:"disableKeyBasedMetadataWriteAccess,omitempty"` - // KeyVaultKeyURI - The URI of the key vault - KeyVaultKeyURI *string `json:"keyVaultKeyUri,omitempty"` - // DefaultIdentity - The default identity for accessing key vault used in features like customer managed keys. The default identity needs to be explicitly set by the users. It can be "FirstPartyIdentity", "SystemAssignedIdentity" and more. - DefaultIdentity *string `json:"defaultIdentity,omitempty"` - // PublicNetworkAccess - Whether requests from Public Network are allowed. Possible values include: 'PublicNetworkAccessEnabled', 'PublicNetworkAccessDisabled' - PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` - // EnableFreeTier - Flag to indicate whether Free Tier is enabled. - EnableFreeTier *bool `json:"enableFreeTier,omitempty"` - // APIProperties - API specific properties. - APIProperties *APIProperties `json:"apiProperties,omitempty"` - // EnableAnalyticalStorage - Flag to indicate whether to enable storage analytics. - EnableAnalyticalStorage *bool `json:"enableAnalyticalStorage,omitempty"` - // AnalyticalStorageConfiguration - Analytical storage specific properties. - AnalyticalStorageConfiguration *AnalyticalStorageConfiguration `json:"analyticalStorageConfiguration,omitempty"` - // InstanceID - READ-ONLY; A unique identifier assigned to the database account - InstanceID *string `json:"instanceId,omitempty"` - // CreateMode - Enum to indicate the mode of account creation. Possible values include: 'CreateModeDefault', 'CreateModeRestore' - CreateMode CreateMode `json:"createMode,omitempty"` - // RestoreParameters - Parameters to indicate the information about the restore. - RestoreParameters *RestoreParameters `json:"restoreParameters,omitempty"` - // BackupPolicy - The object representing the policy for taking backups on an account. - BackupPolicy BasicBackupPolicy `json:"backupPolicy,omitempty"` - // Cors - The CORS policy for the Cosmos DB database account. - Cors *[]CorsPolicy `json:"cors,omitempty"` - // NetworkACLBypass - Indicates what services are allowed to bypass firewall checks. Possible values include: 'NetworkACLBypassNone', 'NetworkACLBypassAzureServices' - NetworkACLBypass NetworkACLBypass `json:"networkAclBypass,omitempty"` - // NetworkACLBypassResourceIds - An array that contains the Resource Ids for Network Acl Bypass for the Cosmos DB account. - NetworkACLBypassResourceIds *[]string `json:"networkAclBypassResourceIds,omitempty"` - // DisableLocalAuth - Opt-out of local authentication and ensure only MSI and AAD can be used exclusively for authentication. - DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` - // Capacity - The object that represents all properties related to capacity enforcement on an account. - Capacity *Capacity `json:"capacity,omitempty"` -} - -// MarshalJSON is the custom marshaler for DatabaseAccountGetProperties. -func (dagp DatabaseAccountGetProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if dagp.ProvisioningState != nil { - objectMap["provisioningState"] = dagp.ProvisioningState - } - if dagp.IPRules != nil { - objectMap["ipRules"] = dagp.IPRules - } - if dagp.IsVirtualNetworkFilterEnabled != nil { - objectMap["isVirtualNetworkFilterEnabled"] = dagp.IsVirtualNetworkFilterEnabled - } - if dagp.EnableAutomaticFailover != nil { - objectMap["enableAutomaticFailover"] = dagp.EnableAutomaticFailover - } - if dagp.ConsistencyPolicy != nil { - objectMap["consistencyPolicy"] = dagp.ConsistencyPolicy - } - if dagp.Capabilities != nil { - objectMap["capabilities"] = dagp.Capabilities - } - if dagp.VirtualNetworkRules != nil { - objectMap["virtualNetworkRules"] = dagp.VirtualNetworkRules - } - if dagp.EnableMultipleWriteLocations != nil { - objectMap["enableMultipleWriteLocations"] = dagp.EnableMultipleWriteLocations - } - if dagp.EnableCassandraConnector != nil { - objectMap["enableCassandraConnector"] = dagp.EnableCassandraConnector - } - if dagp.ConnectorOffer != "" { - objectMap["connectorOffer"] = dagp.ConnectorOffer - } - if dagp.DisableKeyBasedMetadataWriteAccess != nil { - objectMap["disableKeyBasedMetadataWriteAccess"] = dagp.DisableKeyBasedMetadataWriteAccess - } - if dagp.KeyVaultKeyURI != nil { - objectMap["keyVaultKeyUri"] = dagp.KeyVaultKeyURI - } - if dagp.DefaultIdentity != nil { - objectMap["defaultIdentity"] = dagp.DefaultIdentity - } - if dagp.PublicNetworkAccess != "" { - objectMap["publicNetworkAccess"] = dagp.PublicNetworkAccess - } - if dagp.EnableFreeTier != nil { - objectMap["enableFreeTier"] = dagp.EnableFreeTier - } - if dagp.APIProperties != nil { - objectMap["apiProperties"] = dagp.APIProperties - } - if dagp.EnableAnalyticalStorage != nil { - objectMap["enableAnalyticalStorage"] = dagp.EnableAnalyticalStorage - } - if dagp.AnalyticalStorageConfiguration != nil { - objectMap["analyticalStorageConfiguration"] = dagp.AnalyticalStorageConfiguration - } - if dagp.CreateMode != "" { - objectMap["createMode"] = dagp.CreateMode - } - if dagp.RestoreParameters != nil { - objectMap["restoreParameters"] = dagp.RestoreParameters - } - objectMap["backupPolicy"] = dagp.BackupPolicy - if dagp.Cors != nil { - objectMap["cors"] = dagp.Cors - } - if dagp.NetworkACLBypass != "" { - objectMap["networkAclBypass"] = dagp.NetworkACLBypass - } - if dagp.NetworkACLBypassResourceIds != nil { - objectMap["networkAclBypassResourceIds"] = dagp.NetworkACLBypassResourceIds - } - if dagp.DisableLocalAuth != nil { - objectMap["disableLocalAuth"] = dagp.DisableLocalAuth - } - if dagp.Capacity != nil { - objectMap["capacity"] = dagp.Capacity - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for DatabaseAccountGetProperties struct. -func (dagp *DatabaseAccountGetProperties) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "provisioningState": - if v != nil { - var provisioningState string - err = json.Unmarshal(*v, &provisioningState) - if err != nil { - return err - } - dagp.ProvisioningState = &provisioningState - } - case "documentEndpoint": - if v != nil { - var documentEndpoint string - err = json.Unmarshal(*v, &documentEndpoint) - if err != nil { - return err - } - dagp.DocumentEndpoint = &documentEndpoint - } - case "databaseAccountOfferType": - if v != nil { - var databaseAccountOfferType DatabaseAccountOfferType - err = json.Unmarshal(*v, &databaseAccountOfferType) - if err != nil { - return err - } - dagp.DatabaseAccountOfferType = databaseAccountOfferType - } - case "ipRules": - if v != nil { - var IPRules []IPAddressOrRange - err = json.Unmarshal(*v, &IPRules) - if err != nil { - return err - } - dagp.IPRules = &IPRules - } - case "isVirtualNetworkFilterEnabled": - if v != nil { - var isVirtualNetworkFilterEnabled bool - err = json.Unmarshal(*v, &isVirtualNetworkFilterEnabled) - if err != nil { - return err - } - dagp.IsVirtualNetworkFilterEnabled = &isVirtualNetworkFilterEnabled - } - case "enableAutomaticFailover": - if v != nil { - var enableAutomaticFailover bool - err = json.Unmarshal(*v, &enableAutomaticFailover) - if err != nil { - return err - } - dagp.EnableAutomaticFailover = &enableAutomaticFailover - } - case "consistencyPolicy": - if v != nil { - var consistencyPolicy ConsistencyPolicy - err = json.Unmarshal(*v, &consistencyPolicy) - if err != nil { - return err - } - dagp.ConsistencyPolicy = &consistencyPolicy - } - case "capabilities": - if v != nil { - var capabilities []Capability - err = json.Unmarshal(*v, &capabilities) - if err != nil { - return err - } - dagp.Capabilities = &capabilities - } - case "writeLocations": - if v != nil { - var writeLocations []Location - err = json.Unmarshal(*v, &writeLocations) - if err != nil { - return err - } - dagp.WriteLocations = &writeLocations - } - case "readLocations": - if v != nil { - var readLocations []Location - err = json.Unmarshal(*v, &readLocations) - if err != nil { - return err - } - dagp.ReadLocations = &readLocations - } - case "locations": - if v != nil { - var locations []Location - err = json.Unmarshal(*v, &locations) - if err != nil { - return err - } - dagp.Locations = &locations - } - case "failoverPolicies": - if v != nil { - var failoverPolicies []FailoverPolicy - err = json.Unmarshal(*v, &failoverPolicies) - if err != nil { - return err - } - dagp.FailoverPolicies = &failoverPolicies - } - case "virtualNetworkRules": - if v != nil { - var virtualNetworkRules []VirtualNetworkRule - err = json.Unmarshal(*v, &virtualNetworkRules) - if err != nil { - return err - } - dagp.VirtualNetworkRules = &virtualNetworkRules - } - case "privateEndpointConnections": - if v != nil { - var privateEndpointConnections []PrivateEndpointConnection - err = json.Unmarshal(*v, &privateEndpointConnections) - if err != nil { - return err - } - dagp.PrivateEndpointConnections = &privateEndpointConnections - } - case "enableMultipleWriteLocations": - if v != nil { - var enableMultipleWriteLocations bool - err = json.Unmarshal(*v, &enableMultipleWriteLocations) - if err != nil { - return err - } - dagp.EnableMultipleWriteLocations = &enableMultipleWriteLocations - } - case "enableCassandraConnector": - if v != nil { - var enableCassandraConnector bool - err = json.Unmarshal(*v, &enableCassandraConnector) - if err != nil { - return err - } - dagp.EnableCassandraConnector = &enableCassandraConnector - } - case "connectorOffer": - if v != nil { - var connectorOffer ConnectorOffer - err = json.Unmarshal(*v, &connectorOffer) - if err != nil { - return err - } - dagp.ConnectorOffer = connectorOffer - } - case "disableKeyBasedMetadataWriteAccess": - if v != nil { - var disableKeyBasedMetadataWriteAccess bool - err = json.Unmarshal(*v, &disableKeyBasedMetadataWriteAccess) - if err != nil { - return err - } - dagp.DisableKeyBasedMetadataWriteAccess = &disableKeyBasedMetadataWriteAccess - } - case "keyVaultKeyUri": - if v != nil { - var keyVaultKeyURI string - err = json.Unmarshal(*v, &keyVaultKeyURI) - if err != nil { - return err - } - dagp.KeyVaultKeyURI = &keyVaultKeyURI - } - case "defaultIdentity": - if v != nil { - var defaultIdentity string - err = json.Unmarshal(*v, &defaultIdentity) - if err != nil { - return err - } - dagp.DefaultIdentity = &defaultIdentity - } - case "publicNetworkAccess": - if v != nil { - var publicNetworkAccess PublicNetworkAccess - err = json.Unmarshal(*v, &publicNetworkAccess) - if err != nil { - return err - } - dagp.PublicNetworkAccess = publicNetworkAccess - } - case "enableFreeTier": - if v != nil { - var enableFreeTier bool - err = json.Unmarshal(*v, &enableFreeTier) - if err != nil { - return err - } - dagp.EnableFreeTier = &enableFreeTier - } - case "apiProperties": - if v != nil { - var APIProperties APIProperties - err = json.Unmarshal(*v, &APIProperties) - if err != nil { - return err - } - dagp.APIProperties = &APIProperties - } - case "enableAnalyticalStorage": - if v != nil { - var enableAnalyticalStorage bool - err = json.Unmarshal(*v, &enableAnalyticalStorage) - if err != nil { - return err - } - dagp.EnableAnalyticalStorage = &enableAnalyticalStorage - } - case "analyticalStorageConfiguration": - if v != nil { - var analyticalStorageConfiguration AnalyticalStorageConfiguration - err = json.Unmarshal(*v, &analyticalStorageConfiguration) - if err != nil { - return err - } - dagp.AnalyticalStorageConfiguration = &analyticalStorageConfiguration - } - case "instanceId": - if v != nil { - var instanceID string - err = json.Unmarshal(*v, &instanceID) - if err != nil { - return err - } - dagp.InstanceID = &instanceID - } - case "createMode": - if v != nil { - var createMode CreateMode - err = json.Unmarshal(*v, &createMode) - if err != nil { - return err - } - dagp.CreateMode = createMode - } - case "restoreParameters": - if v != nil { - var restoreParameters RestoreParameters - err = json.Unmarshal(*v, &restoreParameters) - if err != nil { - return err - } - dagp.RestoreParameters = &restoreParameters - } - case "backupPolicy": - if v != nil { - backupPolicy, err := unmarshalBasicBackupPolicy(*v) - if err != nil { - return err - } - dagp.BackupPolicy = backupPolicy - } - case "cors": - if v != nil { - var cors []CorsPolicy - err = json.Unmarshal(*v, &cors) - if err != nil { - return err - } - dagp.Cors = &cors - } - case "networkAclBypass": - if v != nil { - var networkACLBypass NetworkACLBypass - err = json.Unmarshal(*v, &networkACLBypass) - if err != nil { - return err - } - dagp.NetworkACLBypass = networkACLBypass - } - case "networkAclBypassResourceIds": - if v != nil { - var networkACLBypassResourceIds []string - err = json.Unmarshal(*v, &networkACLBypassResourceIds) - if err != nil { - return err - } - dagp.NetworkACLBypassResourceIds = &networkACLBypassResourceIds - } - case "disableLocalAuth": - if v != nil { - var disableLocalAuth bool - err = json.Unmarshal(*v, &disableLocalAuth) - if err != nil { - return err - } - dagp.DisableLocalAuth = &disableLocalAuth - } - case "capacity": - if v != nil { - var capacity Capacity - err = json.Unmarshal(*v, &capacity) - if err != nil { - return err - } - dagp.Capacity = &capacity - } - } - } - - return nil -} - -// DatabaseAccountGetResults an Azure Cosmos DB database account. -type DatabaseAccountGetResults struct { - autorest.Response `json:"-"` - // Kind - Indicates the type of database account. This can only be set at database account creation. Possible values include: 'DatabaseAccountKindGlobalDocumentDB', 'DatabaseAccountKindMongoDB', 'DatabaseAccountKindParse' - Kind DatabaseAccountKind `json:"kind,omitempty"` - Identity *ManagedServiceIdentity `json:"identity,omitempty"` - *DatabaseAccountGetProperties `json:"properties,omitempty"` - // SystemData - READ-ONLY; The system meta data relating to this resource. - SystemData *SystemData `json:"systemData,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for DatabaseAccountGetResults. -func (dagr DatabaseAccountGetResults) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if dagr.Kind != "" { - objectMap["kind"] = dagr.Kind - } - if dagr.Identity != nil { - objectMap["identity"] = dagr.Identity - } - if dagr.DatabaseAccountGetProperties != nil { - objectMap["properties"] = dagr.DatabaseAccountGetProperties - } - if dagr.Location != nil { - objectMap["location"] = dagr.Location - } - if dagr.Tags != nil { - objectMap["tags"] = dagr.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for DatabaseAccountGetResults struct. -func (dagr *DatabaseAccountGetResults) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "kind": - if v != nil { - var kind DatabaseAccountKind - err = json.Unmarshal(*v, &kind) - if err != nil { - return err - } - dagr.Kind = kind - } - case "identity": - if v != nil { - var identity ManagedServiceIdentity - err = json.Unmarshal(*v, &identity) - if err != nil { - return err - } - dagr.Identity = &identity - } - case "properties": - if v != nil { - var databaseAccountGetProperties DatabaseAccountGetProperties - err = json.Unmarshal(*v, &databaseAccountGetProperties) - if err != nil { - return err - } - dagr.DatabaseAccountGetProperties = &databaseAccountGetProperties - } - case "systemData": - if v != nil { - var systemData SystemData - err = json.Unmarshal(*v, &systemData) - if err != nil { - return err - } - dagr.SystemData = &systemData - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - dagr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - dagr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - dagr.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - dagr.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - dagr.Tags = tags - } - } - } - - return nil -} - -// DatabaseAccountListConnectionStringsResult the connection strings for the given database account. -type DatabaseAccountListConnectionStringsResult struct { - autorest.Response `json:"-"` - // ConnectionStrings - An array that contains the connection strings for the Cosmos DB account. - ConnectionStrings *[]DatabaseAccountConnectionString `json:"connectionStrings,omitempty"` -} - -// DatabaseAccountListKeysResult the access keys for the given database account. -type DatabaseAccountListKeysResult struct { - autorest.Response `json:"-"` - // PrimaryMasterKey - READ-ONLY; Base 64 encoded value of the primary read-write key. - PrimaryMasterKey *string `json:"primaryMasterKey,omitempty"` - // SecondaryMasterKey - READ-ONLY; Base 64 encoded value of the secondary read-write key. - SecondaryMasterKey *string `json:"secondaryMasterKey,omitempty"` - // PrimaryReadonlyMasterKey - READ-ONLY; Base 64 encoded value of the primary read-only key. - PrimaryReadonlyMasterKey *string `json:"primaryReadonlyMasterKey,omitempty"` - // SecondaryReadonlyMasterKey - READ-ONLY; Base 64 encoded value of the secondary read-only key. - SecondaryReadonlyMasterKey *string `json:"secondaryReadonlyMasterKey,omitempty"` -} - -// MarshalJSON is the custom marshaler for DatabaseAccountListKeysResult. -func (dalkr DatabaseAccountListKeysResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// DatabaseAccountListReadOnlyKeysResult the read-only access keys for the given database account. -type DatabaseAccountListReadOnlyKeysResult struct { - autorest.Response `json:"-"` - // PrimaryReadonlyMasterKey - READ-ONLY; Base 64 encoded value of the primary read-only key. - PrimaryReadonlyMasterKey *string `json:"primaryReadonlyMasterKey,omitempty"` - // SecondaryReadonlyMasterKey - READ-ONLY; Base 64 encoded value of the secondary read-only key. - SecondaryReadonlyMasterKey *string `json:"secondaryReadonlyMasterKey,omitempty"` -} - -// MarshalJSON is the custom marshaler for DatabaseAccountListReadOnlyKeysResult. -func (dalrokr DatabaseAccountListReadOnlyKeysResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// DatabaseAccountRegenerateKeyParameters parameters to regenerate the keys within the database account. -type DatabaseAccountRegenerateKeyParameters struct { - // KeyKind - The access key to regenerate. Possible values include: 'KeyKindPrimary', 'KeyKindSecondary', 'KeyKindPrimaryReadonly', 'KeyKindSecondaryReadonly' - KeyKind KeyKind `json:"keyKind,omitempty"` -} - -// DatabaseAccountsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type DatabaseAccountsCreateOrUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(DatabaseAccountsClient) (DatabaseAccountGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *DatabaseAccountsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for DatabaseAccountsCreateOrUpdateFuture.Result. -func (future *DatabaseAccountsCreateOrUpdateFuture) result(client DatabaseAccountsClient) (dagr DatabaseAccountGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - dagr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsCreateOrUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if dagr.Response.Response, err = future.GetResult(sender); err == nil && dagr.Response.Response.StatusCode != http.StatusNoContent { - dagr, err = client.CreateOrUpdateResponder(dagr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateOrUpdateFuture", "Result", dagr.Response.Response, "Failure responding to request") - } - } - return -} - -// DatabaseAccountsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type DatabaseAccountsDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(DatabaseAccountsClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *DatabaseAccountsDeleteFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for DatabaseAccountsDeleteFuture.Result. -func (future *DatabaseAccountsDeleteFuture) result(client DatabaseAccountsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsDeleteFuture") - return - } - ar.Response = future.Response() - return -} - -// DatabaseAccountsFailoverPriorityChangeFuture an abstraction for monitoring and retrieving the results of -// a long-running operation. -type DatabaseAccountsFailoverPriorityChangeFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(DatabaseAccountsClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *DatabaseAccountsFailoverPriorityChangeFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for DatabaseAccountsFailoverPriorityChangeFuture.Result. -func (future *DatabaseAccountsFailoverPriorityChangeFuture) result(client DatabaseAccountsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsFailoverPriorityChangeFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsFailoverPriorityChangeFuture") - return - } - ar.Response = future.Response() - return -} - -// DatabaseAccountsListResult the List operation response, that contains the database accounts and their -// properties. -type DatabaseAccountsListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of database account and their properties. - Value *[]DatabaseAccountGetResults `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for DatabaseAccountsListResult. -func (dalr DatabaseAccountsListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// DatabaseAccountsOfflineRegionFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type DatabaseAccountsOfflineRegionFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(DatabaseAccountsClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *DatabaseAccountsOfflineRegionFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for DatabaseAccountsOfflineRegionFuture.Result. -func (future *DatabaseAccountsOfflineRegionFuture) result(client DatabaseAccountsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsOfflineRegionFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsOfflineRegionFuture") - return - } - ar.Response = future.Response() - return -} - -// DatabaseAccountsOnlineRegionFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type DatabaseAccountsOnlineRegionFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(DatabaseAccountsClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *DatabaseAccountsOnlineRegionFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for DatabaseAccountsOnlineRegionFuture.Result. -func (future *DatabaseAccountsOnlineRegionFuture) result(client DatabaseAccountsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsOnlineRegionFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsOnlineRegionFuture") - return - } - ar.Response = future.Response() - return -} - -// DatabaseAccountsRegenerateKeyFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type DatabaseAccountsRegenerateKeyFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(DatabaseAccountsClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *DatabaseAccountsRegenerateKeyFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for DatabaseAccountsRegenerateKeyFuture.Result. -func (future *DatabaseAccountsRegenerateKeyFuture) result(client DatabaseAccountsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsRegenerateKeyFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsRegenerateKeyFuture") - return - } - ar.Response = future.Response() - return -} - -// DatabaseAccountsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type DatabaseAccountsUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(DatabaseAccountsClient) (DatabaseAccountGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *DatabaseAccountsUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for DatabaseAccountsUpdateFuture.Result. -func (future *DatabaseAccountsUpdateFuture) result(client DatabaseAccountsClient) (dagr DatabaseAccountGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - dagr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if dagr.Response.Response, err = future.GetResult(sender); err == nil && dagr.Response.Response.StatusCode != http.StatusNoContent { - dagr, err = client.UpdateResponder(dagr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateFuture", "Result", dagr.Response.Response, "Failure responding to request") - } - } - return -} - -// DatabaseAccountUpdateParameters parameters for patching Azure Cosmos DB database account properties. -type DatabaseAccountUpdateParameters struct { - Tags map[string]*string `json:"tags"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Identity *ManagedServiceIdentity `json:"identity,omitempty"` - *DatabaseAccountUpdateProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for DatabaseAccountUpdateParameters. -func (daup DatabaseAccountUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if daup.Tags != nil { - objectMap["tags"] = daup.Tags - } - if daup.Location != nil { - objectMap["location"] = daup.Location - } - if daup.Identity != nil { - objectMap["identity"] = daup.Identity - } - if daup.DatabaseAccountUpdateProperties != nil { - objectMap["properties"] = daup.DatabaseAccountUpdateProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for DatabaseAccountUpdateParameters struct. -func (daup *DatabaseAccountUpdateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - daup.Tags = tags - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - daup.Location = &location - } - case "identity": - if v != nil { - var identity ManagedServiceIdentity - err = json.Unmarshal(*v, &identity) - if err != nil { - return err - } - daup.Identity = &identity - } - case "properties": - if v != nil { - var databaseAccountUpdateProperties DatabaseAccountUpdateProperties - err = json.Unmarshal(*v, &databaseAccountUpdateProperties) - if err != nil { - return err - } - daup.DatabaseAccountUpdateProperties = &databaseAccountUpdateProperties - } - } - } - - return nil -} - -// DatabaseAccountUpdateProperties properties to update Azure Cosmos DB database accounts. -type DatabaseAccountUpdateProperties struct { - // ConsistencyPolicy - The consistency policy for the Cosmos DB account. - ConsistencyPolicy *ConsistencyPolicy `json:"consistencyPolicy,omitempty"` - // Locations - An array that contains the georeplication locations enabled for the Cosmos DB account. - Locations *[]Location `json:"locations,omitempty"` - // IPRules - List of IpRules. - IPRules *[]IPAddressOrRange `json:"ipRules,omitempty"` - // IsVirtualNetworkFilterEnabled - Flag to indicate whether to enable/disable Virtual Network ACL rules. - IsVirtualNetworkFilterEnabled *bool `json:"isVirtualNetworkFilterEnabled,omitempty"` - // EnableAutomaticFailover - Enables automatic failover of the write region in the rare event that the region is unavailable due to an outage. Automatic failover will result in a new write region for the account and is chosen based on the failover priorities configured for the account. - EnableAutomaticFailover *bool `json:"enableAutomaticFailover,omitempty"` - // Capabilities - List of Cosmos DB capabilities for the account - Capabilities *[]Capability `json:"capabilities,omitempty"` - // VirtualNetworkRules - List of Virtual Network ACL rules configured for the Cosmos DB account. - VirtualNetworkRules *[]VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` - // EnableMultipleWriteLocations - Enables the account to write in multiple locations - EnableMultipleWriteLocations *bool `json:"enableMultipleWriteLocations,omitempty"` - // EnableCassandraConnector - Enables the cassandra connector on the Cosmos DB C* account - EnableCassandraConnector *bool `json:"enableCassandraConnector,omitempty"` - // ConnectorOffer - The cassandra connector offer type for the Cosmos DB database C* account. Possible values include: 'ConnectorOfferSmall' - ConnectorOffer ConnectorOffer `json:"connectorOffer,omitempty"` - // DisableKeyBasedMetadataWriteAccess - Disable write operations on metadata resources (databases, containers, throughput) via account keys - DisableKeyBasedMetadataWriteAccess *bool `json:"disableKeyBasedMetadataWriteAccess,omitempty"` - // KeyVaultKeyURI - The URI of the key vault - KeyVaultKeyURI *string `json:"keyVaultKeyUri,omitempty"` - // DefaultIdentity - The default identity for accessing key vault used in features like customer managed keys. The default identity needs to be explicitly set by the users. It can be "FirstPartyIdentity", "SystemAssignedIdentity" and more. - DefaultIdentity *string `json:"defaultIdentity,omitempty"` - // PublicNetworkAccess - Whether requests from Public Network are allowed. Possible values include: 'PublicNetworkAccessEnabled', 'PublicNetworkAccessDisabled' - PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` - // EnableFreeTier - Flag to indicate whether Free Tier is enabled. - EnableFreeTier *bool `json:"enableFreeTier,omitempty"` - // APIProperties - API specific properties. Currently, supported only for MongoDB API. - APIProperties *APIProperties `json:"apiProperties,omitempty"` - // EnableAnalyticalStorage - Flag to indicate whether to enable storage analytics. - EnableAnalyticalStorage *bool `json:"enableAnalyticalStorage,omitempty"` - // AnalyticalStorageConfiguration - Analytical storage specific properties. - AnalyticalStorageConfiguration *AnalyticalStorageConfiguration `json:"analyticalStorageConfiguration,omitempty"` - // BackupPolicy - The object representing the policy for taking backups on an account. - BackupPolicy BasicBackupPolicy `json:"backupPolicy,omitempty"` - // Cors - The CORS policy for the Cosmos DB database account. - Cors *[]CorsPolicy `json:"cors,omitempty"` - // NetworkACLBypass - Indicates what services are allowed to bypass firewall checks. Possible values include: 'NetworkACLBypassNone', 'NetworkACLBypassAzureServices' - NetworkACLBypass NetworkACLBypass `json:"networkAclBypass,omitempty"` - // NetworkACLBypassResourceIds - An array that contains the Resource Ids for Network Acl Bypass for the Cosmos DB account. - NetworkACLBypassResourceIds *[]string `json:"networkAclBypassResourceIds,omitempty"` - // DisableLocalAuth - Opt-out of local authentication and ensure only MSI and AAD can be used exclusively for authentication. - DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` - // Capacity - The object that represents all properties related to capacity enforcement on an account. - Capacity *Capacity `json:"capacity,omitempty"` -} - -// UnmarshalJSON is the custom unmarshaler for DatabaseAccountUpdateProperties struct. -func (daup *DatabaseAccountUpdateProperties) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "consistencyPolicy": - if v != nil { - var consistencyPolicy ConsistencyPolicy - err = json.Unmarshal(*v, &consistencyPolicy) - if err != nil { - return err - } - daup.ConsistencyPolicy = &consistencyPolicy - } - case "locations": - if v != nil { - var locations []Location - err = json.Unmarshal(*v, &locations) - if err != nil { - return err - } - daup.Locations = &locations - } - case "ipRules": - if v != nil { - var IPRules []IPAddressOrRange - err = json.Unmarshal(*v, &IPRules) - if err != nil { - return err - } - daup.IPRules = &IPRules - } - case "isVirtualNetworkFilterEnabled": - if v != nil { - var isVirtualNetworkFilterEnabled bool - err = json.Unmarshal(*v, &isVirtualNetworkFilterEnabled) - if err != nil { - return err - } - daup.IsVirtualNetworkFilterEnabled = &isVirtualNetworkFilterEnabled - } - case "enableAutomaticFailover": - if v != nil { - var enableAutomaticFailover bool - err = json.Unmarshal(*v, &enableAutomaticFailover) - if err != nil { - return err - } - daup.EnableAutomaticFailover = &enableAutomaticFailover - } - case "capabilities": - if v != nil { - var capabilities []Capability - err = json.Unmarshal(*v, &capabilities) - if err != nil { - return err - } - daup.Capabilities = &capabilities - } - case "virtualNetworkRules": - if v != nil { - var virtualNetworkRules []VirtualNetworkRule - err = json.Unmarshal(*v, &virtualNetworkRules) - if err != nil { - return err - } - daup.VirtualNetworkRules = &virtualNetworkRules - } - case "enableMultipleWriteLocations": - if v != nil { - var enableMultipleWriteLocations bool - err = json.Unmarshal(*v, &enableMultipleWriteLocations) - if err != nil { - return err - } - daup.EnableMultipleWriteLocations = &enableMultipleWriteLocations - } - case "enableCassandraConnector": - if v != nil { - var enableCassandraConnector bool - err = json.Unmarshal(*v, &enableCassandraConnector) - if err != nil { - return err - } - daup.EnableCassandraConnector = &enableCassandraConnector - } - case "connectorOffer": - if v != nil { - var connectorOffer ConnectorOffer - err = json.Unmarshal(*v, &connectorOffer) - if err != nil { - return err - } - daup.ConnectorOffer = connectorOffer - } - case "disableKeyBasedMetadataWriteAccess": - if v != nil { - var disableKeyBasedMetadataWriteAccess bool - err = json.Unmarshal(*v, &disableKeyBasedMetadataWriteAccess) - if err != nil { - return err - } - daup.DisableKeyBasedMetadataWriteAccess = &disableKeyBasedMetadataWriteAccess - } - case "keyVaultKeyUri": - if v != nil { - var keyVaultKeyURI string - err = json.Unmarshal(*v, &keyVaultKeyURI) - if err != nil { - return err - } - daup.KeyVaultKeyURI = &keyVaultKeyURI - } - case "defaultIdentity": - if v != nil { - var defaultIdentity string - err = json.Unmarshal(*v, &defaultIdentity) - if err != nil { - return err - } - daup.DefaultIdentity = &defaultIdentity - } - case "publicNetworkAccess": - if v != nil { - var publicNetworkAccess PublicNetworkAccess - err = json.Unmarshal(*v, &publicNetworkAccess) - if err != nil { - return err - } - daup.PublicNetworkAccess = publicNetworkAccess - } - case "enableFreeTier": - if v != nil { - var enableFreeTier bool - err = json.Unmarshal(*v, &enableFreeTier) - if err != nil { - return err - } - daup.EnableFreeTier = &enableFreeTier - } - case "apiProperties": - if v != nil { - var APIProperties APIProperties - err = json.Unmarshal(*v, &APIProperties) - if err != nil { - return err - } - daup.APIProperties = &APIProperties - } - case "enableAnalyticalStorage": - if v != nil { - var enableAnalyticalStorage bool - err = json.Unmarshal(*v, &enableAnalyticalStorage) - if err != nil { - return err - } - daup.EnableAnalyticalStorage = &enableAnalyticalStorage - } - case "analyticalStorageConfiguration": - if v != nil { - var analyticalStorageConfiguration AnalyticalStorageConfiguration - err = json.Unmarshal(*v, &analyticalStorageConfiguration) - if err != nil { - return err - } - daup.AnalyticalStorageConfiguration = &analyticalStorageConfiguration - } - case "backupPolicy": - if v != nil { - backupPolicy, err := unmarshalBasicBackupPolicy(*v) - if err != nil { - return err - } - daup.BackupPolicy = backupPolicy - } - case "cors": - if v != nil { - var cors []CorsPolicy - err = json.Unmarshal(*v, &cors) - if err != nil { - return err - } - daup.Cors = &cors - } - case "networkAclBypass": - if v != nil { - var networkACLBypass NetworkACLBypass - err = json.Unmarshal(*v, &networkACLBypass) - if err != nil { - return err - } - daup.NetworkACLBypass = networkACLBypass - } - case "networkAclBypassResourceIds": - if v != nil { - var networkACLBypassResourceIds []string - err = json.Unmarshal(*v, &networkACLBypassResourceIds) - if err != nil { - return err - } - daup.NetworkACLBypassResourceIds = &networkACLBypassResourceIds - } - case "disableLocalAuth": - if v != nil { - var disableLocalAuth bool - err = json.Unmarshal(*v, &disableLocalAuth) - if err != nil { - return err - } - daup.DisableLocalAuth = &disableLocalAuth - } - case "capacity": - if v != nil { - var capacity Capacity - err = json.Unmarshal(*v, &capacity) - if err != nil { - return err - } - daup.Capacity = &capacity - } - } - } - - return nil -} - -// DatabaseRestoreResource specific Databases to restore. -type DatabaseRestoreResource struct { - // DatabaseName - The name of the database available for restore. - DatabaseName *string `json:"databaseName,omitempty"` - // CollectionNames - The names of the collections available for restore. - CollectionNames *[]string `json:"collectionNames,omitempty"` -} - -// DataCenterResource a managed Cassandra data center. -type DataCenterResource struct { - autorest.Response `json:"-"` - // Properties - Properties of a managed Cassandra data center. - Properties *DataCenterResourceProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the database account. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the database account. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for DataCenterResource. -func (dcr DataCenterResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if dcr.Properties != nil { - objectMap["properties"] = dcr.Properties - } - return json.Marshal(objectMap) -} - -// DataCenterResourceProperties properties of a managed Cassandra data center. -type DataCenterResourceProperties struct { - // ProvisioningState - Possible values include: 'ManagedCassandraProvisioningStateCreating', 'ManagedCassandraProvisioningStateUpdating', 'ManagedCassandraProvisioningStateDeleting', 'ManagedCassandraProvisioningStateSucceeded', 'ManagedCassandraProvisioningStateFailed', 'ManagedCassandraProvisioningStateCanceled' - ProvisioningState ManagedCassandraProvisioningState `json:"provisioningState,omitempty"` - // DataCenterLocation - The region this data center should be created in. - DataCenterLocation *string `json:"dataCenterLocation,omitempty"` - // DelegatedSubnetID - Resource id of a subnet the nodes in this data center should have their network interfaces connected to. The subnet must be in the same region specified in 'dataCenterLocation' and must be able to route to the subnet specified in the cluster's 'delegatedManagementSubnetId' property. This resource id will be of the form '/subscriptions//resourceGroups//providers/Microsoft.Network/virtualNetworks//subnets/'. - DelegatedSubnetID *string `json:"delegatedSubnetId,omitempty"` - // NodeCount - The number of nodes the data center should have. This is the desired number. After it is set, it may take some time for the data center to be scaled to match. To monitor the number of nodes and their status, use the fetchNodeStatus method on the cluster. - NodeCount *int32 `json:"nodeCount,omitempty"` - // SeedNodes - READ-ONLY; IP addresses for seed nodes in this data center. This is for reference. Generally you will want to use the seedNodes property on the cluster, which aggregates the seed nodes from all data centers in the cluster. - SeedNodes *[]SeedNode `json:"seedNodes,omitempty"` - // Base64EncodedCassandraYamlFragment - A fragment of a cassandra.yaml configuration file to be included in the cassandra.yaml for all nodes in this data center. The fragment should be Base64 encoded, and only a subset of keys are allowed. - Base64EncodedCassandraYamlFragment *string `json:"base64EncodedCassandraYamlFragment,omitempty"` - // ManagedDiskCustomerKeyURI - Key uri to use for encryption of managed disks. Ensure the system assigned identity of the cluster has been assigned appropriate permissions(key get/wrap/unwrap permissions) on the key. - ManagedDiskCustomerKeyURI *string `json:"managedDiskCustomerKeyUri,omitempty"` - // BackupStorageCustomerKeyURI - Indicates the Key Uri of the customer key to use for encryption of the backup storage account. - BackupStorageCustomerKeyURI *string `json:"backupStorageCustomerKeyUri,omitempty"` - // Sku - Virtual Machine SKU used for data centers. Default value is Standard_DS14_v2 - Sku *string `json:"sku,omitempty"` - // DiskSku - Disk SKU used for data centers. Default value is P30. - DiskSku *string `json:"diskSku,omitempty"` - // DiskCapacity - Number of disk used for data centers. Default value is 4. - DiskCapacity *int32 `json:"diskCapacity,omitempty"` - // AvailabilityZone - If the azure data center has Availability Zone support, apply it to the Virtual Machine ScaleSet that host the cassandra data center virtual machines. - AvailabilityZone *bool `json:"availabilityZone,omitempty"` -} - -// MarshalJSON is the custom marshaler for DataCenterResourceProperties. -func (dcr DataCenterResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if dcr.ProvisioningState != "" { - objectMap["provisioningState"] = dcr.ProvisioningState - } - if dcr.DataCenterLocation != nil { - objectMap["dataCenterLocation"] = dcr.DataCenterLocation - } - if dcr.DelegatedSubnetID != nil { - objectMap["delegatedSubnetId"] = dcr.DelegatedSubnetID - } - if dcr.NodeCount != nil { - objectMap["nodeCount"] = dcr.NodeCount - } - if dcr.Base64EncodedCassandraYamlFragment != nil { - objectMap["base64EncodedCassandraYamlFragment"] = dcr.Base64EncodedCassandraYamlFragment - } - if dcr.ManagedDiskCustomerKeyURI != nil { - objectMap["managedDiskCustomerKeyUri"] = dcr.ManagedDiskCustomerKeyURI - } - if dcr.BackupStorageCustomerKeyURI != nil { - objectMap["backupStorageCustomerKeyUri"] = dcr.BackupStorageCustomerKeyURI - } - if dcr.Sku != nil { - objectMap["sku"] = dcr.Sku - } - if dcr.DiskSku != nil { - objectMap["diskSku"] = dcr.DiskSku - } - if dcr.DiskCapacity != nil { - objectMap["diskCapacity"] = dcr.DiskCapacity - } - if dcr.AvailabilityZone != nil { - objectMap["availabilityZone"] = dcr.AvailabilityZone - } - return json.Marshal(objectMap) -} - -// ErrorResponse error Response. -type ErrorResponse struct { - // Code - Error code. - Code *string `json:"code,omitempty"` - // Message - Error message indicating why the operation failed. - Message *string `json:"message,omitempty"` -} - -// ExcludedPath ... -type ExcludedPath struct { - // Path - The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) - Path *string `json:"path,omitempty"` -} - -// ExtendedResourceProperties the system generated resource properties associated with SQL databases, SQL -// containers, Gremlin databases and Gremlin graphs. -type ExtendedResourceProperties struct { - // Rid - READ-ONLY; A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. - Ts *float64 `json:"_ts,omitempty"` - // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. - Etag *string `json:"_etag,omitempty"` -} - -// MarshalJSON is the custom marshaler for ExtendedResourceProperties. -func (erp ExtendedResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// FailoverPolicies the list of new failover policies for the failover priority change. -type FailoverPolicies struct { - // FailoverPolicies - List of failover policies. - FailoverPolicies *[]FailoverPolicy `json:"failoverPolicies,omitempty"` -} - -// FailoverPolicy the failover policy for a given region of a database account. -type FailoverPolicy struct { - // ID - READ-ONLY; The unique identifier of the region in which the database account replicates to. Example: <accountName>-<locationName>. - ID *string `json:"id,omitempty"` - // LocationName - The name of the region in which the database account exists. - LocationName *string `json:"locationName,omitempty"` - // FailoverPriority - The failover priority of the region. A failover priority of 0 indicates a write region. The maximum value for a failover priority = (total number of regions - 1). Failover priority values must be unique for each of the regions in which the database account exists. - FailoverPriority *int32 `json:"failoverPriority,omitempty"` -} - -// MarshalJSON is the custom marshaler for FailoverPolicy. -func (fp FailoverPolicy) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if fp.LocationName != nil { - objectMap["locationName"] = fp.LocationName - } - if fp.FailoverPriority != nil { - objectMap["failoverPriority"] = fp.FailoverPriority - } - return json.Marshal(objectMap) -} - -// GremlinDatabaseCreateUpdateParameters parameters to create and update Cosmos DB Gremlin database. -type GremlinDatabaseCreateUpdateParameters struct { - // GremlinDatabaseCreateUpdateProperties - Properties to create and update Azure Cosmos DB Gremlin database. - *GremlinDatabaseCreateUpdateProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for GremlinDatabaseCreateUpdateParameters. -func (gdcup GremlinDatabaseCreateUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if gdcup.GremlinDatabaseCreateUpdateProperties != nil { - objectMap["properties"] = gdcup.GremlinDatabaseCreateUpdateProperties - } - if gdcup.Location != nil { - objectMap["location"] = gdcup.Location - } - if gdcup.Tags != nil { - objectMap["tags"] = gdcup.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for GremlinDatabaseCreateUpdateParameters struct. -func (gdcup *GremlinDatabaseCreateUpdateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var gremlinDatabaseCreateUpdateProperties GremlinDatabaseCreateUpdateProperties - err = json.Unmarshal(*v, &gremlinDatabaseCreateUpdateProperties) - if err != nil { - return err - } - gdcup.GremlinDatabaseCreateUpdateProperties = &gremlinDatabaseCreateUpdateProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - gdcup.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - gdcup.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - gdcup.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - gdcup.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - gdcup.Tags = tags - } - } - } - - return nil -} - -// GremlinDatabaseCreateUpdateProperties properties to create and update Azure Cosmos DB Gremlin database. -type GremlinDatabaseCreateUpdateProperties struct { - // Resource - The standard JSON format of a Gremlin database - Resource *GremlinDatabaseResource `json:"resource,omitempty"` - // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - Options *CreateUpdateOptions `json:"options,omitempty"` -} - -// GremlinDatabaseGetProperties the properties of an Azure Cosmos DB SQL database -type GremlinDatabaseGetProperties struct { - Resource *GremlinDatabaseGetPropertiesResource `json:"resource,omitempty"` - Options *GremlinDatabaseGetPropertiesOptions `json:"options,omitempty"` -} - -// GremlinDatabaseGetPropertiesOptions ... -type GremlinDatabaseGetPropertiesOptions struct { - // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. - Throughput *int32 `json:"throughput,omitempty"` - // AutoscaleSettings - Specifies the Autoscale settings. - AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` -} - -// GremlinDatabaseGetPropertiesResource ... -type GremlinDatabaseGetPropertiesResource struct { - // ID - Name of the Cosmos DB Gremlin database - ID *string `json:"id,omitempty"` - // Rid - READ-ONLY; A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. - Ts *float64 `json:"_ts,omitempty"` - // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. - Etag *string `json:"_etag,omitempty"` -} - -// MarshalJSON is the custom marshaler for GremlinDatabaseGetPropertiesResource. -func (gdgp GremlinDatabaseGetPropertiesResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if gdgp.ID != nil { - objectMap["id"] = gdgp.ID - } - return json.Marshal(objectMap) -} - -// GremlinDatabaseGetResults an Azure Cosmos DB Gremlin database. -type GremlinDatabaseGetResults struct { - autorest.Response `json:"-"` - // GremlinDatabaseGetProperties - The properties of an Azure Cosmos DB SQL database - *GremlinDatabaseGetProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for GremlinDatabaseGetResults. -func (gdgr GremlinDatabaseGetResults) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if gdgr.GremlinDatabaseGetProperties != nil { - objectMap["properties"] = gdgr.GremlinDatabaseGetProperties - } - if gdgr.Location != nil { - objectMap["location"] = gdgr.Location - } - if gdgr.Tags != nil { - objectMap["tags"] = gdgr.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for GremlinDatabaseGetResults struct. -func (gdgr *GremlinDatabaseGetResults) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var gremlinDatabaseGetProperties GremlinDatabaseGetProperties - err = json.Unmarshal(*v, &gremlinDatabaseGetProperties) - if err != nil { - return err - } - gdgr.GremlinDatabaseGetProperties = &gremlinDatabaseGetProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - gdgr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - gdgr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - gdgr.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - gdgr.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - gdgr.Tags = tags - } - } - } - - return nil -} - -// GremlinDatabaseListResult the List operation response, that contains the Gremlin databases and their -// properties. -type GremlinDatabaseListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of Gremlin databases and their properties. - Value *[]GremlinDatabaseGetResults `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for GremlinDatabaseListResult. -func (gdlr GremlinDatabaseListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// GremlinDatabaseResource cosmos DB Gremlin database resource object -type GremlinDatabaseResource struct { - // ID - Name of the Cosmos DB Gremlin database - ID *string `json:"id,omitempty"` -} - -// GremlinGraphCreateUpdateParameters parameters to create and update Cosmos DB Gremlin graph. -type GremlinGraphCreateUpdateParameters struct { - // GremlinGraphCreateUpdateProperties - Properties to create and update Azure Cosmos DB Gremlin graph. - *GremlinGraphCreateUpdateProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for GremlinGraphCreateUpdateParameters. -func (ggcup GremlinGraphCreateUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ggcup.GremlinGraphCreateUpdateProperties != nil { - objectMap["properties"] = ggcup.GremlinGraphCreateUpdateProperties - } - if ggcup.Location != nil { - objectMap["location"] = ggcup.Location - } - if ggcup.Tags != nil { - objectMap["tags"] = ggcup.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for GremlinGraphCreateUpdateParameters struct. -func (ggcup *GremlinGraphCreateUpdateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var gremlinGraphCreateUpdateProperties GremlinGraphCreateUpdateProperties - err = json.Unmarshal(*v, &gremlinGraphCreateUpdateProperties) - if err != nil { - return err - } - ggcup.GremlinGraphCreateUpdateProperties = &gremlinGraphCreateUpdateProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - ggcup.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - ggcup.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - ggcup.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - ggcup.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - ggcup.Tags = tags - } - } - } - - return nil -} - -// GremlinGraphCreateUpdateProperties properties to create and update Azure Cosmos DB Gremlin graph. -type GremlinGraphCreateUpdateProperties struct { - // Resource - The standard JSON format of a Gremlin graph - Resource *GremlinGraphResource `json:"resource,omitempty"` - // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - Options *CreateUpdateOptions `json:"options,omitempty"` -} - -// GremlinGraphGetProperties the properties of an Azure Cosmos DB Gremlin graph -type GremlinGraphGetProperties struct { - Resource *GremlinGraphGetPropertiesResource `json:"resource,omitempty"` - Options *GremlinGraphGetPropertiesOptions `json:"options,omitempty"` -} - -// GremlinGraphGetPropertiesOptions ... -type GremlinGraphGetPropertiesOptions struct { - // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. - Throughput *int32 `json:"throughput,omitempty"` - // AutoscaleSettings - Specifies the Autoscale settings. - AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` -} - -// GremlinGraphGetPropertiesResource ... -type GremlinGraphGetPropertiesResource struct { - // ID - Name of the Cosmos DB Gremlin graph - ID *string `json:"id,omitempty"` - // IndexingPolicy - The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the graph - IndexingPolicy *IndexingPolicy `json:"indexingPolicy,omitempty"` - // PartitionKey - The configuration of the partition key to be used for partitioning data into multiple partitions - PartitionKey *ContainerPartitionKey `json:"partitionKey,omitempty"` - // DefaultTTL - Default time to live - DefaultTTL *int32 `json:"defaultTtl,omitempty"` - // UniqueKeyPolicy - The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. - UniqueKeyPolicy *UniqueKeyPolicy `json:"uniqueKeyPolicy,omitempty"` - // ConflictResolutionPolicy - The conflict resolution policy for the graph. - ConflictResolutionPolicy *ConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"` - // Rid - READ-ONLY; A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. - Ts *float64 `json:"_ts,omitempty"` - // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. - Etag *string `json:"_etag,omitempty"` -} - -// MarshalJSON is the custom marshaler for GremlinGraphGetPropertiesResource. -func (gggp GremlinGraphGetPropertiesResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if gggp.ID != nil { - objectMap["id"] = gggp.ID - } - if gggp.IndexingPolicy != nil { - objectMap["indexingPolicy"] = gggp.IndexingPolicy - } - if gggp.PartitionKey != nil { - objectMap["partitionKey"] = gggp.PartitionKey - } - if gggp.DefaultTTL != nil { - objectMap["defaultTtl"] = gggp.DefaultTTL - } - if gggp.UniqueKeyPolicy != nil { - objectMap["uniqueKeyPolicy"] = gggp.UniqueKeyPolicy - } - if gggp.ConflictResolutionPolicy != nil { - objectMap["conflictResolutionPolicy"] = gggp.ConflictResolutionPolicy - } - return json.Marshal(objectMap) -} - -// GremlinGraphGetResults an Azure Cosmos DB Gremlin graph. -type GremlinGraphGetResults struct { - autorest.Response `json:"-"` - // GremlinGraphGetProperties - The properties of an Azure Cosmos DB Gremlin graph - *GremlinGraphGetProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for GremlinGraphGetResults. -func (gggr GremlinGraphGetResults) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if gggr.GremlinGraphGetProperties != nil { - objectMap["properties"] = gggr.GremlinGraphGetProperties - } - if gggr.Location != nil { - objectMap["location"] = gggr.Location - } - if gggr.Tags != nil { - objectMap["tags"] = gggr.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for GremlinGraphGetResults struct. -func (gggr *GremlinGraphGetResults) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var gremlinGraphGetProperties GremlinGraphGetProperties - err = json.Unmarshal(*v, &gremlinGraphGetProperties) - if err != nil { - return err - } - gggr.GremlinGraphGetProperties = &gremlinGraphGetProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - gggr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - gggr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - gggr.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - gggr.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - gggr.Tags = tags - } - } - } - - return nil -} - -// GremlinGraphListResult the List operation response, that contains the graphs and their properties. -type GremlinGraphListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of graphs and their properties. - Value *[]GremlinGraphGetResults `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for GremlinGraphListResult. -func (gglr GremlinGraphListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// GremlinGraphResource cosmos DB Gremlin graph resource object -type GremlinGraphResource struct { - // ID - Name of the Cosmos DB Gremlin graph - ID *string `json:"id,omitempty"` - // IndexingPolicy - The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the graph - IndexingPolicy *IndexingPolicy `json:"indexingPolicy,omitempty"` - // PartitionKey - The configuration of the partition key to be used for partitioning data into multiple partitions - PartitionKey *ContainerPartitionKey `json:"partitionKey,omitempty"` - // DefaultTTL - Default time to live - DefaultTTL *int32 `json:"defaultTtl,omitempty"` - // UniqueKeyPolicy - The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. - UniqueKeyPolicy *UniqueKeyPolicy `json:"uniqueKeyPolicy,omitempty"` - // ConflictResolutionPolicy - The conflict resolution policy for the graph. - ConflictResolutionPolicy *ConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"` -} - -// GremlinResourcesCreateUpdateGremlinDatabaseFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type GremlinResourcesCreateUpdateGremlinDatabaseFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(GremlinResourcesClient) (GremlinDatabaseGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *GremlinResourcesCreateUpdateGremlinDatabaseFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for GremlinResourcesCreateUpdateGremlinDatabaseFuture.Result. -func (future *GremlinResourcesCreateUpdateGremlinDatabaseFuture) result(client GremlinResourcesClient) (gdgr GremlinDatabaseGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesCreateUpdateGremlinDatabaseFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - gdgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesCreateUpdateGremlinDatabaseFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if gdgr.Response.Response, err = future.GetResult(sender); err == nil && gdgr.Response.Response.StatusCode != http.StatusNoContent { - gdgr, err = client.CreateUpdateGremlinDatabaseResponder(gdgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesCreateUpdateGremlinDatabaseFuture", "Result", gdgr.Response.Response, "Failure responding to request") - } - } - return -} - -// GremlinResourcesCreateUpdateGremlinGraphFuture an abstraction for monitoring and retrieving the results -// of a long-running operation. -type GremlinResourcesCreateUpdateGremlinGraphFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(GremlinResourcesClient) (GremlinGraphGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *GremlinResourcesCreateUpdateGremlinGraphFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for GremlinResourcesCreateUpdateGremlinGraphFuture.Result. -func (future *GremlinResourcesCreateUpdateGremlinGraphFuture) result(client GremlinResourcesClient) (gggr GremlinGraphGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesCreateUpdateGremlinGraphFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - gggr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesCreateUpdateGremlinGraphFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if gggr.Response.Response, err = future.GetResult(sender); err == nil && gggr.Response.Response.StatusCode != http.StatusNoContent { - gggr, err = client.CreateUpdateGremlinGraphResponder(gggr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesCreateUpdateGremlinGraphFuture", "Result", gggr.Response.Response, "Failure responding to request") - } - } - return -} - -// GremlinResourcesDeleteGremlinDatabaseFuture an abstraction for monitoring and retrieving the results of -// a long-running operation. -type GremlinResourcesDeleteGremlinDatabaseFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(GremlinResourcesClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *GremlinResourcesDeleteGremlinDatabaseFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for GremlinResourcesDeleteGremlinDatabaseFuture.Result. -func (future *GremlinResourcesDeleteGremlinDatabaseFuture) result(client GremlinResourcesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesDeleteGremlinDatabaseFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesDeleteGremlinDatabaseFuture") - return - } - ar.Response = future.Response() - return -} - -// GremlinResourcesDeleteGremlinGraphFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type GremlinResourcesDeleteGremlinGraphFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(GremlinResourcesClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *GremlinResourcesDeleteGremlinGraphFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for GremlinResourcesDeleteGremlinGraphFuture.Result. -func (future *GremlinResourcesDeleteGremlinGraphFuture) result(client GremlinResourcesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesDeleteGremlinGraphFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesDeleteGremlinGraphFuture") - return - } - ar.Response = future.Response() - return -} - -// GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(GremlinResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture.Result. -func (future *GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture) result(client GremlinResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.MigrateGremlinDatabaseToAutoscaleResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinDatabaseToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture an abstraction for monitoring and -// retrieving the results of a long-running operation. -type GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(GremlinResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture.Result. -func (future *GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture) result(client GremlinResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.MigrateGremlinDatabaseToManualThroughputResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinDatabaseToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// GremlinResourcesMigrateGremlinGraphToAutoscaleFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type GremlinResourcesMigrateGremlinGraphToAutoscaleFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(GremlinResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *GremlinResourcesMigrateGremlinGraphToAutoscaleFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for GremlinResourcesMigrateGremlinGraphToAutoscaleFuture.Result. -func (future *GremlinResourcesMigrateGremlinGraphToAutoscaleFuture) result(client GremlinResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinGraphToAutoscaleFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesMigrateGremlinGraphToAutoscaleFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.MigrateGremlinGraphToAutoscaleResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinGraphToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// GremlinResourcesMigrateGremlinGraphToManualThroughputFuture an abstraction for monitoring and retrieving -// the results of a long-running operation. -type GremlinResourcesMigrateGremlinGraphToManualThroughputFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(GremlinResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *GremlinResourcesMigrateGremlinGraphToManualThroughputFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for GremlinResourcesMigrateGremlinGraphToManualThroughputFuture.Result. -func (future *GremlinResourcesMigrateGremlinGraphToManualThroughputFuture) result(client GremlinResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinGraphToManualThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesMigrateGremlinGraphToManualThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.MigrateGremlinGraphToManualThroughputResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesMigrateGremlinGraphToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// GremlinResourcesUpdateGremlinDatabaseThroughputFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type GremlinResourcesUpdateGremlinDatabaseThroughputFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(GremlinResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *GremlinResourcesUpdateGremlinDatabaseThroughputFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for GremlinResourcesUpdateGremlinDatabaseThroughputFuture.Result. -func (future *GremlinResourcesUpdateGremlinDatabaseThroughputFuture) result(client GremlinResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesUpdateGremlinDatabaseThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesUpdateGremlinDatabaseThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.UpdateGremlinDatabaseThroughputResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesUpdateGremlinDatabaseThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// GremlinResourcesUpdateGremlinGraphThroughputFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type GremlinResourcesUpdateGremlinGraphThroughputFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(GremlinResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *GremlinResourcesUpdateGremlinGraphThroughputFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for GremlinResourcesUpdateGremlinGraphThroughputFuture.Result. -func (future *GremlinResourcesUpdateGremlinGraphThroughputFuture) result(client GremlinResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesUpdateGremlinGraphThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesUpdateGremlinGraphThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.UpdateGremlinGraphThroughputResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.GremlinResourcesUpdateGremlinGraphThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// IncludedPath the paths that are included in indexing -type IncludedPath struct { - // Path - The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) - Path *string `json:"path,omitempty"` - // Indexes - List of indexes for this path - Indexes *[]Indexes `json:"indexes,omitempty"` -} - -// Indexes the indexes for the path. -type Indexes struct { - // DataType - The datatype for which the indexing behavior is applied to. Possible values include: 'DataTypeString', 'DataTypeNumber', 'DataTypePoint', 'DataTypePolygon', 'DataTypeLineString', 'DataTypeMultiPolygon' - DataType DataType `json:"dataType,omitempty"` - // Precision - The precision of the index. -1 is maximum precision. - Precision *int32 `json:"precision,omitempty"` - // Kind - Indicates the type of index. Possible values include: 'IndexKindHash', 'IndexKindRange', 'IndexKindSpatial' - Kind IndexKind `json:"kind,omitempty"` -} - -// IndexingPolicy cosmos DB indexing policy -type IndexingPolicy struct { - // Automatic - Indicates if the indexing policy is automatic - Automatic *bool `json:"automatic,omitempty"` - // IndexingMode - Indicates the indexing mode. Possible values include: 'IndexingModeConsistent', 'IndexingModeLazy', 'IndexingModeNone' - IndexingMode IndexingMode `json:"indexingMode,omitempty"` - // IncludedPaths - List of paths to include in the indexing - IncludedPaths *[]IncludedPath `json:"includedPaths,omitempty"` - // ExcludedPaths - List of paths to exclude from indexing - ExcludedPaths *[]ExcludedPath `json:"excludedPaths,omitempty"` - // CompositeIndexes - List of composite path list - CompositeIndexes *[][]CompositePath `json:"compositeIndexes,omitempty"` - // SpatialIndexes - List of spatial specifics - SpatialIndexes *[]SpatialSpec `json:"spatialIndexes,omitempty"` -} - -// IPAddressOrRange ipAddressOrRange object -type IPAddressOrRange struct { - // IPAddressOrRange - A single IPv4 address or a single IPv4 address range in CIDR format. Provided IPs must be well-formatted and cannot be contained in one of the following ranges: 10.0.0.0/8, 100.64.0.0/10, 172.16.0.0/12, 192.168.0.0/16, since these are not enforceable by the IP address filter. Example of valid inputs: “23.40.210.245” or “23.40.210.0/8”. - IPAddressOrRange *string `json:"ipAddressOrRange,omitempty"` -} - -// ListClusters list of managed Cassandra clusters. -type ListClusters struct { - autorest.Response `json:"-"` - // Value - Container for the array of clusters. - Value *[]ClusterResource `json:"value,omitempty"` -} - -// ListDataCenters list of managed Cassandra data centers and their properties. -type ListDataCenters struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; Container for array of data centers. - Value *[]DataCenterResource `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for ListDataCenters. -func (ldc ListDataCenters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// Location a region in which the Azure Cosmos DB database account is deployed. -type Location struct { - // ID - READ-ONLY; The unique identifier of the region within the database account. Example: <accountName>-<locationName>. - ID *string `json:"id,omitempty"` - // LocationName - The name of the region. - LocationName *string `json:"locationName,omitempty"` - // DocumentEndpoint - READ-ONLY; The connection endpoint for the specific region. Example: https://<accountName>-<locationName>.documents.azure.com:443/ - DocumentEndpoint *string `json:"documentEndpoint,omitempty"` - ProvisioningState *string `json:"provisioningState,omitempty"` - // FailoverPriority - The failover priority of the region. A failover priority of 0 indicates a write region. The maximum value for a failover priority = (total number of regions - 1). Failover priority values must be unique for each of the regions in which the database account exists. - FailoverPriority *int32 `json:"failoverPriority,omitempty"` - // IsZoneRedundant - Flag to indicate whether or not this region is an AvailabilityZone region - IsZoneRedundant *bool `json:"isZoneRedundant,omitempty"` -} - -// MarshalJSON is the custom marshaler for Location. -func (l Location) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if l.LocationName != nil { - objectMap["locationName"] = l.LocationName - } - if l.ProvisioningState != nil { - objectMap["provisioningState"] = l.ProvisioningState - } - if l.FailoverPriority != nil { - objectMap["failoverPriority"] = l.FailoverPriority - } - if l.IsZoneRedundant != nil { - objectMap["isZoneRedundant"] = l.IsZoneRedundant - } - return json.Marshal(objectMap) -} - -// LocationGetResult cosmos DB location get result -type LocationGetResult struct { - autorest.Response `json:"-"` - // Properties - Cosmos DB location metadata - Properties *LocationProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the database account. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the database account. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for LocationGetResult. -func (lgr LocationGetResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if lgr.Properties != nil { - objectMap["properties"] = lgr.Properties - } - return json.Marshal(objectMap) -} - -// LocationListResult the List operation response, that contains Cosmos DB locations and their properties. -type LocationListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of Cosmos DB locations and their properties. - Value *[]LocationGetResult `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for LocationListResult. -func (llr LocationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// LocationProperties cosmos DB location metadata -type LocationProperties struct { - // SupportsAvailabilityZone - READ-ONLY; Flag indicating whether the location supports availability zones or not. - SupportsAvailabilityZone *bool `json:"supportsAvailabilityZone,omitempty"` - // IsResidencyRestricted - READ-ONLY; Flag indicating whether the location is residency sensitive. - IsResidencyRestricted *bool `json:"isResidencyRestricted,omitempty"` - // BackupStorageRedundancies - READ-ONLY; The properties of available backup storage redundancies. - BackupStorageRedundancies *[]BackupStorageRedundancy `json:"backupStorageRedundancies,omitempty"` -} - -// MarshalJSON is the custom marshaler for LocationProperties. -func (lp LocationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// ManagedCassandraARMResourceProperties the core properties of ARM resources. -type ManagedCassandraARMResourceProperties struct { - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` - Identity *ManagedCassandraManagedServiceIdentity `json:"identity,omitempty"` -} - -// MarshalJSON is the custom marshaler for ManagedCassandraARMResourceProperties. -func (mcarp ManagedCassandraARMResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mcarp.Location != nil { - objectMap["location"] = mcarp.Location - } - if mcarp.Tags != nil { - objectMap["tags"] = mcarp.Tags - } - if mcarp.Identity != nil { - objectMap["identity"] = mcarp.Identity - } - return json.Marshal(objectMap) -} - -// ManagedCassandraManagedServiceIdentity identity for the resource. -type ManagedCassandraManagedServiceIdentity struct { - // PrincipalID - READ-ONLY; The object id of the identity resource. - PrincipalID *string `json:"principalId,omitempty"` - // TenantID - READ-ONLY; The tenant id of the resource. - TenantID *string `json:"tenantId,omitempty"` - // Type - The type of the resource. Possible values include: 'ManagedCassandraResourceIdentityTypeSystemAssigned', 'ManagedCassandraResourceIdentityTypeNone' - Type ManagedCassandraResourceIdentityType `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for ManagedCassandraManagedServiceIdentity. -func (mcmsi ManagedCassandraManagedServiceIdentity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mcmsi.Type != "" { - objectMap["type"] = mcmsi.Type - } - return json.Marshal(objectMap) -} - -// ManagedCassandraReaperStatus ... -type ManagedCassandraReaperStatus struct { - Healthy *bool `json:"healthy,omitempty"` - RepairRunIds map[string]*string `json:"repairRunIds"` - RepairSchedules map[string]*string `json:"repairSchedules"` -} - -// MarshalJSON is the custom marshaler for ManagedCassandraReaperStatus. -func (mcrs ManagedCassandraReaperStatus) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mcrs.Healthy != nil { - objectMap["healthy"] = mcrs.Healthy - } - if mcrs.RepairRunIds != nil { - objectMap["repairRunIds"] = mcrs.RepairRunIds - } - if mcrs.RepairSchedules != nil { - objectMap["repairSchedules"] = mcrs.RepairSchedules - } - return json.Marshal(objectMap) -} - -// ManagedServiceIdentity identity for the resource. -type ManagedServiceIdentity struct { - // PrincipalID - READ-ONLY; The principal id of the system assigned identity. This property will only be provided for a system assigned identity. - PrincipalID *string `json:"principalId,omitempty"` - // TenantID - READ-ONLY; The tenant id of the system assigned identity. This property will only be provided for a system assigned identity. - TenantID *string `json:"tenantId,omitempty"` - // Type - The type of identity used for the resource. The type 'SystemAssigned,UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the service. Possible values include: 'ResourceIdentityTypeSystemAssigned', 'ResourceIdentityTypeUserAssigned', 'ResourceIdentityTypeSystemAssignedUserAssigned', 'ResourceIdentityTypeNone' - Type ResourceIdentityType `json:"type,omitempty"` - // UserAssignedIdentities - The list of user identities associated with resource. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - UserAssignedIdentities map[string]*ManagedServiceIdentityUserAssignedIdentitiesValue `json:"userAssignedIdentities"` -} - -// MarshalJSON is the custom marshaler for ManagedServiceIdentity. -func (msi ManagedServiceIdentity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if msi.Type != "" { - objectMap["type"] = msi.Type - } - if msi.UserAssignedIdentities != nil { - objectMap["userAssignedIdentities"] = msi.UserAssignedIdentities - } - return json.Marshal(objectMap) -} - -// ManagedServiceIdentityUserAssignedIdentitiesValue ... -type ManagedServiceIdentityUserAssignedIdentitiesValue struct { - // PrincipalID - READ-ONLY; The principal id of user assigned identity. - PrincipalID *string `json:"principalId,omitempty"` - // ClientID - READ-ONLY; The client id of user assigned identity. - ClientID *string `json:"clientId,omitempty"` -} - -// MarshalJSON is the custom marshaler for ManagedServiceIdentityUserAssignedIdentitiesValue. -func (msiAiv ManagedServiceIdentityUserAssignedIdentitiesValue) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// Metric metric data -type Metric struct { - // StartTime - READ-ONLY; The start time for the metric (ISO-8601 format). - StartTime *date.Time `json:"startTime,omitempty"` - // EndTime - READ-ONLY; The end time for the metric (ISO-8601 format). - EndTime *date.Time `json:"endTime,omitempty"` - // TimeGrain - READ-ONLY; The time grain to be used to summarize the metric values. - TimeGrain *string `json:"timeGrain,omitempty"` - // Unit - The unit of the metric. Possible values include: 'UnitTypeCount', 'UnitTypeBytes', 'UnitTypeSeconds', 'UnitTypePercent', 'UnitTypeCountPerSecond', 'UnitTypeBytesPerSecond', 'UnitTypeMilliseconds' - Unit UnitType `json:"unit,omitempty"` - // Name - READ-ONLY; The name information for the metric. - Name *MetricName `json:"name,omitempty"` - // MetricValues - READ-ONLY; The metric values for the specified time window and timestep. - MetricValues *[]MetricValue `json:"metricValues,omitempty"` -} - -// MarshalJSON is the custom marshaler for Metric. -func (mVar Metric) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mVar.Unit != "" { - objectMap["unit"] = mVar.Unit - } - return json.Marshal(objectMap) -} - -// MetricAvailability the availability of the metric. -type MetricAvailability struct { - // TimeGrain - READ-ONLY; The time grain to be used to summarize the metric values. - TimeGrain *string `json:"timeGrain,omitempty"` - // Retention - READ-ONLY; The retention for the metric values. - Retention *string `json:"retention,omitempty"` -} - -// MarshalJSON is the custom marshaler for MetricAvailability. -func (ma MetricAvailability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// MetricDefinition the definition of a metric. -type MetricDefinition struct { - // MetricAvailabilities - READ-ONLY; The list of metric availabilities for the account. - MetricAvailabilities *[]MetricAvailability `json:"metricAvailabilities,omitempty"` - // PrimaryAggregationType - READ-ONLY; The primary aggregation type of the metric. Possible values include: 'PrimaryAggregationTypeNone', 'PrimaryAggregationTypeAverage', 'PrimaryAggregationTypeTotal', 'PrimaryAggregationTypeMinimum', 'PrimaryAggregationTypeMaximum', 'PrimaryAggregationTypeLast' - PrimaryAggregationType PrimaryAggregationType `json:"primaryAggregationType,omitempty"` - // Unit - The unit of the metric. Possible values include: 'UnitTypeCount', 'UnitTypeBytes', 'UnitTypeSeconds', 'UnitTypePercent', 'UnitTypeCountPerSecond', 'UnitTypeBytesPerSecond', 'UnitTypeMilliseconds' - Unit UnitType `json:"unit,omitempty"` - // ResourceURI - READ-ONLY; The resource uri of the database. - ResourceURI *string `json:"resourceUri,omitempty"` - // Name - READ-ONLY; The name information for the metric. - Name *MetricName `json:"name,omitempty"` -} - -// MarshalJSON is the custom marshaler for MetricDefinition. -func (md MetricDefinition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if md.Unit != "" { - objectMap["unit"] = md.Unit - } - return json.Marshal(objectMap) -} - -// MetricDefinitionsListResult the response to a list metric definitions request. -type MetricDefinitionsListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; The list of metric definitions for the account. - Value *[]MetricDefinition `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for MetricDefinitionsListResult. -func (mdlr MetricDefinitionsListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// MetricListResult the response to a list metrics request. -type MetricListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; The list of metrics for the account. - Value *[]Metric `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for MetricListResult. -func (mlr MetricListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// MetricName a metric name. -type MetricName struct { - // Value - READ-ONLY; The name of the metric. - Value *string `json:"value,omitempty"` - // LocalizedValue - READ-ONLY; The friendly name of the metric. - LocalizedValue *string `json:"localizedValue,omitempty"` -} - -// MarshalJSON is the custom marshaler for MetricName. -func (mn MetricName) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// MetricValue represents metrics values. -type MetricValue struct { - // Count - READ-ONLY; The number of values for the metric. - Count *float64 `json:"_count,omitempty"` - // Average - READ-ONLY; The average value of the metric. - Average *float64 `json:"average,omitempty"` - // Maximum - READ-ONLY; The max value of the metric. - Maximum *float64 `json:"maximum,omitempty"` - // Minimum - READ-ONLY; The min value of the metric. - Minimum *float64 `json:"minimum,omitempty"` - // Timestamp - READ-ONLY; The metric timestamp (ISO-8601 format). - Timestamp *date.Time `json:"timestamp,omitempty"` - // Total - READ-ONLY; The total value of the metric. - Total *float64 `json:"total,omitempty"` -} - -// MarshalJSON is the custom marshaler for MetricValue. -func (mv MetricValue) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// MongoDBCollectionCreateUpdateParameters parameters to create and update Cosmos DB MongoDB collection. -type MongoDBCollectionCreateUpdateParameters struct { - // MongoDBCollectionCreateUpdateProperties - Properties to create and update Azure Cosmos DB MongoDB collection. - *MongoDBCollectionCreateUpdateProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for MongoDBCollectionCreateUpdateParameters. -func (mdccup MongoDBCollectionCreateUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mdccup.MongoDBCollectionCreateUpdateProperties != nil { - objectMap["properties"] = mdccup.MongoDBCollectionCreateUpdateProperties - } - if mdccup.Location != nil { - objectMap["location"] = mdccup.Location - } - if mdccup.Tags != nil { - objectMap["tags"] = mdccup.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for MongoDBCollectionCreateUpdateParameters struct. -func (mdccup *MongoDBCollectionCreateUpdateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var mongoDBCollectionCreateUpdateProperties MongoDBCollectionCreateUpdateProperties - err = json.Unmarshal(*v, &mongoDBCollectionCreateUpdateProperties) - if err != nil { - return err - } - mdccup.MongoDBCollectionCreateUpdateProperties = &mongoDBCollectionCreateUpdateProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - mdccup.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - mdccup.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - mdccup.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - mdccup.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - mdccup.Tags = tags - } - } - } - - return nil -} - -// MongoDBCollectionCreateUpdateProperties properties to create and update Azure Cosmos DB MongoDB -// collection. -type MongoDBCollectionCreateUpdateProperties struct { - // Resource - The standard JSON format of a MongoDB collection - Resource *MongoDBCollectionResource `json:"resource,omitempty"` - // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - Options *CreateUpdateOptions `json:"options,omitempty"` -} - -// MongoDBCollectionGetProperties the properties of an Azure Cosmos DB MongoDB collection -type MongoDBCollectionGetProperties struct { - Resource *MongoDBCollectionGetPropertiesResource `json:"resource,omitempty"` - Options *MongoDBCollectionGetPropertiesOptions `json:"options,omitempty"` -} - -// MongoDBCollectionGetPropertiesOptions ... -type MongoDBCollectionGetPropertiesOptions struct { - // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. - Throughput *int32 `json:"throughput,omitempty"` - // AutoscaleSettings - Specifies the Autoscale settings. - AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` -} - -// MongoDBCollectionGetPropertiesResource ... -type MongoDBCollectionGetPropertiesResource struct { - // ID - Name of the Cosmos DB MongoDB collection - ID *string `json:"id,omitempty"` - // ShardKey - A key-value pair of shard keys to be applied for the request. - ShardKey map[string]*string `json:"shardKey"` - // Indexes - List of index keys - Indexes *[]MongoIndex `json:"indexes,omitempty"` - // AnalyticalStorageTTL - Analytical TTL. - AnalyticalStorageTTL *int32 `json:"analyticalStorageTtl,omitempty"` - // Rid - READ-ONLY; A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. - Ts *float64 `json:"_ts,omitempty"` - // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. - Etag *string `json:"_etag,omitempty"` -} - -// MarshalJSON is the custom marshaler for MongoDBCollectionGetPropertiesResource. -func (mdcgp MongoDBCollectionGetPropertiesResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mdcgp.ID != nil { - objectMap["id"] = mdcgp.ID - } - if mdcgp.ShardKey != nil { - objectMap["shardKey"] = mdcgp.ShardKey - } - if mdcgp.Indexes != nil { - objectMap["indexes"] = mdcgp.Indexes - } - if mdcgp.AnalyticalStorageTTL != nil { - objectMap["analyticalStorageTtl"] = mdcgp.AnalyticalStorageTTL - } - return json.Marshal(objectMap) -} - -// MongoDBCollectionGetResults an Azure Cosmos DB MongoDB collection. -type MongoDBCollectionGetResults struct { - autorest.Response `json:"-"` - // MongoDBCollectionGetProperties - The properties of an Azure Cosmos DB MongoDB collection - *MongoDBCollectionGetProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for MongoDBCollectionGetResults. -func (mdcgr MongoDBCollectionGetResults) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mdcgr.MongoDBCollectionGetProperties != nil { - objectMap["properties"] = mdcgr.MongoDBCollectionGetProperties - } - if mdcgr.Location != nil { - objectMap["location"] = mdcgr.Location - } - if mdcgr.Tags != nil { - objectMap["tags"] = mdcgr.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for MongoDBCollectionGetResults struct. -func (mdcgr *MongoDBCollectionGetResults) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var mongoDBCollectionGetProperties MongoDBCollectionGetProperties - err = json.Unmarshal(*v, &mongoDBCollectionGetProperties) - if err != nil { - return err - } - mdcgr.MongoDBCollectionGetProperties = &mongoDBCollectionGetProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - mdcgr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - mdcgr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - mdcgr.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - mdcgr.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - mdcgr.Tags = tags - } - } - } - - return nil -} - -// MongoDBCollectionListResult the List operation response, that contains the MongoDB collections and their -// properties. -type MongoDBCollectionListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of MongoDB collections and their properties. - Value *[]MongoDBCollectionGetResults `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for MongoDBCollectionListResult. -func (mdclr MongoDBCollectionListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// MongoDBCollectionResource cosmos DB MongoDB collection resource object -type MongoDBCollectionResource struct { - // ID - Name of the Cosmos DB MongoDB collection - ID *string `json:"id,omitempty"` - // ShardKey - A key-value pair of shard keys to be applied for the request. - ShardKey map[string]*string `json:"shardKey"` - // Indexes - List of index keys - Indexes *[]MongoIndex `json:"indexes,omitempty"` - // AnalyticalStorageTTL - Analytical TTL. - AnalyticalStorageTTL *int32 `json:"analyticalStorageTtl,omitempty"` -} - -// MarshalJSON is the custom marshaler for MongoDBCollectionResource. -func (mdcr MongoDBCollectionResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mdcr.ID != nil { - objectMap["id"] = mdcr.ID - } - if mdcr.ShardKey != nil { - objectMap["shardKey"] = mdcr.ShardKey - } - if mdcr.Indexes != nil { - objectMap["indexes"] = mdcr.Indexes - } - if mdcr.AnalyticalStorageTTL != nil { - objectMap["analyticalStorageTtl"] = mdcr.AnalyticalStorageTTL - } - return json.Marshal(objectMap) -} - -// MongoDBDatabaseCreateUpdateParameters parameters to create and update Cosmos DB MongoDB database. -type MongoDBDatabaseCreateUpdateParameters struct { - // MongoDBDatabaseCreateUpdateProperties - Properties to create and update Azure Cosmos DB MongoDB database. - *MongoDBDatabaseCreateUpdateProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for MongoDBDatabaseCreateUpdateParameters. -func (mddcup MongoDBDatabaseCreateUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mddcup.MongoDBDatabaseCreateUpdateProperties != nil { - objectMap["properties"] = mddcup.MongoDBDatabaseCreateUpdateProperties - } - if mddcup.Location != nil { - objectMap["location"] = mddcup.Location - } - if mddcup.Tags != nil { - objectMap["tags"] = mddcup.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for MongoDBDatabaseCreateUpdateParameters struct. -func (mddcup *MongoDBDatabaseCreateUpdateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var mongoDBDatabaseCreateUpdateProperties MongoDBDatabaseCreateUpdateProperties - err = json.Unmarshal(*v, &mongoDBDatabaseCreateUpdateProperties) - if err != nil { - return err - } - mddcup.MongoDBDatabaseCreateUpdateProperties = &mongoDBDatabaseCreateUpdateProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - mddcup.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - mddcup.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - mddcup.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - mddcup.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - mddcup.Tags = tags - } - } - } - - return nil -} - -// MongoDBDatabaseCreateUpdateProperties properties to create and update Azure Cosmos DB MongoDB database. -type MongoDBDatabaseCreateUpdateProperties struct { - // Resource - The standard JSON format of a MongoDB database - Resource *MongoDBDatabaseResource `json:"resource,omitempty"` - // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - Options *CreateUpdateOptions `json:"options,omitempty"` -} - -// MongoDBDatabaseGetProperties the properties of an Azure Cosmos DB MongoDB database -type MongoDBDatabaseGetProperties struct { - Resource *MongoDBDatabaseGetPropertiesResource `json:"resource,omitempty"` - Options *MongoDBDatabaseGetPropertiesOptions `json:"options,omitempty"` -} - -// MongoDBDatabaseGetPropertiesOptions ... -type MongoDBDatabaseGetPropertiesOptions struct { - // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. - Throughput *int32 `json:"throughput,omitempty"` - // AutoscaleSettings - Specifies the Autoscale settings. - AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` -} - -// MongoDBDatabaseGetPropertiesResource ... -type MongoDBDatabaseGetPropertiesResource struct { - // ID - Name of the Cosmos DB MongoDB database - ID *string `json:"id,omitempty"` - // Rid - READ-ONLY; A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. - Ts *float64 `json:"_ts,omitempty"` - // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. - Etag *string `json:"_etag,omitempty"` -} - -// MarshalJSON is the custom marshaler for MongoDBDatabaseGetPropertiesResource. -func (mddgp MongoDBDatabaseGetPropertiesResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mddgp.ID != nil { - objectMap["id"] = mddgp.ID - } - return json.Marshal(objectMap) -} - -// MongoDBDatabaseGetResults an Azure Cosmos DB MongoDB database. -type MongoDBDatabaseGetResults struct { - autorest.Response `json:"-"` - // MongoDBDatabaseGetProperties - The properties of an Azure Cosmos DB MongoDB database - *MongoDBDatabaseGetProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for MongoDBDatabaseGetResults. -func (mddgr MongoDBDatabaseGetResults) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mddgr.MongoDBDatabaseGetProperties != nil { - objectMap["properties"] = mddgr.MongoDBDatabaseGetProperties - } - if mddgr.Location != nil { - objectMap["location"] = mddgr.Location - } - if mddgr.Tags != nil { - objectMap["tags"] = mddgr.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for MongoDBDatabaseGetResults struct. -func (mddgr *MongoDBDatabaseGetResults) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var mongoDBDatabaseGetProperties MongoDBDatabaseGetProperties - err = json.Unmarshal(*v, &mongoDBDatabaseGetProperties) - if err != nil { - return err - } - mddgr.MongoDBDatabaseGetProperties = &mongoDBDatabaseGetProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - mddgr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - mddgr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - mddgr.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - mddgr.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - mddgr.Tags = tags - } - } - } - - return nil -} - -// MongoDBDatabaseListResult the List operation response, that contains the MongoDB databases and their -// properties. -type MongoDBDatabaseListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of MongoDB databases and their properties. - Value *[]MongoDBDatabaseGetResults `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for MongoDBDatabaseListResult. -func (mddlr MongoDBDatabaseListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// MongoDBDatabaseResource cosmos DB MongoDB database resource object -type MongoDBDatabaseResource struct { - // ID - Name of the Cosmos DB MongoDB database - ID *string `json:"id,omitempty"` -} - -// MongoDBResourcesCreateUpdateMongoDBCollectionFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type MongoDBResourcesCreateUpdateMongoDBCollectionFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(MongoDBResourcesClient) (MongoDBCollectionGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *MongoDBResourcesCreateUpdateMongoDBCollectionFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for MongoDBResourcesCreateUpdateMongoDBCollectionFuture.Result. -func (future *MongoDBResourcesCreateUpdateMongoDBCollectionFuture) result(client MongoDBResourcesClient) (mdcgr MongoDBCollectionGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesCreateUpdateMongoDBCollectionFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - mdcgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesCreateUpdateMongoDBCollectionFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if mdcgr.Response.Response, err = future.GetResult(sender); err == nil && mdcgr.Response.Response.StatusCode != http.StatusNoContent { - mdcgr, err = client.CreateUpdateMongoDBCollectionResponder(mdcgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesCreateUpdateMongoDBCollectionFuture", "Result", mdcgr.Response.Response, "Failure responding to request") - } - } - return -} - -// MongoDBResourcesCreateUpdateMongoDBDatabaseFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type MongoDBResourcesCreateUpdateMongoDBDatabaseFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(MongoDBResourcesClient) (MongoDBDatabaseGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *MongoDBResourcesCreateUpdateMongoDBDatabaseFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for MongoDBResourcesCreateUpdateMongoDBDatabaseFuture.Result. -func (future *MongoDBResourcesCreateUpdateMongoDBDatabaseFuture) result(client MongoDBResourcesClient) (mddgr MongoDBDatabaseGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesCreateUpdateMongoDBDatabaseFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - mddgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesCreateUpdateMongoDBDatabaseFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if mddgr.Response.Response, err = future.GetResult(sender); err == nil && mddgr.Response.Response.StatusCode != http.StatusNoContent { - mddgr, err = client.CreateUpdateMongoDBDatabaseResponder(mddgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesCreateUpdateMongoDBDatabaseFuture", "Result", mddgr.Response.Response, "Failure responding to request") - } - } - return -} - -// MongoDBResourcesDeleteMongoDBCollectionFuture an abstraction for monitoring and retrieving the results -// of a long-running operation. -type MongoDBResourcesDeleteMongoDBCollectionFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(MongoDBResourcesClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *MongoDBResourcesDeleteMongoDBCollectionFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for MongoDBResourcesDeleteMongoDBCollectionFuture.Result. -func (future *MongoDBResourcesDeleteMongoDBCollectionFuture) result(client MongoDBResourcesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesDeleteMongoDBCollectionFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesDeleteMongoDBCollectionFuture") - return - } - ar.Response = future.Response() - return -} - -// MongoDBResourcesDeleteMongoDBDatabaseFuture an abstraction for monitoring and retrieving the results of -// a long-running operation. -type MongoDBResourcesDeleteMongoDBDatabaseFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(MongoDBResourcesClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *MongoDBResourcesDeleteMongoDBDatabaseFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for MongoDBResourcesDeleteMongoDBDatabaseFuture.Result. -func (future *MongoDBResourcesDeleteMongoDBDatabaseFuture) result(client MongoDBResourcesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesDeleteMongoDBDatabaseFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesDeleteMongoDBDatabaseFuture") - return - } - ar.Response = future.Response() - return -} - -// MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture an abstraction for monitoring and retrieving -// the results of a long-running operation. -type MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(MongoDBResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture.Result. -func (future *MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture) result(client MongoDBResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.MigrateMongoDBCollectionToAutoscaleResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture an abstraction for monitoring and -// retrieving the results of a long-running operation. -type MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(MongoDBResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture.Result. -func (future *MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture) result(client MongoDBResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.MigrateMongoDBCollectionToManualThroughputResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(MongoDBResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture.Result. -func (future *MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture) result(client MongoDBResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.MigrateMongoDBDatabaseToAutoscaleResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture an abstraction for monitoring and -// retrieving the results of a long-running operation. -type MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(MongoDBResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture.Result. -func (future *MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture) result(client MongoDBResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.MigrateMongoDBDatabaseToManualThroughputResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// MongoDBResourcesRetrieveContinuousBackupInformationFuture an abstraction for monitoring and retrieving -// the results of a long-running operation. -type MongoDBResourcesRetrieveContinuousBackupInformationFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(MongoDBResourcesClient) (BackupInformation, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *MongoDBResourcesRetrieveContinuousBackupInformationFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for MongoDBResourcesRetrieveContinuousBackupInformationFuture.Result. -func (future *MongoDBResourcesRetrieveContinuousBackupInformationFuture) result(client MongoDBResourcesClient) (bi BackupInformation, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesRetrieveContinuousBackupInformationFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - bi.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesRetrieveContinuousBackupInformationFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if bi.Response.Response, err = future.GetResult(sender); err == nil && bi.Response.Response.StatusCode != http.StatusNoContent { - bi, err = client.RetrieveContinuousBackupInformationResponder(bi.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesRetrieveContinuousBackupInformationFuture", "Result", bi.Response.Response, "Failure responding to request") - } - } - return -} - -// MongoDBResourcesUpdateMongoDBCollectionThroughputFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type MongoDBResourcesUpdateMongoDBCollectionThroughputFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(MongoDBResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *MongoDBResourcesUpdateMongoDBCollectionThroughputFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for MongoDBResourcesUpdateMongoDBCollectionThroughputFuture.Result. -func (future *MongoDBResourcesUpdateMongoDBCollectionThroughputFuture) result(client MongoDBResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesUpdateMongoDBCollectionThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesUpdateMongoDBCollectionThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.UpdateMongoDBCollectionThroughputResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesUpdateMongoDBCollectionThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(MongoDBResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture.Result. -func (future *MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture) result(client MongoDBResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.UpdateMongoDBDatabaseThroughputResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// MongoIndex cosmos DB MongoDB collection index key -type MongoIndex struct { - // Key - Cosmos DB MongoDB collection index keys - Key *MongoIndexKeys `json:"key,omitempty"` - // Options - Cosmos DB MongoDB collection index key options - Options *MongoIndexOptions `json:"options,omitempty"` -} - -// MongoIndexKeys cosmos DB MongoDB collection resource object -type MongoIndexKeys struct { - // Keys - List of keys for each MongoDB collection in the Azure Cosmos DB service - Keys *[]string `json:"keys,omitempty"` -} - -// MongoIndexOptions cosmos DB MongoDB collection index options -type MongoIndexOptions struct { - // ExpireAfterSeconds - Expire after seconds - ExpireAfterSeconds *int32 `json:"expireAfterSeconds,omitempty"` - // Unique - Is unique or not - Unique *bool `json:"unique,omitempty"` -} - -// NotebookWorkspace a notebook workspace resource -type NotebookWorkspace struct { - autorest.Response `json:"-"` - // NotebookWorkspaceProperties - Resource properties. - *NotebookWorkspaceProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the database account. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the database account. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for NotebookWorkspace. -func (nw NotebookWorkspace) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if nw.NotebookWorkspaceProperties != nil { - objectMap["properties"] = nw.NotebookWorkspaceProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for NotebookWorkspace struct. -func (nw *NotebookWorkspace) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var notebookWorkspaceProperties NotebookWorkspaceProperties - err = json.Unmarshal(*v, ¬ebookWorkspaceProperties) - if err != nil { - return err - } - nw.NotebookWorkspaceProperties = ¬ebookWorkspaceProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - nw.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - nw.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - nw.Type = &typeVar - } - } - } - - return nil -} - -// NotebookWorkspaceConnectionInfoResult the connection info for the given notebook workspace -type NotebookWorkspaceConnectionInfoResult struct { - autorest.Response `json:"-"` - // AuthToken - READ-ONLY; Specifies auth token used for connecting to Notebook server (uses token-based auth). - AuthToken *string `json:"authToken,omitempty"` - // NotebookServerEndpoint - READ-ONLY; Specifies the endpoint of Notebook server. - NotebookServerEndpoint *string `json:"notebookServerEndpoint,omitempty"` -} - -// MarshalJSON is the custom marshaler for NotebookWorkspaceConnectionInfoResult. -func (nwcir NotebookWorkspaceConnectionInfoResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// NotebookWorkspaceCreateUpdateParameters parameters to create a notebook workspace resource -type NotebookWorkspaceCreateUpdateParameters struct { - // ID - READ-ONLY; The unique resource identifier of the database account. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the database account. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for NotebookWorkspaceCreateUpdateParameters. -func (nwcup NotebookWorkspaceCreateUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// NotebookWorkspaceListResult a list of notebook workspace resources -type NotebookWorkspaceListResult struct { - autorest.Response `json:"-"` - // Value - Array of notebook workspace resources - Value *[]NotebookWorkspace `json:"value,omitempty"` -} - -// NotebookWorkspaceProperties properties of a notebook workspace resource. -type NotebookWorkspaceProperties struct { - // NotebookServerEndpoint - READ-ONLY; Specifies the endpoint of Notebook server. - NotebookServerEndpoint *string `json:"notebookServerEndpoint,omitempty"` - // Status - READ-ONLY; Status of the notebook workspace. Possible values are: Creating, Online, Deleting, Failed, Updating. - Status *string `json:"status,omitempty"` -} - -// MarshalJSON is the custom marshaler for NotebookWorkspaceProperties. -func (nwp NotebookWorkspaceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// NotebookWorkspacesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type NotebookWorkspacesCreateOrUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(NotebookWorkspacesClient) (NotebookWorkspace, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *NotebookWorkspacesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for NotebookWorkspacesCreateOrUpdateFuture.Result. -func (future *NotebookWorkspacesCreateOrUpdateFuture) result(client NotebookWorkspacesClient) (nw NotebookWorkspace, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - nw.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.NotebookWorkspacesCreateOrUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if nw.Response.Response, err = future.GetResult(sender); err == nil && nw.Response.Response.StatusCode != http.StatusNoContent { - nw, err = client.CreateOrUpdateResponder(nw.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesCreateOrUpdateFuture", "Result", nw.Response.Response, "Failure responding to request") - } - } - return -} - -// NotebookWorkspacesDeleteFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type NotebookWorkspacesDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(NotebookWorkspacesClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *NotebookWorkspacesDeleteFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for NotebookWorkspacesDeleteFuture.Result. -func (future *NotebookWorkspacesDeleteFuture) result(client NotebookWorkspacesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.NotebookWorkspacesDeleteFuture") - return - } - ar.Response = future.Response() - return -} - -// NotebookWorkspacesRegenerateAuthTokenFuture an abstraction for monitoring and retrieving the results of -// a long-running operation. -type NotebookWorkspacesRegenerateAuthTokenFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(NotebookWorkspacesClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *NotebookWorkspacesRegenerateAuthTokenFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for NotebookWorkspacesRegenerateAuthTokenFuture.Result. -func (future *NotebookWorkspacesRegenerateAuthTokenFuture) result(client NotebookWorkspacesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesRegenerateAuthTokenFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.NotebookWorkspacesRegenerateAuthTokenFuture") - return - } - ar.Response = future.Response() - return -} - -// NotebookWorkspacesStartFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type NotebookWorkspacesStartFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(NotebookWorkspacesClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *NotebookWorkspacesStartFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for NotebookWorkspacesStartFuture.Result. -func (future *NotebookWorkspacesStartFuture) result(client NotebookWorkspacesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesStartFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.NotebookWorkspacesStartFuture") - return - } - ar.Response = future.Response() - return -} - -// Operation REST API operation -type Operation struct { - // Name - Operation name: {provider}/{resource}/{operation} - Name *string `json:"name,omitempty"` - // Display - The object that represents the operation. - Display *OperationDisplay `json:"display,omitempty"` -} - -// OperationDisplay the object that represents the operation. -type OperationDisplay struct { - // Provider - Service provider: Microsoft.ResourceProvider - Provider *string `json:"Provider,omitempty"` - // Resource - Resource on which the operation is performed: Profile, endpoint, etc. - Resource *string `json:"Resource,omitempty"` - // Operation - Operation type: Read, write, delete, etc. - Operation *string `json:"Operation,omitempty"` - // Description - Description of operation - Description *string `json:"Description,omitempty"` -} - -// OperationListResult result of the request to list Resource Provider operations. It contains a list of -// operations and a URL link to get the next set of results. -type OperationListResult struct { - autorest.Response `json:"-"` - // Value - List of operations supported by the Resource Provider. - Value *[]Operation `json:"value,omitempty"` - // NextLink - URL to get the next set of operation list results if there are any. - NextLink *string `json:"nextLink,omitempty"` -} - -// OperationListResultIterator provides access to a complete listing of Operation values. -type OperationListResultIterator struct { - i int - page OperationListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *OperationListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter OperationListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter OperationListResultIterator) Response() OperationListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter OperationListResultIterator) Value() Operation { - if !iter.page.NotDone() { - return Operation{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the OperationListResultIterator type. -func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { - return OperationListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (olr OperationListResult) IsEmpty() bool { - return olr.Value == nil || len(*olr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (olr OperationListResult) hasNextLink() bool { - return olr.NextLink != nil && len(*olr.NextLink) != 0 -} - -// operationListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { - if !olr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(olr.NextLink))) -} - -// OperationListResultPage contains a page of Operation values. -type OperationListResultPage struct { - fn func(context.Context, OperationListResult) (OperationListResult, error) - olr OperationListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.olr) - if err != nil { - return err - } - page.olr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *OperationListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page OperationListResultPage) NotDone() bool { - return !page.olr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page OperationListResultPage) Response() OperationListResult { - return page.olr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page OperationListResultPage) Values() []Operation { - if page.olr.IsEmpty() { - return nil - } - return *page.olr.Value -} - -// Creates a new instance of the OperationListResultPage type. -func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { - return OperationListResultPage{ - fn: getNextPage, - olr: cur, - } -} - -// OptionsResource cosmos DB options resource object -type OptionsResource struct { - // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. - Throughput *int32 `json:"throughput,omitempty"` - // AutoscaleSettings - Specifies the Autoscale settings. - AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` -} - -// PartitionMetric the metric values for a single partition. -type PartitionMetric struct { - // PartitionID - READ-ONLY; The partition id (GUID identifier) of the metric values. - PartitionID *string `json:"partitionId,omitempty"` - // PartitionKeyRangeID - READ-ONLY; The partition key range id (integer identifier) of the metric values. - PartitionKeyRangeID *string `json:"partitionKeyRangeId,omitempty"` - // StartTime - READ-ONLY; The start time for the metric (ISO-8601 format). - StartTime *date.Time `json:"startTime,omitempty"` - // EndTime - READ-ONLY; The end time for the metric (ISO-8601 format). - EndTime *date.Time `json:"endTime,omitempty"` - // TimeGrain - READ-ONLY; The time grain to be used to summarize the metric values. - TimeGrain *string `json:"timeGrain,omitempty"` - // Unit - The unit of the metric. Possible values include: 'UnitTypeCount', 'UnitTypeBytes', 'UnitTypeSeconds', 'UnitTypePercent', 'UnitTypeCountPerSecond', 'UnitTypeBytesPerSecond', 'UnitTypeMilliseconds' - Unit UnitType `json:"unit,omitempty"` - // Name - READ-ONLY; The name information for the metric. - Name *MetricName `json:"name,omitempty"` - // MetricValues - READ-ONLY; The metric values for the specified time window and timestep. - MetricValues *[]MetricValue `json:"metricValues,omitempty"` -} - -// MarshalJSON is the custom marshaler for PartitionMetric. -func (pm PartitionMetric) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if pm.Unit != "" { - objectMap["unit"] = pm.Unit - } - return json.Marshal(objectMap) -} - -// PartitionMetricListResult the response to a list partition metrics request. -type PartitionMetricListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; The list of partition-level metrics for the account. - Value *[]PartitionMetric `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for PartitionMetricListResult. -func (pmlr PartitionMetricListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// PartitionUsage the partition level usage data for a usage request. -type PartitionUsage struct { - // PartitionID - READ-ONLY; The partition id (GUID identifier) of the usages. - PartitionID *string `json:"partitionId,omitempty"` - // PartitionKeyRangeID - READ-ONLY; The partition key range id (integer identifier) of the usages. - PartitionKeyRangeID *string `json:"partitionKeyRangeId,omitempty"` - // Unit - The unit of the metric. Possible values include: 'UnitTypeCount', 'UnitTypeBytes', 'UnitTypeSeconds', 'UnitTypePercent', 'UnitTypeCountPerSecond', 'UnitTypeBytesPerSecond', 'UnitTypeMilliseconds' - Unit UnitType `json:"unit,omitempty"` - // Name - READ-ONLY; The name information for the metric. - Name *MetricName `json:"name,omitempty"` - // QuotaPeriod - READ-ONLY; The quota period used to summarize the usage values. - QuotaPeriod *string `json:"quotaPeriod,omitempty"` - // Limit - READ-ONLY; Maximum value for this metric - Limit *int64 `json:"limit,omitempty"` - // CurrentValue - READ-ONLY; Current value for this metric - CurrentValue *int64 `json:"currentValue,omitempty"` -} - -// MarshalJSON is the custom marshaler for PartitionUsage. -func (pu PartitionUsage) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if pu.Unit != "" { - objectMap["unit"] = pu.Unit - } - return json.Marshal(objectMap) -} - -// PartitionUsagesResult the response to a list partition level usage request. -type PartitionUsagesResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; The list of partition-level usages for the database. A usage is a point in time metric - Value *[]PartitionUsage `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for PartitionUsagesResult. -func (pur PartitionUsagesResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// PercentileMetric percentile Metric data -type PercentileMetric struct { - // StartTime - READ-ONLY; The start time for the metric (ISO-8601 format). - StartTime *date.Time `json:"startTime,omitempty"` - // EndTime - READ-ONLY; The end time for the metric (ISO-8601 format). - EndTime *date.Time `json:"endTime,omitempty"` - // TimeGrain - READ-ONLY; The time grain to be used to summarize the metric values. - TimeGrain *string `json:"timeGrain,omitempty"` - // Unit - The unit of the metric. Possible values include: 'UnitTypeCount', 'UnitTypeBytes', 'UnitTypeSeconds', 'UnitTypePercent', 'UnitTypeCountPerSecond', 'UnitTypeBytesPerSecond', 'UnitTypeMilliseconds' - Unit UnitType `json:"unit,omitempty"` - // Name - READ-ONLY; The name information for the metric. - Name *MetricName `json:"name,omitempty"` - // MetricValues - READ-ONLY; The percentile metric values for the specified time window and timestep. - MetricValues *[]PercentileMetricValue `json:"metricValues,omitempty"` -} - -// MarshalJSON is the custom marshaler for PercentileMetric. -func (pm PercentileMetric) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if pm.Unit != "" { - objectMap["unit"] = pm.Unit - } - return json.Marshal(objectMap) -} - -// PercentileMetricListResult the response to a list percentile metrics request. -type PercentileMetricListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; The list of percentile metrics for the account. - Value *[]PercentileMetric `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for PercentileMetricListResult. -func (pmlr PercentileMetricListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// PercentileMetricValue represents percentile metrics values. -type PercentileMetricValue struct { - // P10 - READ-ONLY; The 10th percentile value for the metric. - P10 *float64 `json:"P10,omitempty"` - // P25 - READ-ONLY; The 25th percentile value for the metric. - P25 *float64 `json:"P25,omitempty"` - // P50 - READ-ONLY; The 50th percentile value for the metric. - P50 *float64 `json:"P50,omitempty"` - // P75 - READ-ONLY; The 75th percentile value for the metric. - P75 *float64 `json:"P75,omitempty"` - // P90 - READ-ONLY; The 90th percentile value for the metric. - P90 *float64 `json:"P90,omitempty"` - // P95 - READ-ONLY; The 95th percentile value for the metric. - P95 *float64 `json:"P95,omitempty"` - // P99 - READ-ONLY; The 99th percentile value for the metric. - P99 *float64 `json:"P99,omitempty"` - // Count - READ-ONLY; The number of values for the metric. - Count *float64 `json:"_count,omitempty"` - // Average - READ-ONLY; The average value of the metric. - Average *float64 `json:"average,omitempty"` - // Maximum - READ-ONLY; The max value of the metric. - Maximum *float64 `json:"maximum,omitempty"` - // Minimum - READ-ONLY; The min value of the metric. - Minimum *float64 `json:"minimum,omitempty"` - // Timestamp - READ-ONLY; The metric timestamp (ISO-8601 format). - Timestamp *date.Time `json:"timestamp,omitempty"` - // Total - READ-ONLY; The total value of the metric. - Total *float64 `json:"total,omitempty"` -} - -// MarshalJSON is the custom marshaler for PercentileMetricValue. -func (pmv PercentileMetricValue) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// PeriodicModeBackupPolicy the object representing periodic mode backup policy. -type PeriodicModeBackupPolicy struct { - // PeriodicModeProperties - Configuration values for periodic mode backup - PeriodicModeProperties *PeriodicModeProperties `json:"periodicModeProperties,omitempty"` - // MigrationState - The object representing the state of the migration between the backup policies. - MigrationState *BackupPolicyMigrationState `json:"migrationState,omitempty"` - // Type - Possible values include: 'TypeBackupPolicy', 'TypePeriodic', 'TypeContinuous' - Type Type `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for PeriodicModeBackupPolicy. -func (pmbp PeriodicModeBackupPolicy) MarshalJSON() ([]byte, error) { - pmbp.Type = TypePeriodic - objectMap := make(map[string]interface{}) - if pmbp.PeriodicModeProperties != nil { - objectMap["periodicModeProperties"] = pmbp.PeriodicModeProperties - } - if pmbp.MigrationState != nil { - objectMap["migrationState"] = pmbp.MigrationState - } - if pmbp.Type != "" { - objectMap["type"] = pmbp.Type - } - return json.Marshal(objectMap) -} - -// AsPeriodicModeBackupPolicy is the BasicBackupPolicy implementation for PeriodicModeBackupPolicy. -func (pmbp PeriodicModeBackupPolicy) AsPeriodicModeBackupPolicy() (*PeriodicModeBackupPolicy, bool) { - return &pmbp, true -} - -// AsContinuousModeBackupPolicy is the BasicBackupPolicy implementation for PeriodicModeBackupPolicy. -func (pmbp PeriodicModeBackupPolicy) AsContinuousModeBackupPolicy() (*ContinuousModeBackupPolicy, bool) { - return nil, false -} - -// AsBackupPolicy is the BasicBackupPolicy implementation for PeriodicModeBackupPolicy. -func (pmbp PeriodicModeBackupPolicy) AsBackupPolicy() (*BackupPolicy, bool) { - return nil, false -} - -// AsBasicBackupPolicy is the BasicBackupPolicy implementation for PeriodicModeBackupPolicy. -func (pmbp PeriodicModeBackupPolicy) AsBasicBackupPolicy() (BasicBackupPolicy, bool) { - return &pmbp, true -} - -// PeriodicModeProperties configuration values for periodic mode backup -type PeriodicModeProperties struct { - // BackupIntervalInMinutes - An integer representing the interval in minutes between two backups - BackupIntervalInMinutes *int32 `json:"backupIntervalInMinutes,omitempty"` - // BackupRetentionIntervalInHours - An integer representing the time (in hours) that each backup is retained - BackupRetentionIntervalInHours *int32 `json:"backupRetentionIntervalInHours,omitempty"` - // BackupStorageRedundancy - Enum to indicate type of backup residency. Possible values include: 'BackupStorageRedundancyGeo', 'BackupStorageRedundancyLocal', 'BackupStorageRedundancyZone' - BackupStorageRedundancy BackupStorageRedundancy `json:"backupStorageRedundancy,omitempty"` -} - -// Permission the set of data plane operations permitted through this Role Definition. -type Permission struct { - // DataActions - An array of data actions that are allowed. - DataActions *[]string `json:"dataActions,omitempty"` - // NotDataActions - An array of data actions that are denied. - NotDataActions *[]string `json:"notDataActions,omitempty"` -} - -// PrivateEndpointConnection a private endpoint connection -type PrivateEndpointConnection struct { - autorest.Response `json:"-"` - // PrivateEndpointConnectionProperties - Resource properties. - *PrivateEndpointConnectionProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the resource - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for PrivateEndpointConnection. -func (pec PrivateEndpointConnection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if pec.PrivateEndpointConnectionProperties != nil { - objectMap["properties"] = pec.PrivateEndpointConnectionProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for PrivateEndpointConnection struct. -func (pec *PrivateEndpointConnection) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var privateEndpointConnectionProperties PrivateEndpointConnectionProperties - err = json.Unmarshal(*v, &privateEndpointConnectionProperties) - if err != nil { - return err - } - pec.PrivateEndpointConnectionProperties = &privateEndpointConnectionProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - pec.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - pec.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - pec.Type = &typeVar - } - } - } - - return nil -} - -// PrivateEndpointConnectionListResult a list of private endpoint connections -type PrivateEndpointConnectionListResult struct { - autorest.Response `json:"-"` - // Value - Array of private endpoint connections - Value *[]PrivateEndpointConnection `json:"value,omitempty"` -} - -// PrivateEndpointConnectionProperties properties of a private endpoint connection. -type PrivateEndpointConnectionProperties struct { - // PrivateEndpoint - Private endpoint which the connection belongs to. - PrivateEndpoint *PrivateEndpointProperty `json:"privateEndpoint,omitempty"` - // PrivateLinkServiceConnectionState - Connection State of the Private Endpoint Connection. - PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionStateProperty `json:"privateLinkServiceConnectionState,omitempty"` - // GroupID - Group id of the private endpoint. - GroupID *string `json:"groupId,omitempty"` - // ProvisioningState - Provisioning state of the private endpoint. - ProvisioningState *string `json:"provisioningState,omitempty"` -} - -// PrivateEndpointConnectionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results -// of a long-running operation. -type PrivateEndpointConnectionsCreateOrUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(PrivateEndpointConnectionsClient) (PrivateEndpointConnection, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *PrivateEndpointConnectionsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for PrivateEndpointConnectionsCreateOrUpdateFuture.Result. -func (future *PrivateEndpointConnectionsCreateOrUpdateFuture) result(client PrivateEndpointConnectionsClient) (pec PrivateEndpointConnection, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - pec.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.PrivateEndpointConnectionsCreateOrUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if pec.Response.Response, err = future.GetResult(sender); err == nil && pec.Response.Response.StatusCode != http.StatusNoContent { - pec, err = client.CreateOrUpdateResponder(pec.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsCreateOrUpdateFuture", "Result", pec.Response.Response, "Failure responding to request") - } - } - return -} - -// PrivateEndpointConnectionsDeleteFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type PrivateEndpointConnectionsDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(PrivateEndpointConnectionsClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *PrivateEndpointConnectionsDeleteFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for PrivateEndpointConnectionsDeleteFuture.Result. -func (future *PrivateEndpointConnectionsDeleteFuture) result(client PrivateEndpointConnectionsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.PrivateEndpointConnectionsDeleteFuture") - return - } - ar.Response = future.Response() - return -} - -// PrivateEndpointProperty private endpoint which the connection belongs to. -type PrivateEndpointProperty struct { - // ID - Resource id of the private endpoint. - ID *string `json:"id,omitempty"` -} - -// PrivateLinkResource a private link resource -type PrivateLinkResource struct { - autorest.Response `json:"-"` - // PrivateLinkResourceProperties - Resource properties. - *PrivateLinkResourceProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the database account. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the database account. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for PrivateLinkResource. -func (plr PrivateLinkResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if plr.PrivateLinkResourceProperties != nil { - objectMap["properties"] = plr.PrivateLinkResourceProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for PrivateLinkResource struct. -func (plr *PrivateLinkResource) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var privateLinkResourceProperties PrivateLinkResourceProperties - err = json.Unmarshal(*v, &privateLinkResourceProperties) - if err != nil { - return err - } - plr.PrivateLinkResourceProperties = &privateLinkResourceProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - plr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - plr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - plr.Type = &typeVar - } - } - } - - return nil -} - -// PrivateLinkResourceListResult a list of private link resources -type PrivateLinkResourceListResult struct { - autorest.Response `json:"-"` - // Value - Array of private link resources - Value *[]PrivateLinkResource `json:"value,omitempty"` -} - -// PrivateLinkResourceProperties properties of a private link resource. -type PrivateLinkResourceProperties struct { - // GroupID - READ-ONLY; The private link resource group id. - GroupID *string `json:"groupId,omitempty"` - // RequiredMembers - READ-ONLY; The private link resource required member names. - RequiredMembers *[]string `json:"requiredMembers,omitempty"` - // RequiredZoneNames - READ-ONLY; The private link resource required zone names. - RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` -} - -// MarshalJSON is the custom marshaler for PrivateLinkResourceProperties. -func (plrp PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// PrivateLinkServiceConnectionStateProperty connection State of the Private Endpoint Connection. -type PrivateLinkServiceConnectionStateProperty struct { - // Status - The private link service connection status. - Status *string `json:"status,omitempty"` - // Description - The private link service connection description. - Description *string `json:"description,omitempty"` - // ActionsRequired - READ-ONLY; Any action that is required beyond basic workflow (approve/ reject/ disconnect) - ActionsRequired *string `json:"actionsRequired,omitempty"` -} - -// MarshalJSON is the custom marshaler for PrivateLinkServiceConnectionStateProperty. -func (plscsp PrivateLinkServiceConnectionStateProperty) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if plscsp.Status != nil { - objectMap["status"] = plscsp.Status - } - if plscsp.Description != nil { - objectMap["description"] = plscsp.Description - } - return json.Marshal(objectMap) -} - -// ProxyResource the resource model definition for a Azure Resource Manager proxy resource. It will not -// have tags and a location -type ProxyResource struct { - // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the resource - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for ProxyResource. -func (pr ProxyResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// RegionForOnlineOffline cosmos DB region to online or offline. -type RegionForOnlineOffline struct { - // Region - Cosmos DB region, with spaces between words and each word capitalized. - Region *string `json:"region,omitempty"` -} - -// Resource common fields that are returned in the response for all Azure Resource Manager resources -type Resource struct { - // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the resource - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for Resource. -func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// RestorableDatabaseAccountGetResult a Azure Cosmos DB restorable database account. -type RestorableDatabaseAccountGetResult struct { - autorest.Response `json:"-"` - // RestorableDatabaseAccountProperties - The properties of a restorable database account. - *RestorableDatabaseAccountProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` -} - -// MarshalJSON is the custom marshaler for RestorableDatabaseAccountGetResult. -func (rdagr RestorableDatabaseAccountGetResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if rdagr.RestorableDatabaseAccountProperties != nil { - objectMap["properties"] = rdagr.RestorableDatabaseAccountProperties - } - if rdagr.Location != nil { - objectMap["location"] = rdagr.Location - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for RestorableDatabaseAccountGetResult struct. -func (rdagr *RestorableDatabaseAccountGetResult) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var restorableDatabaseAccountProperties RestorableDatabaseAccountProperties - err = json.Unmarshal(*v, &restorableDatabaseAccountProperties) - if err != nil { - return err - } - rdagr.RestorableDatabaseAccountProperties = &restorableDatabaseAccountProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - rdagr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - rdagr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - rdagr.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - rdagr.Location = &location - } - } - } - - return nil -} - -// RestorableDatabaseAccountProperties the properties of a restorable database account. -type RestorableDatabaseAccountProperties struct { - // AccountName - The name of the global database account - AccountName *string `json:"accountName,omitempty"` - // CreationTime - The creation time of the restorable database account (ISO-8601 format). - CreationTime *date.Time `json:"creationTime,omitempty"` - // DeletionTime - The time at which the restorable database account has been deleted (ISO-8601 format). - DeletionTime *date.Time `json:"deletionTime,omitempty"` - // APIType - READ-ONLY; The API type of the restorable database account. Possible values include: 'APITypeMongoDB', 'APITypeGremlin', 'APITypeCassandra', 'APITypeTable', 'APITypeSQL', 'APITypeGremlinV2' - APIType APIType `json:"apiType,omitempty"` - // RestorableLocations - READ-ONLY; List of regions where the of the database account can be restored from. - RestorableLocations *[]RestorableLocationResource `json:"restorableLocations,omitempty"` -} - -// MarshalJSON is the custom marshaler for RestorableDatabaseAccountProperties. -func (rdap RestorableDatabaseAccountProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if rdap.AccountName != nil { - objectMap["accountName"] = rdap.AccountName - } - if rdap.CreationTime != nil { - objectMap["creationTime"] = rdap.CreationTime - } - if rdap.DeletionTime != nil { - objectMap["deletionTime"] = rdap.DeletionTime - } - return json.Marshal(objectMap) -} - -// RestorableDatabaseAccountsListResult the List operation response, that contains the restorable database -// accounts and their properties. -type RestorableDatabaseAccountsListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of restorable database accounts and their properties. - Value *[]RestorableDatabaseAccountGetResult `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for RestorableDatabaseAccountsListResult. -func (rdalr RestorableDatabaseAccountsListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// RestorableLocationResource properties of the regional restorable account. -type RestorableLocationResource struct { - // LocationName - READ-ONLY; The location of the regional restorable account. - LocationName *string `json:"locationName,omitempty"` - // RegionalDatabaseAccountInstanceID - READ-ONLY; The instance id of the regional restorable account. - RegionalDatabaseAccountInstanceID *string `json:"regionalDatabaseAccountInstanceId,omitempty"` - // CreationTime - READ-ONLY; The creation time of the regional restorable database account (ISO-8601 format). - CreationTime *date.Time `json:"creationTime,omitempty"` - // DeletionTime - READ-ONLY; The time at which the regional restorable database account has been deleted (ISO-8601 format). - DeletionTime *date.Time `json:"deletionTime,omitempty"` -} - -// MarshalJSON is the custom marshaler for RestorableLocationResource. -func (rlr RestorableLocationResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// RestorableMongodbCollectionGetResult an Azure Cosmos DB MongoDB collection event -type RestorableMongodbCollectionGetResult struct { - // RestorableMongodbCollectionProperties - The properties of a MongoDB collection event. - *RestorableMongodbCollectionProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource Identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for RestorableMongodbCollectionGetResult. -func (rmcgr RestorableMongodbCollectionGetResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if rmcgr.RestorableMongodbCollectionProperties != nil { - objectMap["properties"] = rmcgr.RestorableMongodbCollectionProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for RestorableMongodbCollectionGetResult struct. -func (rmcgr *RestorableMongodbCollectionGetResult) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var restorableMongodbCollectionProperties RestorableMongodbCollectionProperties - err = json.Unmarshal(*v, &restorableMongodbCollectionProperties) - if err != nil { - return err - } - rmcgr.RestorableMongodbCollectionProperties = &restorableMongodbCollectionProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - rmcgr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - rmcgr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - rmcgr.Type = &typeVar - } - } - } - - return nil -} - -// RestorableMongodbCollectionProperties the properties of an Azure Cosmos DB MongoDB collection event -type RestorableMongodbCollectionProperties struct { - // Resource - The resource of an Azure Cosmos DB MongoDB collection event - Resource *RestorableMongodbCollectionPropertiesResource `json:"resource,omitempty"` -} - -// RestorableMongodbCollectionPropertiesResource the resource of an Azure Cosmos DB MongoDB collection -// event -type RestorableMongodbCollectionPropertiesResource struct { - // Rid - READ-ONLY; A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // OperationType - READ-ONLY; The operation type of this collection event. Possible values include: 'OperationTypeCreate', 'OperationTypeReplace', 'OperationTypeDelete', 'OperationTypeSystemOperation' - OperationType OperationType `json:"operationType,omitempty"` - // EventTimestamp - READ-ONLY; The time when this collection event happened. - EventTimestamp *string `json:"eventTimestamp,omitempty"` - // OwnerID - READ-ONLY; The name of this MongoDB collection. - OwnerID *string `json:"ownerId,omitempty"` - // OwnerResourceID - READ-ONLY; The resource ID of this MongoDB collection. - OwnerResourceID *string `json:"ownerResourceId,omitempty"` -} - -// MarshalJSON is the custom marshaler for RestorableMongodbCollectionPropertiesResource. -func (rmcp RestorableMongodbCollectionPropertiesResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// RestorableMongodbCollectionsListResult the List operation response, that contains the MongoDB collection -// events and their properties. -type RestorableMongodbCollectionsListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of MongoDB collection events and their properties. - Value *[]RestorableMongodbCollectionGetResult `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for RestorableMongodbCollectionsListResult. -func (rmclr RestorableMongodbCollectionsListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// RestorableMongodbDatabaseGetResult an Azure Cosmos DB MongoDB database event -type RestorableMongodbDatabaseGetResult struct { - // RestorableMongodbDatabaseProperties - The properties of a MongoDB database event. - *RestorableMongodbDatabaseProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource Identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for RestorableMongodbDatabaseGetResult. -func (rmdgr RestorableMongodbDatabaseGetResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if rmdgr.RestorableMongodbDatabaseProperties != nil { - objectMap["properties"] = rmdgr.RestorableMongodbDatabaseProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for RestorableMongodbDatabaseGetResult struct. -func (rmdgr *RestorableMongodbDatabaseGetResult) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var restorableMongodbDatabaseProperties RestorableMongodbDatabaseProperties - err = json.Unmarshal(*v, &restorableMongodbDatabaseProperties) - if err != nil { - return err - } - rmdgr.RestorableMongodbDatabaseProperties = &restorableMongodbDatabaseProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - rmdgr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - rmdgr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - rmdgr.Type = &typeVar - } - } - } - - return nil -} - -// RestorableMongodbDatabaseProperties the properties of an Azure Cosmos DB MongoDB database event -type RestorableMongodbDatabaseProperties struct { - // Resource - The resource of an Azure Cosmos DB MongoDB database event - Resource *RestorableMongodbDatabasePropertiesResource `json:"resource,omitempty"` -} - -// RestorableMongodbDatabasePropertiesResource the resource of an Azure Cosmos DB MongoDB database event -type RestorableMongodbDatabasePropertiesResource struct { - // Rid - READ-ONLY; A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // OperationType - READ-ONLY; The operation type of this database event. Possible values include: 'OperationTypeCreate', 'OperationTypeReplace', 'OperationTypeDelete', 'OperationTypeSystemOperation' - OperationType OperationType `json:"operationType,omitempty"` - // EventTimestamp - READ-ONLY; The time when this database event happened. - EventTimestamp *string `json:"eventTimestamp,omitempty"` - // OwnerID - READ-ONLY; The name of this MongoDB database. - OwnerID *string `json:"ownerId,omitempty"` - // OwnerResourceID - READ-ONLY; The resource ID of this MongoDB database. - OwnerResourceID *string `json:"ownerResourceId,omitempty"` -} - -// MarshalJSON is the custom marshaler for RestorableMongodbDatabasePropertiesResource. -func (rmdp RestorableMongodbDatabasePropertiesResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// RestorableMongodbDatabasesListResult the List operation response, that contains the MongoDB database -// events and their properties. -type RestorableMongodbDatabasesListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of MongoDB database events and their properties. - Value *[]RestorableMongodbDatabaseGetResult `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for RestorableMongodbDatabasesListResult. -func (rmdlr RestorableMongodbDatabasesListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// RestorableMongodbResourcesListResult the List operation response, that contains the restorable MongoDB -// resources. -type RestorableMongodbResourcesListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of restorable MongoDB resources, including the database and collection names. - Value *[]DatabaseRestoreResource `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for RestorableMongodbResourcesListResult. -func (rmrlr RestorableMongodbResourcesListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// RestorableSQLContainerGetResult an Azure Cosmos DB SQL container event -type RestorableSQLContainerGetResult struct { - // RestorableSQLContainerProperties - The properties of a SQL container event. - *RestorableSQLContainerProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource Identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for RestorableSQLContainerGetResult. -func (rscgr RestorableSQLContainerGetResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if rscgr.RestorableSQLContainerProperties != nil { - objectMap["properties"] = rscgr.RestorableSQLContainerProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for RestorableSQLContainerGetResult struct. -func (rscgr *RestorableSQLContainerGetResult) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var restorableSQLContainerProperties RestorableSQLContainerProperties - err = json.Unmarshal(*v, &restorableSQLContainerProperties) - if err != nil { - return err - } - rscgr.RestorableSQLContainerProperties = &restorableSQLContainerProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - rscgr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - rscgr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - rscgr.Type = &typeVar - } - } - } - - return nil -} - -// RestorableSQLContainerProperties the properties of an Azure Cosmos DB SQL container event -type RestorableSQLContainerProperties struct { - // Resource - The resource of an Azure Cosmos DB SQL container event - Resource *RestorableSQLContainerPropertiesResource `json:"resource,omitempty"` -} - -// RestorableSQLContainerPropertiesResource the resource of an Azure Cosmos DB SQL container event -type RestorableSQLContainerPropertiesResource struct { - // Rid - READ-ONLY; A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // OperationType - READ-ONLY; The operation type of this container event. Possible values include: 'OperationTypeCreate', 'OperationTypeReplace', 'OperationTypeDelete', 'OperationTypeSystemOperation' - OperationType OperationType `json:"operationType,omitempty"` - // EventTimestamp - READ-ONLY; The when this container event happened. - EventTimestamp *string `json:"eventTimestamp,omitempty"` - // OwnerID - READ-ONLY; The name of this SQL container. - OwnerID *string `json:"ownerId,omitempty"` - // OwnerResourceID - READ-ONLY; The resource ID of this SQL container. - OwnerResourceID *string `json:"ownerResourceId,omitempty"` - // Container - Cosmos DB SQL container resource object - Container *RestorableSQLContainerPropertiesResourceContainer `json:"container,omitempty"` -} - -// MarshalJSON is the custom marshaler for RestorableSQLContainerPropertiesResource. -func (rscp RestorableSQLContainerPropertiesResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if rscp.Container != nil { - objectMap["container"] = rscp.Container - } - return json.Marshal(objectMap) -} - -// RestorableSQLContainerPropertiesResourceContainer cosmos DB SQL container resource object -type RestorableSQLContainerPropertiesResourceContainer struct { - // ID - Name of the Cosmos DB SQL container - ID *string `json:"id,omitempty"` - // IndexingPolicy - The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the container - IndexingPolicy *IndexingPolicy `json:"indexingPolicy,omitempty"` - // PartitionKey - The configuration of the partition key to be used for partitioning data into multiple partitions - PartitionKey *ContainerPartitionKey `json:"partitionKey,omitempty"` - // DefaultTTL - Default time to live - DefaultTTL *int32 `json:"defaultTtl,omitempty"` - // UniqueKeyPolicy - The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. - UniqueKeyPolicy *UniqueKeyPolicy `json:"uniqueKeyPolicy,omitempty"` - // ConflictResolutionPolicy - The conflict resolution policy for the container. - ConflictResolutionPolicy *ConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"` - // AnalyticalStorageTTL - Analytical TTL. - AnalyticalStorageTTL *int64 `json:"analyticalStorageTtl,omitempty"` - // Rid - READ-ONLY; A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. - Ts *float64 `json:"_ts,omitempty"` - // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. - Etag *string `json:"_etag,omitempty"` - // Self - READ-ONLY; A system generated property that specifies the addressable path of the container resource. - Self *string `json:"_self,omitempty"` -} - -// MarshalJSON is the custom marshaler for RestorableSQLContainerPropertiesResourceContainer. -func (rscp RestorableSQLContainerPropertiesResourceContainer) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if rscp.ID != nil { - objectMap["id"] = rscp.ID - } - if rscp.IndexingPolicy != nil { - objectMap["indexingPolicy"] = rscp.IndexingPolicy - } - if rscp.PartitionKey != nil { - objectMap["partitionKey"] = rscp.PartitionKey - } - if rscp.DefaultTTL != nil { - objectMap["defaultTtl"] = rscp.DefaultTTL - } - if rscp.UniqueKeyPolicy != nil { - objectMap["uniqueKeyPolicy"] = rscp.UniqueKeyPolicy - } - if rscp.ConflictResolutionPolicy != nil { - objectMap["conflictResolutionPolicy"] = rscp.ConflictResolutionPolicy - } - if rscp.AnalyticalStorageTTL != nil { - objectMap["analyticalStorageTtl"] = rscp.AnalyticalStorageTTL - } - return json.Marshal(objectMap) -} - -// RestorableSQLContainersListResult the List operation response, that contains the SQL container events -// and their properties. -type RestorableSQLContainersListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of SQL container events and their properties. - Value *[]RestorableSQLContainerGetResult `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for RestorableSQLContainersListResult. -func (rsclr RestorableSQLContainersListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// RestorableSQLDatabaseGetResult an Azure Cosmos DB SQL database event -type RestorableSQLDatabaseGetResult struct { - // RestorableSQLDatabaseProperties - The properties of a SQL database event. - *RestorableSQLDatabaseProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource Identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for RestorableSQLDatabaseGetResult. -func (rsdgr RestorableSQLDatabaseGetResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if rsdgr.RestorableSQLDatabaseProperties != nil { - objectMap["properties"] = rsdgr.RestorableSQLDatabaseProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for RestorableSQLDatabaseGetResult struct. -func (rsdgr *RestorableSQLDatabaseGetResult) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var restorableSQLDatabaseProperties RestorableSQLDatabaseProperties - err = json.Unmarshal(*v, &restorableSQLDatabaseProperties) - if err != nil { - return err - } - rsdgr.RestorableSQLDatabaseProperties = &restorableSQLDatabaseProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - rsdgr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - rsdgr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - rsdgr.Type = &typeVar - } - } - } - - return nil -} - -// RestorableSQLDatabaseProperties the properties of an Azure Cosmos DB SQL database event -type RestorableSQLDatabaseProperties struct { - // Resource - The resource of an Azure Cosmos DB SQL database event - Resource *RestorableSQLDatabasePropertiesResource `json:"resource,omitempty"` -} - -// RestorableSQLDatabasePropertiesResource the resource of an Azure Cosmos DB SQL database event -type RestorableSQLDatabasePropertiesResource struct { - // Rid - READ-ONLY; A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // OperationType - READ-ONLY; The operation type of this database event. Possible values include: 'OperationTypeCreate', 'OperationTypeReplace', 'OperationTypeDelete', 'OperationTypeSystemOperation' - OperationType OperationType `json:"operationType,omitempty"` - // EventTimestamp - READ-ONLY; The time when this database event happened. - EventTimestamp *string `json:"eventTimestamp,omitempty"` - // OwnerID - READ-ONLY; The name of the SQL database. - OwnerID *string `json:"ownerId,omitempty"` - // OwnerResourceID - READ-ONLY; The resource ID of the SQL database. - OwnerResourceID *string `json:"ownerResourceId,omitempty"` - // Database - Cosmos DB SQL database resource object - Database *RestorableSQLDatabasePropertiesResourceDatabase `json:"database,omitempty"` -} - -// MarshalJSON is the custom marshaler for RestorableSQLDatabasePropertiesResource. -func (rsdp RestorableSQLDatabasePropertiesResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if rsdp.Database != nil { - objectMap["database"] = rsdp.Database - } - return json.Marshal(objectMap) -} - -// RestorableSQLDatabasePropertiesResourceDatabase cosmos DB SQL database resource object -type RestorableSQLDatabasePropertiesResourceDatabase struct { - // ID - Name of the Cosmos DB SQL database - ID *string `json:"id,omitempty"` - // Rid - READ-ONLY; A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. - Ts *float64 `json:"_ts,omitempty"` - // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. - Etag *string `json:"_etag,omitempty"` - // Colls - READ-ONLY; A system generated property that specified the addressable path of the collections resource. - Colls *string `json:"_colls,omitempty"` - // Users - READ-ONLY; A system generated property that specifies the addressable path of the users resource. - Users *string `json:"_users,omitempty"` - // Self - READ-ONLY; A system generated property that specifies the addressable path of the database resource. - Self *string `json:"_self,omitempty"` -} - -// MarshalJSON is the custom marshaler for RestorableSQLDatabasePropertiesResourceDatabase. -func (rsdp RestorableSQLDatabasePropertiesResourceDatabase) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if rsdp.ID != nil { - objectMap["id"] = rsdp.ID - } - return json.Marshal(objectMap) -} - -// RestorableSQLDatabasesListResult the List operation response, that contains the SQL database events and -// their properties. -type RestorableSQLDatabasesListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of SQL database events and their properties. - Value *[]RestorableSQLDatabaseGetResult `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for RestorableSQLDatabasesListResult. -func (rsdlr RestorableSQLDatabasesListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// RestorableSQLResourcesListResult the List operation response, that contains the restorable SQL -// resources. -type RestorableSQLResourcesListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of restorable SQL resources, including the database and collection names. - Value *[]DatabaseRestoreResource `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for RestorableSQLResourcesListResult. -func (rsrlr RestorableSQLResourcesListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// RestoreParameters parameters to indicate the information about the restore. -type RestoreParameters struct { - // RestoreMode - Describes the mode of the restore. Possible values include: 'RestoreModePointInTime' - RestoreMode RestoreMode `json:"restoreMode,omitempty"` - // RestoreSource - The id of the restorable database account from which the restore has to be initiated. For example: /subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{restorableDatabaseAccountName} - RestoreSource *string `json:"restoreSource,omitempty"` - // RestoreTimestampInUtc - Time to which the account has to be restored (ISO-8601 format). - RestoreTimestampInUtc *date.Time `json:"restoreTimestampInUtc,omitempty"` - // DatabasesToRestore - List of specific databases available for restore. - DatabasesToRestore *[]DatabaseRestoreResource `json:"databasesToRestore,omitempty"` -} - -// SeedNode ... -type SeedNode struct { - // IPAddress - IP address of this seed node. - IPAddress *string `json:"ipAddress,omitempty"` -} - -// SpatialSpec ... -type SpatialSpec struct { - // Path - The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) - Path *string `json:"path,omitempty"` - // Types - List of path's spatial type - Types *[]SpatialType `json:"types,omitempty"` -} - -// SQLContainerCreateUpdateParameters parameters to create and update Cosmos DB container. -type SQLContainerCreateUpdateParameters struct { - // SQLContainerCreateUpdateProperties - Properties to create and update Azure Cosmos DB container. - *SQLContainerCreateUpdateProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for SQLContainerCreateUpdateParameters. -func (sccup SQLContainerCreateUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if sccup.SQLContainerCreateUpdateProperties != nil { - objectMap["properties"] = sccup.SQLContainerCreateUpdateProperties - } - if sccup.Location != nil { - objectMap["location"] = sccup.Location - } - if sccup.Tags != nil { - objectMap["tags"] = sccup.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for SQLContainerCreateUpdateParameters struct. -func (sccup *SQLContainerCreateUpdateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var SQLContainerCreateUpdateProperties SQLContainerCreateUpdateProperties - err = json.Unmarshal(*v, &SQLContainerCreateUpdateProperties) - if err != nil { - return err - } - sccup.SQLContainerCreateUpdateProperties = &SQLContainerCreateUpdateProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - sccup.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - sccup.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - sccup.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - sccup.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - sccup.Tags = tags - } - } - } - - return nil -} - -// SQLContainerCreateUpdateProperties properties to create and update Azure Cosmos DB container. -type SQLContainerCreateUpdateProperties struct { - // Resource - The standard JSON format of a container - Resource *SQLContainerResource `json:"resource,omitempty"` - // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - Options *CreateUpdateOptions `json:"options,omitempty"` -} - -// SQLContainerGetProperties the properties of an Azure Cosmos DB container -type SQLContainerGetProperties struct { - Resource *SQLContainerGetPropertiesResource `json:"resource,omitempty"` - Options *SQLContainerGetPropertiesOptions `json:"options,omitempty"` -} - -// SQLContainerGetPropertiesOptions ... -type SQLContainerGetPropertiesOptions struct { - // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. - Throughput *int32 `json:"throughput,omitempty"` - // AutoscaleSettings - Specifies the Autoscale settings. - AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` -} - -// SQLContainerGetPropertiesResource ... -type SQLContainerGetPropertiesResource struct { - // ID - Name of the Cosmos DB SQL container - ID *string `json:"id,omitempty"` - // IndexingPolicy - The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the container - IndexingPolicy *IndexingPolicy `json:"indexingPolicy,omitempty"` - // PartitionKey - The configuration of the partition key to be used for partitioning data into multiple partitions - PartitionKey *ContainerPartitionKey `json:"partitionKey,omitempty"` - // DefaultTTL - Default time to live - DefaultTTL *int32 `json:"defaultTtl,omitempty"` - // UniqueKeyPolicy - The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. - UniqueKeyPolicy *UniqueKeyPolicy `json:"uniqueKeyPolicy,omitempty"` - // ConflictResolutionPolicy - The conflict resolution policy for the container. - ConflictResolutionPolicy *ConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"` - // AnalyticalStorageTTL - Analytical TTL. - AnalyticalStorageTTL *int64 `json:"analyticalStorageTtl,omitempty"` - // Rid - READ-ONLY; A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. - Ts *float64 `json:"_ts,omitempty"` - // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. - Etag *string `json:"_etag,omitempty"` -} - -// MarshalJSON is the custom marshaler for SQLContainerGetPropertiesResource. -func (scgp SQLContainerGetPropertiesResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if scgp.ID != nil { - objectMap["id"] = scgp.ID - } - if scgp.IndexingPolicy != nil { - objectMap["indexingPolicy"] = scgp.IndexingPolicy - } - if scgp.PartitionKey != nil { - objectMap["partitionKey"] = scgp.PartitionKey - } - if scgp.DefaultTTL != nil { - objectMap["defaultTtl"] = scgp.DefaultTTL - } - if scgp.UniqueKeyPolicy != nil { - objectMap["uniqueKeyPolicy"] = scgp.UniqueKeyPolicy - } - if scgp.ConflictResolutionPolicy != nil { - objectMap["conflictResolutionPolicy"] = scgp.ConflictResolutionPolicy - } - if scgp.AnalyticalStorageTTL != nil { - objectMap["analyticalStorageTtl"] = scgp.AnalyticalStorageTTL - } - return json.Marshal(objectMap) -} - -// SQLContainerGetResults an Azure Cosmos DB container. -type SQLContainerGetResults struct { - autorest.Response `json:"-"` - // SQLContainerGetProperties - The properties of an Azure Cosmos DB container - *SQLContainerGetProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for SQLContainerGetResults. -func (scgr SQLContainerGetResults) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if scgr.SQLContainerGetProperties != nil { - objectMap["properties"] = scgr.SQLContainerGetProperties - } - if scgr.Location != nil { - objectMap["location"] = scgr.Location - } - if scgr.Tags != nil { - objectMap["tags"] = scgr.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for SQLContainerGetResults struct. -func (scgr *SQLContainerGetResults) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var SQLContainerGetProperties SQLContainerGetProperties - err = json.Unmarshal(*v, &SQLContainerGetProperties) - if err != nil { - return err - } - scgr.SQLContainerGetProperties = &SQLContainerGetProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - scgr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - scgr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - scgr.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - scgr.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - scgr.Tags = tags - } - } - } - - return nil -} - -// SQLContainerListResult the List operation response, that contains the containers and their properties. -type SQLContainerListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of containers and their properties. - Value *[]SQLContainerGetResults `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for SQLContainerListResult. -func (sclr SQLContainerListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// SQLContainerResource cosmos DB SQL container resource object -type SQLContainerResource struct { - // ID - Name of the Cosmos DB SQL container - ID *string `json:"id,omitempty"` - // IndexingPolicy - The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the container - IndexingPolicy *IndexingPolicy `json:"indexingPolicy,omitempty"` - // PartitionKey - The configuration of the partition key to be used for partitioning data into multiple partitions - PartitionKey *ContainerPartitionKey `json:"partitionKey,omitempty"` - // DefaultTTL - Default time to live - DefaultTTL *int32 `json:"defaultTtl,omitempty"` - // UniqueKeyPolicy - The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. - UniqueKeyPolicy *UniqueKeyPolicy `json:"uniqueKeyPolicy,omitempty"` - // ConflictResolutionPolicy - The conflict resolution policy for the container. - ConflictResolutionPolicy *ConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"` - // AnalyticalStorageTTL - Analytical TTL. - AnalyticalStorageTTL *int64 `json:"analyticalStorageTtl,omitempty"` -} - -// SQLDatabaseCreateUpdateParameters parameters to create and update Cosmos DB SQL database. -type SQLDatabaseCreateUpdateParameters struct { - // SQLDatabaseCreateUpdateProperties - Properties to create and update Azure Cosmos DB SQL database. - *SQLDatabaseCreateUpdateProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for SQLDatabaseCreateUpdateParameters. -func (sdcup SQLDatabaseCreateUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if sdcup.SQLDatabaseCreateUpdateProperties != nil { - objectMap["properties"] = sdcup.SQLDatabaseCreateUpdateProperties - } - if sdcup.Location != nil { - objectMap["location"] = sdcup.Location - } - if sdcup.Tags != nil { - objectMap["tags"] = sdcup.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for SQLDatabaseCreateUpdateParameters struct. -func (sdcup *SQLDatabaseCreateUpdateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var SQLDatabaseCreateUpdateProperties SQLDatabaseCreateUpdateProperties - err = json.Unmarshal(*v, &SQLDatabaseCreateUpdateProperties) - if err != nil { - return err - } - sdcup.SQLDatabaseCreateUpdateProperties = &SQLDatabaseCreateUpdateProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - sdcup.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - sdcup.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - sdcup.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - sdcup.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - sdcup.Tags = tags - } - } - } - - return nil -} - -// SQLDatabaseCreateUpdateProperties properties to create and update Azure Cosmos DB SQL database. -type SQLDatabaseCreateUpdateProperties struct { - // Resource - The standard JSON format of a SQL database - Resource *SQLDatabaseResource `json:"resource,omitempty"` - // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - Options *CreateUpdateOptions `json:"options,omitempty"` -} - -// SQLDatabaseGetProperties the properties of an Azure Cosmos DB SQL database -type SQLDatabaseGetProperties struct { - Resource *SQLDatabaseGetPropertiesResource `json:"resource,omitempty"` - Options *SQLDatabaseGetPropertiesOptions `json:"options,omitempty"` -} - -// SQLDatabaseGetPropertiesOptions ... -type SQLDatabaseGetPropertiesOptions struct { - // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. - Throughput *int32 `json:"throughput,omitempty"` - // AutoscaleSettings - Specifies the Autoscale settings. - AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` -} - -// SQLDatabaseGetPropertiesResource ... -type SQLDatabaseGetPropertiesResource struct { - // ID - Name of the Cosmos DB SQL database - ID *string `json:"id,omitempty"` - // Rid - READ-ONLY; A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. - Ts *float64 `json:"_ts,omitempty"` - // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. - Etag *string `json:"_etag,omitempty"` - // Colls - A system generated property that specified the addressable path of the collections resource. - Colls *string `json:"_colls,omitempty"` - // Users - A system generated property that specifies the addressable path of the users resource. - Users *string `json:"_users,omitempty"` -} - -// MarshalJSON is the custom marshaler for SQLDatabaseGetPropertiesResource. -func (sdgp SQLDatabaseGetPropertiesResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if sdgp.ID != nil { - objectMap["id"] = sdgp.ID - } - if sdgp.Colls != nil { - objectMap["_colls"] = sdgp.Colls - } - if sdgp.Users != nil { - objectMap["_users"] = sdgp.Users - } - return json.Marshal(objectMap) -} - -// SQLDatabaseGetResults an Azure Cosmos DB SQL database. -type SQLDatabaseGetResults struct { - autorest.Response `json:"-"` - // SQLDatabaseGetProperties - The properties of an Azure Cosmos DB SQL database - *SQLDatabaseGetProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for SQLDatabaseGetResults. -func (sdgr SQLDatabaseGetResults) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if sdgr.SQLDatabaseGetProperties != nil { - objectMap["properties"] = sdgr.SQLDatabaseGetProperties - } - if sdgr.Location != nil { - objectMap["location"] = sdgr.Location - } - if sdgr.Tags != nil { - objectMap["tags"] = sdgr.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for SQLDatabaseGetResults struct. -func (sdgr *SQLDatabaseGetResults) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var SQLDatabaseGetProperties SQLDatabaseGetProperties - err = json.Unmarshal(*v, &SQLDatabaseGetProperties) - if err != nil { - return err - } - sdgr.SQLDatabaseGetProperties = &SQLDatabaseGetProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - sdgr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - sdgr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - sdgr.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - sdgr.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - sdgr.Tags = tags - } - } - } - - return nil -} - -// SQLDatabaseListResult the List operation response, that contains the SQL databases and their properties. -type SQLDatabaseListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of SQL databases and their properties. - Value *[]SQLDatabaseGetResults `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for SQLDatabaseListResult. -func (sdlr SQLDatabaseListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// SQLDatabaseResource cosmos DB SQL database resource object -type SQLDatabaseResource struct { - // ID - Name of the Cosmos DB SQL database - ID *string `json:"id,omitempty"` -} - -// SQLResourcesCreateUpdateSQLContainerFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type SQLResourcesCreateUpdateSQLContainerFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(SQLResourcesClient) (SQLContainerGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *SQLResourcesCreateUpdateSQLContainerFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for SQLResourcesCreateUpdateSQLContainerFuture.Result. -func (future *SQLResourcesCreateUpdateSQLContainerFuture) result(client SQLResourcesClient) (scgr SQLContainerGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLContainerFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - scgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesCreateUpdateSQLContainerFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if scgr.Response.Response, err = future.GetResult(sender); err == nil && scgr.Response.Response.StatusCode != http.StatusNoContent { - scgr, err = client.CreateUpdateSQLContainerResponder(scgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLContainerFuture", "Result", scgr.Response.Response, "Failure responding to request") - } - } - return -} - -// SQLResourcesCreateUpdateSQLDatabaseFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type SQLResourcesCreateUpdateSQLDatabaseFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(SQLResourcesClient) (SQLDatabaseGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *SQLResourcesCreateUpdateSQLDatabaseFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for SQLResourcesCreateUpdateSQLDatabaseFuture.Result. -func (future *SQLResourcesCreateUpdateSQLDatabaseFuture) result(client SQLResourcesClient) (sdgr SQLDatabaseGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLDatabaseFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - sdgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesCreateUpdateSQLDatabaseFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if sdgr.Response.Response, err = future.GetResult(sender); err == nil && sdgr.Response.Response.StatusCode != http.StatusNoContent { - sdgr, err = client.CreateUpdateSQLDatabaseResponder(sdgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLDatabaseFuture", "Result", sdgr.Response.Response, "Failure responding to request") - } - } - return -} - -// SQLResourcesCreateUpdateSQLRoleAssignmentFuture an abstraction for monitoring and retrieving the results -// of a long-running operation. -type SQLResourcesCreateUpdateSQLRoleAssignmentFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(SQLResourcesClient) (SQLRoleAssignmentGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *SQLResourcesCreateUpdateSQLRoleAssignmentFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for SQLResourcesCreateUpdateSQLRoleAssignmentFuture.Result. -func (future *SQLResourcesCreateUpdateSQLRoleAssignmentFuture) result(client SQLResourcesClient) (sragr SQLRoleAssignmentGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLRoleAssignmentFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - sragr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesCreateUpdateSQLRoleAssignmentFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if sragr.Response.Response, err = future.GetResult(sender); err == nil && sragr.Response.Response.StatusCode != http.StatusNoContent { - sragr, err = client.CreateUpdateSQLRoleAssignmentResponder(sragr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLRoleAssignmentFuture", "Result", sragr.Response.Response, "Failure responding to request") - } - } - return -} - -// SQLResourcesCreateUpdateSQLRoleDefinitionFuture an abstraction for monitoring and retrieving the results -// of a long-running operation. -type SQLResourcesCreateUpdateSQLRoleDefinitionFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(SQLResourcesClient) (SQLRoleDefinitionGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *SQLResourcesCreateUpdateSQLRoleDefinitionFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for SQLResourcesCreateUpdateSQLRoleDefinitionFuture.Result. -func (future *SQLResourcesCreateUpdateSQLRoleDefinitionFuture) result(client SQLResourcesClient) (srdgr SQLRoleDefinitionGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLRoleDefinitionFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - srdgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesCreateUpdateSQLRoleDefinitionFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if srdgr.Response.Response, err = future.GetResult(sender); err == nil && srdgr.Response.Response.StatusCode != http.StatusNoContent { - srdgr, err = client.CreateUpdateSQLRoleDefinitionResponder(srdgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLRoleDefinitionFuture", "Result", srdgr.Response.Response, "Failure responding to request") - } - } - return -} - -// SQLResourcesCreateUpdateSQLStoredProcedureFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type SQLResourcesCreateUpdateSQLStoredProcedureFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(SQLResourcesClient) (SQLStoredProcedureGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *SQLResourcesCreateUpdateSQLStoredProcedureFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for SQLResourcesCreateUpdateSQLStoredProcedureFuture.Result. -func (future *SQLResourcesCreateUpdateSQLStoredProcedureFuture) result(client SQLResourcesClient) (sspgr SQLStoredProcedureGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLStoredProcedureFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - sspgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesCreateUpdateSQLStoredProcedureFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if sspgr.Response.Response, err = future.GetResult(sender); err == nil && sspgr.Response.Response.StatusCode != http.StatusNoContent { - sspgr, err = client.CreateUpdateSQLStoredProcedureResponder(sspgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLStoredProcedureFuture", "Result", sspgr.Response.Response, "Failure responding to request") - } - } - return -} - -// SQLResourcesCreateUpdateSQLTriggerFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type SQLResourcesCreateUpdateSQLTriggerFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(SQLResourcesClient) (SQLTriggerGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *SQLResourcesCreateUpdateSQLTriggerFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for SQLResourcesCreateUpdateSQLTriggerFuture.Result. -func (future *SQLResourcesCreateUpdateSQLTriggerFuture) result(client SQLResourcesClient) (stgr SQLTriggerGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLTriggerFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - stgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesCreateUpdateSQLTriggerFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if stgr.Response.Response, err = future.GetResult(sender); err == nil && stgr.Response.Response.StatusCode != http.StatusNoContent { - stgr, err = client.CreateUpdateSQLTriggerResponder(stgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLTriggerFuture", "Result", stgr.Response.Response, "Failure responding to request") - } - } - return -} - -// SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(SQLResourcesClient) (SQLUserDefinedFunctionGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture.Result. -func (future *SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture) result(client SQLResourcesClient) (sudfgr SQLUserDefinedFunctionGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - sudfgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if sudfgr.Response.Response, err = future.GetResult(sender); err == nil && sudfgr.Response.Response.StatusCode != http.StatusNoContent { - sudfgr, err = client.CreateUpdateSQLUserDefinedFunctionResponder(sudfgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture", "Result", sudfgr.Response.Response, "Failure responding to request") - } - } - return -} - -// SQLResourcesDeleteSQLContainerFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type SQLResourcesDeleteSQLContainerFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(SQLResourcesClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *SQLResourcesDeleteSQLContainerFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for SQLResourcesDeleteSQLContainerFuture.Result. -func (future *SQLResourcesDeleteSQLContainerFuture) result(client SQLResourcesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesDeleteSQLContainerFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesDeleteSQLContainerFuture") - return - } - ar.Response = future.Response() - return -} - -// SQLResourcesDeleteSQLDatabaseFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type SQLResourcesDeleteSQLDatabaseFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(SQLResourcesClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *SQLResourcesDeleteSQLDatabaseFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for SQLResourcesDeleteSQLDatabaseFuture.Result. -func (future *SQLResourcesDeleteSQLDatabaseFuture) result(client SQLResourcesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesDeleteSQLDatabaseFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesDeleteSQLDatabaseFuture") - return - } - ar.Response = future.Response() - return -} - -// SQLResourcesDeleteSQLRoleAssignmentFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type SQLResourcesDeleteSQLRoleAssignmentFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(SQLResourcesClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *SQLResourcesDeleteSQLRoleAssignmentFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for SQLResourcesDeleteSQLRoleAssignmentFuture.Result. -func (future *SQLResourcesDeleteSQLRoleAssignmentFuture) result(client SQLResourcesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesDeleteSQLRoleAssignmentFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesDeleteSQLRoleAssignmentFuture") - return - } - ar.Response = future.Response() - return -} - -// SQLResourcesDeleteSQLRoleDefinitionFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type SQLResourcesDeleteSQLRoleDefinitionFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(SQLResourcesClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *SQLResourcesDeleteSQLRoleDefinitionFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for SQLResourcesDeleteSQLRoleDefinitionFuture.Result. -func (future *SQLResourcesDeleteSQLRoleDefinitionFuture) result(client SQLResourcesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesDeleteSQLRoleDefinitionFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesDeleteSQLRoleDefinitionFuture") - return - } - ar.Response = future.Response() - return -} - -// SQLResourcesDeleteSQLStoredProcedureFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type SQLResourcesDeleteSQLStoredProcedureFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(SQLResourcesClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *SQLResourcesDeleteSQLStoredProcedureFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for SQLResourcesDeleteSQLStoredProcedureFuture.Result. -func (future *SQLResourcesDeleteSQLStoredProcedureFuture) result(client SQLResourcesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesDeleteSQLStoredProcedureFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesDeleteSQLStoredProcedureFuture") - return - } - ar.Response = future.Response() - return -} - -// SQLResourcesDeleteSQLTriggerFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type SQLResourcesDeleteSQLTriggerFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(SQLResourcesClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *SQLResourcesDeleteSQLTriggerFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for SQLResourcesDeleteSQLTriggerFuture.Result. -func (future *SQLResourcesDeleteSQLTriggerFuture) result(client SQLResourcesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesDeleteSQLTriggerFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesDeleteSQLTriggerFuture") - return - } - ar.Response = future.Response() - return -} - -// SQLResourcesDeleteSQLUserDefinedFunctionFuture an abstraction for monitoring and retrieving the results -// of a long-running operation. -type SQLResourcesDeleteSQLUserDefinedFunctionFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(SQLResourcesClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *SQLResourcesDeleteSQLUserDefinedFunctionFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for SQLResourcesDeleteSQLUserDefinedFunctionFuture.Result. -func (future *SQLResourcesDeleteSQLUserDefinedFunctionFuture) result(client SQLResourcesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesDeleteSQLUserDefinedFunctionFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesDeleteSQLUserDefinedFunctionFuture") - return - } - ar.Response = future.Response() - return -} - -// SQLResourcesMigrateSQLContainerToAutoscaleFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type SQLResourcesMigrateSQLContainerToAutoscaleFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(SQLResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *SQLResourcesMigrateSQLContainerToAutoscaleFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for SQLResourcesMigrateSQLContainerToAutoscaleFuture.Result. -func (future *SQLResourcesMigrateSQLContainerToAutoscaleFuture) result(client SQLResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLContainerToAutoscaleFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesMigrateSQLContainerToAutoscaleFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.MigrateSQLContainerToAutoscaleResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLContainerToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// SQLResourcesMigrateSQLContainerToManualThroughputFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type SQLResourcesMigrateSQLContainerToManualThroughputFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(SQLResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *SQLResourcesMigrateSQLContainerToManualThroughputFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for SQLResourcesMigrateSQLContainerToManualThroughputFuture.Result. -func (future *SQLResourcesMigrateSQLContainerToManualThroughputFuture) result(client SQLResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLContainerToManualThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesMigrateSQLContainerToManualThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.MigrateSQLContainerToManualThroughputResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLContainerToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// SQLResourcesMigrateSQLDatabaseToAutoscaleFuture an abstraction for monitoring and retrieving the results -// of a long-running operation. -type SQLResourcesMigrateSQLDatabaseToAutoscaleFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(SQLResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *SQLResourcesMigrateSQLDatabaseToAutoscaleFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for SQLResourcesMigrateSQLDatabaseToAutoscaleFuture.Result. -func (future *SQLResourcesMigrateSQLDatabaseToAutoscaleFuture) result(client SQLResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLDatabaseToAutoscaleFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesMigrateSQLDatabaseToAutoscaleFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.MigrateSQLDatabaseToAutoscaleResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLDatabaseToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// SQLResourcesMigrateSQLDatabaseToManualThroughputFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type SQLResourcesMigrateSQLDatabaseToManualThroughputFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(SQLResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *SQLResourcesMigrateSQLDatabaseToManualThroughputFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for SQLResourcesMigrateSQLDatabaseToManualThroughputFuture.Result. -func (future *SQLResourcesMigrateSQLDatabaseToManualThroughputFuture) result(client SQLResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLDatabaseToManualThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesMigrateSQLDatabaseToManualThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.MigrateSQLDatabaseToManualThroughputResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesMigrateSQLDatabaseToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// SQLResourcesRetrieveContinuousBackupInformationFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type SQLResourcesRetrieveContinuousBackupInformationFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(SQLResourcesClient) (BackupInformation, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *SQLResourcesRetrieveContinuousBackupInformationFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for SQLResourcesRetrieveContinuousBackupInformationFuture.Result. -func (future *SQLResourcesRetrieveContinuousBackupInformationFuture) result(client SQLResourcesClient) (bi BackupInformation, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesRetrieveContinuousBackupInformationFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - bi.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesRetrieveContinuousBackupInformationFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if bi.Response.Response, err = future.GetResult(sender); err == nil && bi.Response.Response.StatusCode != http.StatusNoContent { - bi, err = client.RetrieveContinuousBackupInformationResponder(bi.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesRetrieveContinuousBackupInformationFuture", "Result", bi.Response.Response, "Failure responding to request") - } - } - return -} - -// SQLResourcesUpdateSQLContainerThroughputFuture an abstraction for monitoring and retrieving the results -// of a long-running operation. -type SQLResourcesUpdateSQLContainerThroughputFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(SQLResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *SQLResourcesUpdateSQLContainerThroughputFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for SQLResourcesUpdateSQLContainerThroughputFuture.Result. -func (future *SQLResourcesUpdateSQLContainerThroughputFuture) result(client SQLResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesUpdateSQLContainerThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesUpdateSQLContainerThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.UpdateSQLContainerThroughputResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesUpdateSQLContainerThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// SQLResourcesUpdateSQLDatabaseThroughputFuture an abstraction for monitoring and retrieving the results -// of a long-running operation. -type SQLResourcesUpdateSQLDatabaseThroughputFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(SQLResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *SQLResourcesUpdateSQLDatabaseThroughputFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for SQLResourcesUpdateSQLDatabaseThroughputFuture.Result. -func (future *SQLResourcesUpdateSQLDatabaseThroughputFuture) result(client SQLResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesUpdateSQLDatabaseThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesUpdateSQLDatabaseThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.UpdateSQLDatabaseThroughputResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesUpdateSQLDatabaseThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// SQLRoleAssignmentCreateUpdateParameters parameters to create and update an Azure Cosmos DB SQL Role -// Assignment. -type SQLRoleAssignmentCreateUpdateParameters struct { - // SQLRoleAssignmentResource - Properties to create and update an Azure Cosmos DB SQL Role Assignment. - *SQLRoleAssignmentResource `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for SQLRoleAssignmentCreateUpdateParameters. -func (sracup SQLRoleAssignmentCreateUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if sracup.SQLRoleAssignmentResource != nil { - objectMap["properties"] = sracup.SQLRoleAssignmentResource - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for SQLRoleAssignmentCreateUpdateParameters struct. -func (sracup *SQLRoleAssignmentCreateUpdateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var SQLRoleAssignmentResource SQLRoleAssignmentResource - err = json.Unmarshal(*v, &SQLRoleAssignmentResource) - if err != nil { - return err - } - sracup.SQLRoleAssignmentResource = &SQLRoleAssignmentResource - } - } - } - - return nil -} - -// SQLRoleAssignmentGetResults an Azure Cosmos DB Role Assignment -type SQLRoleAssignmentGetResults struct { - autorest.Response `json:"-"` - // SQLRoleAssignmentResource - Properties related to the Role Assignment. - *SQLRoleAssignmentResource `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the database account. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the database account. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for SQLRoleAssignmentGetResults. -func (sragr SQLRoleAssignmentGetResults) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if sragr.SQLRoleAssignmentResource != nil { - objectMap["properties"] = sragr.SQLRoleAssignmentResource - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for SQLRoleAssignmentGetResults struct. -func (sragr *SQLRoleAssignmentGetResults) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var SQLRoleAssignmentResource SQLRoleAssignmentResource - err = json.Unmarshal(*v, &SQLRoleAssignmentResource) - if err != nil { - return err - } - sragr.SQLRoleAssignmentResource = &SQLRoleAssignmentResource - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - sragr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - sragr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - sragr.Type = &typeVar - } - } - } - - return nil -} - -// SQLRoleAssignmentListResult the relevant Role Assignments. -type SQLRoleAssignmentListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of Role Assignments and their properties - Value *[]SQLRoleAssignmentGetResults `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for SQLRoleAssignmentListResult. -func (sralr SQLRoleAssignmentListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// SQLRoleAssignmentResource azure Cosmos DB SQL Role Assignment resource object. -type SQLRoleAssignmentResource struct { - // RoleDefinitionID - The unique identifier for the associated Role Definition. - RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` - // Scope - The data plane resource path for which access is being granted through this Role Assignment. - Scope *string `json:"scope,omitempty"` - // PrincipalID - The unique identifier for the associated AAD principal in the AAD graph to which access is being granted through this Role Assignment. Tenant ID for the principal is inferred using the tenant associated with the subscription. - PrincipalID *string `json:"principalId,omitempty"` -} - -// SQLRoleDefinitionCreateUpdateParameters parameters to create and update an Azure Cosmos DB SQL Role -// Definition. -type SQLRoleDefinitionCreateUpdateParameters struct { - // SQLRoleDefinitionResource - Properties to create and update an Azure Cosmos DB SQL Role Definition. - *SQLRoleDefinitionResource `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for SQLRoleDefinitionCreateUpdateParameters. -func (srdcup SQLRoleDefinitionCreateUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if srdcup.SQLRoleDefinitionResource != nil { - objectMap["properties"] = srdcup.SQLRoleDefinitionResource - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for SQLRoleDefinitionCreateUpdateParameters struct. -func (srdcup *SQLRoleDefinitionCreateUpdateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var SQLRoleDefinitionResource SQLRoleDefinitionResource - err = json.Unmarshal(*v, &SQLRoleDefinitionResource) - if err != nil { - return err - } - srdcup.SQLRoleDefinitionResource = &SQLRoleDefinitionResource - } - } - } - - return nil -} - -// SQLRoleDefinitionGetResults an Azure Cosmos DB SQL Role Definition. -type SQLRoleDefinitionGetResults struct { - autorest.Response `json:"-"` - // SQLRoleDefinitionResource - Properties related to the Role Definition. - *SQLRoleDefinitionResource `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the database account. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the database account. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for SQLRoleDefinitionGetResults. -func (srdgr SQLRoleDefinitionGetResults) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if srdgr.SQLRoleDefinitionResource != nil { - objectMap["properties"] = srdgr.SQLRoleDefinitionResource - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for SQLRoleDefinitionGetResults struct. -func (srdgr *SQLRoleDefinitionGetResults) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var SQLRoleDefinitionResource SQLRoleDefinitionResource - err = json.Unmarshal(*v, &SQLRoleDefinitionResource) - if err != nil { - return err - } - srdgr.SQLRoleDefinitionResource = &SQLRoleDefinitionResource - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - srdgr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - srdgr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - srdgr.Type = &typeVar - } - } - } - - return nil -} - -// SQLRoleDefinitionListResult the relevant Role Definitions. -type SQLRoleDefinitionListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of Role Definitions and their properties. - Value *[]SQLRoleDefinitionGetResults `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for SQLRoleDefinitionListResult. -func (srdlr SQLRoleDefinitionListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// SQLRoleDefinitionResource azure Cosmos DB SQL Role Definition resource object. -type SQLRoleDefinitionResource struct { - // RoleName - A user-friendly name for the Role Definition. Must be unique for the database account. - RoleName *string `json:"roleName,omitempty"` - // Type - Indicates whether the Role Definition was built-in or user created. Possible values include: 'RoleDefinitionTypeBuiltInRole', 'RoleDefinitionTypeCustomRole' - Type RoleDefinitionType `json:"type,omitempty"` - // AssignableScopes - A set of fully qualified Scopes at or below which Role Assignments may be created using this Role Definition. This will allow application of this Role Definition on the entire database account or any underlying Database / Collection. Must have at least one element. Scopes higher than Database account are not enforceable as assignable Scopes. Note that resources referenced in assignable Scopes need not exist. - AssignableScopes *[]string `json:"assignableScopes,omitempty"` - // Permissions - The set of operations allowed through this Role Definition. - Permissions *[]Permission `json:"permissions,omitempty"` -} - -// SQLStoredProcedureCreateUpdateParameters parameters to create and update Cosmos DB storedProcedure. -type SQLStoredProcedureCreateUpdateParameters struct { - // SQLStoredProcedureCreateUpdateProperties - Properties to create and update Azure Cosmos DB storedProcedure. - *SQLStoredProcedureCreateUpdateProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for SQLStoredProcedureCreateUpdateParameters. -func (sspcup SQLStoredProcedureCreateUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if sspcup.SQLStoredProcedureCreateUpdateProperties != nil { - objectMap["properties"] = sspcup.SQLStoredProcedureCreateUpdateProperties - } - if sspcup.Location != nil { - objectMap["location"] = sspcup.Location - } - if sspcup.Tags != nil { - objectMap["tags"] = sspcup.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for SQLStoredProcedureCreateUpdateParameters struct. -func (sspcup *SQLStoredProcedureCreateUpdateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var SQLStoredProcedureCreateUpdateProperties SQLStoredProcedureCreateUpdateProperties - err = json.Unmarshal(*v, &SQLStoredProcedureCreateUpdateProperties) - if err != nil { - return err - } - sspcup.SQLStoredProcedureCreateUpdateProperties = &SQLStoredProcedureCreateUpdateProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - sspcup.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - sspcup.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - sspcup.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - sspcup.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - sspcup.Tags = tags - } - } - } - - return nil -} - -// SQLStoredProcedureCreateUpdateProperties properties to create and update Azure Cosmos DB -// storedProcedure. -type SQLStoredProcedureCreateUpdateProperties struct { - // Resource - The standard JSON format of a storedProcedure - Resource *SQLStoredProcedureResource `json:"resource,omitempty"` - // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - Options *CreateUpdateOptions `json:"options,omitempty"` -} - -// SQLStoredProcedureGetProperties the properties of an Azure Cosmos DB StoredProcedure -type SQLStoredProcedureGetProperties struct { - Resource *SQLStoredProcedureGetPropertiesResource `json:"resource,omitempty"` -} - -// SQLStoredProcedureGetPropertiesResource ... -type SQLStoredProcedureGetPropertiesResource struct { - // ID - Name of the Cosmos DB SQL storedProcedure - ID *string `json:"id,omitempty"` - // Body - Body of the Stored Procedure - Body *string `json:"body,omitempty"` - // Rid - READ-ONLY; A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. - Ts *float64 `json:"_ts,omitempty"` - // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. - Etag *string `json:"_etag,omitempty"` -} - -// MarshalJSON is the custom marshaler for SQLStoredProcedureGetPropertiesResource. -func (sspgp SQLStoredProcedureGetPropertiesResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if sspgp.ID != nil { - objectMap["id"] = sspgp.ID - } - if sspgp.Body != nil { - objectMap["body"] = sspgp.Body - } - return json.Marshal(objectMap) -} - -// SQLStoredProcedureGetResults an Azure Cosmos DB storedProcedure. -type SQLStoredProcedureGetResults struct { - autorest.Response `json:"-"` - // SQLStoredProcedureGetProperties - The properties of an Azure Cosmos DB storedProcedure - *SQLStoredProcedureGetProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for SQLStoredProcedureGetResults. -func (sspgr SQLStoredProcedureGetResults) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if sspgr.SQLStoredProcedureGetProperties != nil { - objectMap["properties"] = sspgr.SQLStoredProcedureGetProperties - } - if sspgr.Location != nil { - objectMap["location"] = sspgr.Location - } - if sspgr.Tags != nil { - objectMap["tags"] = sspgr.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for SQLStoredProcedureGetResults struct. -func (sspgr *SQLStoredProcedureGetResults) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var SQLStoredProcedureGetProperties SQLStoredProcedureGetProperties - err = json.Unmarshal(*v, &SQLStoredProcedureGetProperties) - if err != nil { - return err - } - sspgr.SQLStoredProcedureGetProperties = &SQLStoredProcedureGetProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - sspgr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - sspgr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - sspgr.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - sspgr.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - sspgr.Tags = tags - } - } - } - - return nil -} - -// SQLStoredProcedureListResult the List operation response, that contains the storedProcedures and their -// properties. -type SQLStoredProcedureListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of storedProcedures and their properties. - Value *[]SQLStoredProcedureGetResults `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for SQLStoredProcedureListResult. -func (ssplr SQLStoredProcedureListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// SQLStoredProcedureResource cosmos DB SQL storedProcedure resource object -type SQLStoredProcedureResource struct { - // ID - Name of the Cosmos DB SQL storedProcedure - ID *string `json:"id,omitempty"` - // Body - Body of the Stored Procedure - Body *string `json:"body,omitempty"` -} - -// SQLTriggerCreateUpdateParameters parameters to create and update Cosmos DB trigger. -type SQLTriggerCreateUpdateParameters struct { - // SQLTriggerCreateUpdateProperties - Properties to create and update Azure Cosmos DB trigger. - *SQLTriggerCreateUpdateProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for SQLTriggerCreateUpdateParameters. -func (stcup SQLTriggerCreateUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if stcup.SQLTriggerCreateUpdateProperties != nil { - objectMap["properties"] = stcup.SQLTriggerCreateUpdateProperties - } - if stcup.Location != nil { - objectMap["location"] = stcup.Location - } - if stcup.Tags != nil { - objectMap["tags"] = stcup.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for SQLTriggerCreateUpdateParameters struct. -func (stcup *SQLTriggerCreateUpdateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var SQLTriggerCreateUpdateProperties SQLTriggerCreateUpdateProperties - err = json.Unmarshal(*v, &SQLTriggerCreateUpdateProperties) - if err != nil { - return err - } - stcup.SQLTriggerCreateUpdateProperties = &SQLTriggerCreateUpdateProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - stcup.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - stcup.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - stcup.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - stcup.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - stcup.Tags = tags - } - } - } - - return nil -} - -// SQLTriggerCreateUpdateProperties properties to create and update Azure Cosmos DB trigger. -type SQLTriggerCreateUpdateProperties struct { - // Resource - The standard JSON format of a trigger - Resource *SQLTriggerResource `json:"resource,omitempty"` - // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - Options *CreateUpdateOptions `json:"options,omitempty"` -} - -// SQLTriggerGetProperties the properties of an Azure Cosmos DB trigger -type SQLTriggerGetProperties struct { - Resource *SQLTriggerGetPropertiesResource `json:"resource,omitempty"` -} - -// SQLTriggerGetPropertiesResource ... -type SQLTriggerGetPropertiesResource struct { - // ID - Name of the Cosmos DB SQL trigger - ID *string `json:"id,omitempty"` - // Body - Body of the Trigger - Body *string `json:"body,omitempty"` - // TriggerType - Type of the Trigger. Possible values include: 'TriggerTypePre', 'TriggerTypePost' - TriggerType TriggerType `json:"triggerType,omitempty"` - // TriggerOperation - The operation the trigger is associated with. Possible values include: 'TriggerOperationAll', 'TriggerOperationCreate', 'TriggerOperationUpdate', 'TriggerOperationDelete', 'TriggerOperationReplace' - TriggerOperation TriggerOperation `json:"triggerOperation,omitempty"` - // Rid - READ-ONLY; A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. - Ts *float64 `json:"_ts,omitempty"` - // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. - Etag *string `json:"_etag,omitempty"` -} - -// MarshalJSON is the custom marshaler for SQLTriggerGetPropertiesResource. -func (stgp SQLTriggerGetPropertiesResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if stgp.ID != nil { - objectMap["id"] = stgp.ID - } - if stgp.Body != nil { - objectMap["body"] = stgp.Body - } - if stgp.TriggerType != "" { - objectMap["triggerType"] = stgp.TriggerType - } - if stgp.TriggerOperation != "" { - objectMap["triggerOperation"] = stgp.TriggerOperation - } - return json.Marshal(objectMap) -} - -// SQLTriggerGetResults an Azure Cosmos DB trigger. -type SQLTriggerGetResults struct { - autorest.Response `json:"-"` - // SQLTriggerGetProperties - The properties of an Azure Cosmos DB trigger - *SQLTriggerGetProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for SQLTriggerGetResults. -func (stgr SQLTriggerGetResults) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if stgr.SQLTriggerGetProperties != nil { - objectMap["properties"] = stgr.SQLTriggerGetProperties - } - if stgr.Location != nil { - objectMap["location"] = stgr.Location - } - if stgr.Tags != nil { - objectMap["tags"] = stgr.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for SQLTriggerGetResults struct. -func (stgr *SQLTriggerGetResults) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var SQLTriggerGetProperties SQLTriggerGetProperties - err = json.Unmarshal(*v, &SQLTriggerGetProperties) - if err != nil { - return err - } - stgr.SQLTriggerGetProperties = &SQLTriggerGetProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - stgr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - stgr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - stgr.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - stgr.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - stgr.Tags = tags - } - } - } - - return nil -} - -// SQLTriggerListResult the List operation response, that contains the triggers and their properties. -type SQLTriggerListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of triggers and their properties. - Value *[]SQLTriggerGetResults `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for SQLTriggerListResult. -func (stlr SQLTriggerListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// SQLTriggerResource cosmos DB SQL trigger resource object -type SQLTriggerResource struct { - // ID - Name of the Cosmos DB SQL trigger - ID *string `json:"id,omitempty"` - // Body - Body of the Trigger - Body *string `json:"body,omitempty"` - // TriggerType - Type of the Trigger. Possible values include: 'TriggerTypePre', 'TriggerTypePost' - TriggerType TriggerType `json:"triggerType,omitempty"` - // TriggerOperation - The operation the trigger is associated with. Possible values include: 'TriggerOperationAll', 'TriggerOperationCreate', 'TriggerOperationUpdate', 'TriggerOperationDelete', 'TriggerOperationReplace' - TriggerOperation TriggerOperation `json:"triggerOperation,omitempty"` -} - -// SQLUserDefinedFunctionCreateUpdateParameters parameters to create and update Cosmos DB -// userDefinedFunction. -type SQLUserDefinedFunctionCreateUpdateParameters struct { - // SQLUserDefinedFunctionCreateUpdateProperties - Properties to create and update Azure Cosmos DB userDefinedFunction. - *SQLUserDefinedFunctionCreateUpdateProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for SQLUserDefinedFunctionCreateUpdateParameters. -func (sudfcup SQLUserDefinedFunctionCreateUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if sudfcup.SQLUserDefinedFunctionCreateUpdateProperties != nil { - objectMap["properties"] = sudfcup.SQLUserDefinedFunctionCreateUpdateProperties - } - if sudfcup.Location != nil { - objectMap["location"] = sudfcup.Location - } - if sudfcup.Tags != nil { - objectMap["tags"] = sudfcup.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for SQLUserDefinedFunctionCreateUpdateParameters struct. -func (sudfcup *SQLUserDefinedFunctionCreateUpdateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var SQLUserDefinedFunctionCreateUpdateProperties SQLUserDefinedFunctionCreateUpdateProperties - err = json.Unmarshal(*v, &SQLUserDefinedFunctionCreateUpdateProperties) - if err != nil { - return err - } - sudfcup.SQLUserDefinedFunctionCreateUpdateProperties = &SQLUserDefinedFunctionCreateUpdateProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - sudfcup.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - sudfcup.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - sudfcup.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - sudfcup.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - sudfcup.Tags = tags - } - } - } - - return nil -} - -// SQLUserDefinedFunctionCreateUpdateProperties properties to create and update Azure Cosmos DB -// userDefinedFunction. -type SQLUserDefinedFunctionCreateUpdateProperties struct { - // Resource - The standard JSON format of a userDefinedFunction - Resource *SQLUserDefinedFunctionResource `json:"resource,omitempty"` - // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - Options *CreateUpdateOptions `json:"options,omitempty"` -} - -// SQLUserDefinedFunctionGetProperties the properties of an Azure Cosmos DB userDefinedFunction -type SQLUserDefinedFunctionGetProperties struct { - Resource *SQLUserDefinedFunctionGetPropertiesResource `json:"resource,omitempty"` -} - -// SQLUserDefinedFunctionGetPropertiesResource ... -type SQLUserDefinedFunctionGetPropertiesResource struct { - // ID - Name of the Cosmos DB SQL userDefinedFunction - ID *string `json:"id,omitempty"` - // Body - Body of the User Defined Function - Body *string `json:"body,omitempty"` - // Rid - READ-ONLY; A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. - Ts *float64 `json:"_ts,omitempty"` - // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. - Etag *string `json:"_etag,omitempty"` -} - -// MarshalJSON is the custom marshaler for SQLUserDefinedFunctionGetPropertiesResource. -func (sudfgp SQLUserDefinedFunctionGetPropertiesResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if sudfgp.ID != nil { - objectMap["id"] = sudfgp.ID - } - if sudfgp.Body != nil { - objectMap["body"] = sudfgp.Body - } - return json.Marshal(objectMap) -} - -// SQLUserDefinedFunctionGetResults an Azure Cosmos DB userDefinedFunction. -type SQLUserDefinedFunctionGetResults struct { - autorest.Response `json:"-"` - // SQLUserDefinedFunctionGetProperties - The properties of an Azure Cosmos DB userDefinedFunction - *SQLUserDefinedFunctionGetProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for SQLUserDefinedFunctionGetResults. -func (sudfgr SQLUserDefinedFunctionGetResults) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if sudfgr.SQLUserDefinedFunctionGetProperties != nil { - objectMap["properties"] = sudfgr.SQLUserDefinedFunctionGetProperties - } - if sudfgr.Location != nil { - objectMap["location"] = sudfgr.Location - } - if sudfgr.Tags != nil { - objectMap["tags"] = sudfgr.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for SQLUserDefinedFunctionGetResults struct. -func (sudfgr *SQLUserDefinedFunctionGetResults) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var SQLUserDefinedFunctionGetProperties SQLUserDefinedFunctionGetProperties - err = json.Unmarshal(*v, &SQLUserDefinedFunctionGetProperties) - if err != nil { - return err - } - sudfgr.SQLUserDefinedFunctionGetProperties = &SQLUserDefinedFunctionGetProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - sudfgr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - sudfgr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - sudfgr.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - sudfgr.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - sudfgr.Tags = tags - } - } - } - - return nil -} - -// SQLUserDefinedFunctionListResult the List operation response, that contains the userDefinedFunctions and -// their properties. -type SQLUserDefinedFunctionListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of userDefinedFunctions and their properties. - Value *[]SQLUserDefinedFunctionGetResults `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for SQLUserDefinedFunctionListResult. -func (sudflr SQLUserDefinedFunctionListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// SQLUserDefinedFunctionResource cosmos DB SQL userDefinedFunction resource object -type SQLUserDefinedFunctionResource struct { - // ID - Name of the Cosmos DB SQL userDefinedFunction - ID *string `json:"id,omitempty"` - // Body - Body of the User Defined Function - Body *string `json:"body,omitempty"` -} - -// SystemData metadata pertaining to creation and last modification of the resource. -type SystemData struct { - // CreatedBy - The identity that created the resource. - CreatedBy *string `json:"createdBy,omitempty"` - // CreatedByType - The type of identity that created the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' - CreatedByType CreatedByType `json:"createdByType,omitempty"` - // CreatedAt - The timestamp of resource creation (UTC). - CreatedAt *date.Time `json:"createdAt,omitempty"` - // LastModifiedBy - The identity that last modified the resource. - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` - // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' - LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` - // LastModifiedAt - The timestamp of resource last modification (UTC) - LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` -} - -// TableCreateUpdateParameters parameters to create and update Cosmos DB Table. -type TableCreateUpdateParameters struct { - // TableCreateUpdateProperties - Properties to create and update Azure Cosmos DB Table. - *TableCreateUpdateProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for TableCreateUpdateParameters. -func (tcup TableCreateUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if tcup.TableCreateUpdateProperties != nil { - objectMap["properties"] = tcup.TableCreateUpdateProperties - } - if tcup.Location != nil { - objectMap["location"] = tcup.Location - } - if tcup.Tags != nil { - objectMap["tags"] = tcup.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for TableCreateUpdateParameters struct. -func (tcup *TableCreateUpdateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var tableCreateUpdateProperties TableCreateUpdateProperties - err = json.Unmarshal(*v, &tableCreateUpdateProperties) - if err != nil { - return err - } - tcup.TableCreateUpdateProperties = &tableCreateUpdateProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - tcup.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - tcup.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - tcup.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - tcup.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - tcup.Tags = tags - } - } - } - - return nil -} - -// TableCreateUpdateProperties properties to create and update Azure Cosmos DB Table. -type TableCreateUpdateProperties struct { - // Resource - The standard JSON format of a Table - Resource *TableResource `json:"resource,omitempty"` - // Options - A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. - Options *CreateUpdateOptions `json:"options,omitempty"` -} - -// TableGetProperties the properties of an Azure Cosmos Table -type TableGetProperties struct { - Resource *TableGetPropertiesResource `json:"resource,omitempty"` - Options *TableGetPropertiesOptions `json:"options,omitempty"` -} - -// TableGetPropertiesOptions ... -type TableGetPropertiesOptions struct { - // Throughput - Value of the Cosmos DB resource throughput or autoscaleSettings. Use the ThroughputSetting resource when retrieving offer details. - Throughput *int32 `json:"throughput,omitempty"` - // AutoscaleSettings - Specifies the Autoscale settings. - AutoscaleSettings *AutoscaleSettings `json:"autoscaleSettings,omitempty"` -} - -// TableGetPropertiesResource ... -type TableGetPropertiesResource struct { - // ID - Name of the Cosmos DB table - ID *string `json:"id,omitempty"` - // Rid - READ-ONLY; A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. - Ts *float64 `json:"_ts,omitempty"` - // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. - Etag *string `json:"_etag,omitempty"` -} - -// MarshalJSON is the custom marshaler for TableGetPropertiesResource. -func (tgp TableGetPropertiesResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if tgp.ID != nil { - objectMap["id"] = tgp.ID - } - return json.Marshal(objectMap) -} - -// TableGetResults an Azure Cosmos DB Table. -type TableGetResults struct { - autorest.Response `json:"-"` - // TableGetProperties - The properties of an Azure Cosmos DB Table - *TableGetProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for TableGetResults. -func (tgr TableGetResults) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if tgr.TableGetProperties != nil { - objectMap["properties"] = tgr.TableGetProperties - } - if tgr.Location != nil { - objectMap["location"] = tgr.Location - } - if tgr.Tags != nil { - objectMap["tags"] = tgr.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for TableGetResults struct. -func (tgr *TableGetResults) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var tableGetProperties TableGetProperties - err = json.Unmarshal(*v, &tableGetProperties) - if err != nil { - return err - } - tgr.TableGetProperties = &tableGetProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - tgr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - tgr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - tgr.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - tgr.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - tgr.Tags = tags - } - } - } - - return nil -} - -// TableListResult the List operation response, that contains the Table and their properties. -type TableListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of Table and their properties. - Value *[]TableGetResults `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for TableListResult. -func (tlr TableListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// TableResource cosmos DB table resource object -type TableResource struct { - // ID - Name of the Cosmos DB table - ID *string `json:"id,omitempty"` -} - -// TableResourcesCreateUpdateTableFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type TableResourcesCreateUpdateTableFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(TableResourcesClient) (TableGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *TableResourcesCreateUpdateTableFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for TableResourcesCreateUpdateTableFuture.Result. -func (future *TableResourcesCreateUpdateTableFuture) result(client TableResourcesClient) (tgr TableGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesCreateUpdateTableFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.TableResourcesCreateUpdateTableFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tgr.Response.Response, err = future.GetResult(sender); err == nil && tgr.Response.Response.StatusCode != http.StatusNoContent { - tgr, err = client.CreateUpdateTableResponder(tgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesCreateUpdateTableFuture", "Result", tgr.Response.Response, "Failure responding to request") - } - } - return -} - -// TableResourcesDeleteTableFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type TableResourcesDeleteTableFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(TableResourcesClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *TableResourcesDeleteTableFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for TableResourcesDeleteTableFuture.Result. -func (future *TableResourcesDeleteTableFuture) result(client TableResourcesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesDeleteTableFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.TableResourcesDeleteTableFuture") - return - } - ar.Response = future.Response() - return -} - -// TableResourcesMigrateTableToAutoscaleFuture an abstraction for monitoring and retrieving the results of -// a long-running operation. -type TableResourcesMigrateTableToAutoscaleFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(TableResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *TableResourcesMigrateTableToAutoscaleFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for TableResourcesMigrateTableToAutoscaleFuture.Result. -func (future *TableResourcesMigrateTableToAutoscaleFuture) result(client TableResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesMigrateTableToAutoscaleFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.TableResourcesMigrateTableToAutoscaleFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.MigrateTableToAutoscaleResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesMigrateTableToAutoscaleFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// TableResourcesMigrateTableToManualThroughputFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type TableResourcesMigrateTableToManualThroughputFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(TableResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *TableResourcesMigrateTableToManualThroughputFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for TableResourcesMigrateTableToManualThroughputFuture.Result. -func (future *TableResourcesMigrateTableToManualThroughputFuture) result(client TableResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesMigrateTableToManualThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.TableResourcesMigrateTableToManualThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.MigrateTableToManualThroughputResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesMigrateTableToManualThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// TableResourcesUpdateTableThroughputFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type TableResourcesUpdateTableThroughputFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(TableResourcesClient) (ThroughputSettingsGetResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *TableResourcesUpdateTableThroughputFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for TableResourcesUpdateTableThroughputFuture.Result. -func (future *TableResourcesUpdateTableThroughputFuture) result(client TableResourcesClient) (tsgr ThroughputSettingsGetResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesUpdateTableThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - tsgr.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("documentdb.TableResourcesUpdateTableThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if tsgr.Response.Response, err = future.GetResult(sender); err == nil && tsgr.Response.Response.StatusCode != http.StatusNoContent { - tsgr, err = client.UpdateTableThroughputResponder(tsgr.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesUpdateTableThroughputFuture", "Result", tsgr.Response.Response, "Failure responding to request") - } - } - return -} - -// ThroughputPolicyResource cosmos DB resource throughput policy -type ThroughputPolicyResource struct { - // IsEnabled - Determines whether the ThroughputPolicy is active or not - IsEnabled *bool `json:"isEnabled,omitempty"` - // IncrementPercent - Represents the percentage by which throughput can increase every time throughput policy kicks in. - IncrementPercent *int32 `json:"incrementPercent,omitempty"` -} - -// ThroughputSettingsGetProperties the properties of an Azure Cosmos DB resource throughput -type ThroughputSettingsGetProperties struct { - Resource *ThroughputSettingsGetPropertiesResource `json:"resource,omitempty"` -} - -// ThroughputSettingsGetPropertiesResource ... -type ThroughputSettingsGetPropertiesResource struct { - // Throughput - Value of the Cosmos DB resource throughput. Either throughput is required or autoscaleSettings is required, but not both. - Throughput *int32 `json:"throughput,omitempty"` - // AutoscaleSettings - Cosmos DB resource for autoscale settings. Either throughput is required or autoscaleSettings is required, but not both. - AutoscaleSettings *AutoscaleSettingsResource `json:"autoscaleSettings,omitempty"` - // MinimumThroughput - READ-ONLY; The minimum throughput of the resource - MinimumThroughput *string `json:"minimumThroughput,omitempty"` - // OfferReplacePending - READ-ONLY; The throughput replace is pending - OfferReplacePending *string `json:"offerReplacePending,omitempty"` - // Rid - READ-ONLY; A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // Ts - READ-ONLY; A system generated property that denotes the last updated timestamp of the resource. - Ts *float64 `json:"_ts,omitempty"` - // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. - Etag *string `json:"_etag,omitempty"` -} - -// MarshalJSON is the custom marshaler for ThroughputSettingsGetPropertiesResource. -func (tsgp ThroughputSettingsGetPropertiesResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if tsgp.Throughput != nil { - objectMap["throughput"] = tsgp.Throughput - } - if tsgp.AutoscaleSettings != nil { - objectMap["autoscaleSettings"] = tsgp.AutoscaleSettings - } - return json.Marshal(objectMap) -} - -// ThroughputSettingsGetResults an Azure Cosmos DB resource throughput. -type ThroughputSettingsGetResults struct { - autorest.Response `json:"-"` - // ThroughputSettingsGetProperties - The properties of an Azure Cosmos DB resource throughput - *ThroughputSettingsGetProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for ThroughputSettingsGetResults. -func (tsgr ThroughputSettingsGetResults) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if tsgr.ThroughputSettingsGetProperties != nil { - objectMap["properties"] = tsgr.ThroughputSettingsGetProperties - } - if tsgr.Location != nil { - objectMap["location"] = tsgr.Location - } - if tsgr.Tags != nil { - objectMap["tags"] = tsgr.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for ThroughputSettingsGetResults struct. -func (tsgr *ThroughputSettingsGetResults) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var throughputSettingsGetProperties ThroughputSettingsGetProperties - err = json.Unmarshal(*v, &throughputSettingsGetProperties) - if err != nil { - return err - } - tsgr.ThroughputSettingsGetProperties = &throughputSettingsGetProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - tsgr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - tsgr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - tsgr.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - tsgr.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - tsgr.Tags = tags - } - } - } - - return nil -} - -// ThroughputSettingsResource cosmos DB resource throughput object. Either throughput is required or -// autoscaleSettings is required, but not both. -type ThroughputSettingsResource struct { - // Throughput - Value of the Cosmos DB resource throughput. Either throughput is required or autoscaleSettings is required, but not both. - Throughput *int32 `json:"throughput,omitempty"` - // AutoscaleSettings - Cosmos DB resource for autoscale settings. Either throughput is required or autoscaleSettings is required, but not both. - AutoscaleSettings *AutoscaleSettingsResource `json:"autoscaleSettings,omitempty"` - // MinimumThroughput - READ-ONLY; The minimum throughput of the resource - MinimumThroughput *string `json:"minimumThroughput,omitempty"` - // OfferReplacePending - READ-ONLY; The throughput replace is pending - OfferReplacePending *string `json:"offerReplacePending,omitempty"` -} - -// MarshalJSON is the custom marshaler for ThroughputSettingsResource. -func (tsr ThroughputSettingsResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if tsr.Throughput != nil { - objectMap["throughput"] = tsr.Throughput - } - if tsr.AutoscaleSettings != nil { - objectMap["autoscaleSettings"] = tsr.AutoscaleSettings - } - return json.Marshal(objectMap) -} - -// ThroughputSettingsUpdateParameters parameters to update Cosmos DB resource throughput. -type ThroughputSettingsUpdateParameters struct { - // ThroughputSettingsUpdateProperties - Properties to update Azure Cosmos DB resource throughput. - *ThroughputSettingsUpdateProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The unique resource identifier of the ARM resource. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the ARM resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of Azure resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource group to which the resource belongs. - Location *string `json:"location,omitempty"` - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for ThroughputSettingsUpdateParameters. -func (tsup ThroughputSettingsUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if tsup.ThroughputSettingsUpdateProperties != nil { - objectMap["properties"] = tsup.ThroughputSettingsUpdateProperties - } - if tsup.Location != nil { - objectMap["location"] = tsup.Location - } - if tsup.Tags != nil { - objectMap["tags"] = tsup.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for ThroughputSettingsUpdateParameters struct. -func (tsup *ThroughputSettingsUpdateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var throughputSettingsUpdateProperties ThroughputSettingsUpdateProperties - err = json.Unmarshal(*v, &throughputSettingsUpdateProperties) - if err != nil { - return err - } - tsup.ThroughputSettingsUpdateProperties = &throughputSettingsUpdateProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - tsup.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - tsup.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - tsup.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - tsup.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - tsup.Tags = tags - } - } - } - - return nil -} - -// ThroughputSettingsUpdateProperties properties to update Azure Cosmos DB resource throughput. -type ThroughputSettingsUpdateProperties struct { - // Resource - The standard JSON format of a resource throughput - Resource *ThroughputSettingsResource `json:"resource,omitempty"` -} - -// TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource -// which has 'tags' and a 'location' -type TrackedResource struct { - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` - // Location - The geo-location where the resource lives - Location *string `json:"location,omitempty"` - // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the resource - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for TrackedResource. -func (tr TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if tr.Tags != nil { - objectMap["tags"] = tr.Tags - } - if tr.Location != nil { - objectMap["location"] = tr.Location - } - return json.Marshal(objectMap) -} - -// UniqueKey the unique key on that enforces uniqueness constraint on documents in the collection in the -// Azure Cosmos DB service. -type UniqueKey struct { - // Paths - List of paths must be unique for each document in the Azure Cosmos DB service - Paths *[]string `json:"paths,omitempty"` -} - -// UniqueKeyPolicy the unique key policy configuration for specifying uniqueness constraints on documents -// in the collection in the Azure Cosmos DB service. -type UniqueKeyPolicy struct { - // UniqueKeys - List of unique keys on that enforces uniqueness constraint on documents in the collection in the Azure Cosmos DB service. - UniqueKeys *[]UniqueKey `json:"uniqueKeys,omitempty"` -} - -// Usage the usage data for a usage request. -type Usage struct { - // Unit - The unit of the metric. Possible values include: 'UnitTypeCount', 'UnitTypeBytes', 'UnitTypeSeconds', 'UnitTypePercent', 'UnitTypeCountPerSecond', 'UnitTypeBytesPerSecond', 'UnitTypeMilliseconds' - Unit UnitType `json:"unit,omitempty"` - // Name - READ-ONLY; The name information for the metric. - Name *MetricName `json:"name,omitempty"` - // QuotaPeriod - READ-ONLY; The quota period used to summarize the usage values. - QuotaPeriod *string `json:"quotaPeriod,omitempty"` - // Limit - READ-ONLY; Maximum value for this metric - Limit *int64 `json:"limit,omitempty"` - // CurrentValue - READ-ONLY; Current value for this metric - CurrentValue *int64 `json:"currentValue,omitempty"` -} - -// MarshalJSON is the custom marshaler for Usage. -func (u Usage) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if u.Unit != "" { - objectMap["unit"] = u.Unit - } - return json.Marshal(objectMap) -} - -// UsagesResult the response to a list usage request. -type UsagesResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; The list of usages for the database. A usage is a point in time metric - Value *[]Usage `json:"value,omitempty"` -} - -// MarshalJSON is the custom marshaler for UsagesResult. -func (ur UsagesResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// VirtualNetworkRule virtual Network ACL Rule object -type VirtualNetworkRule struct { - // ID - Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}. - ID *string `json:"id,omitempty"` - // IgnoreMissingVNetServiceEndpoint - Create firewall rule before the virtual network has vnet service endpoint enabled. - IgnoreMissingVNetServiceEndpoint *bool `json:"ignoreMissingVNetServiceEndpoint,omitempty"` -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/mongodbresources.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/mongodbresources.go deleted file mode 100644 index 8f88c0b9fb92..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/mongodbresources.go +++ /dev/null @@ -1,1672 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// MongoDBResourcesClient is the client for the MongoDBResources methods of the Documentdb service. -type MongoDBResourcesClient struct { - BaseClient -} - -// NewMongoDBResourcesClient creates an instance of the MongoDBResourcesClient client. -func NewMongoDBResourcesClient(subscriptionID string) MongoDBResourcesClient { - return NewMongoDBResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewMongoDBResourcesClientWithBaseURI creates an instance of the MongoDBResourcesClient client using a custom -// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure -// stack). -func NewMongoDBResourcesClientWithBaseURI(baseURI string, subscriptionID string) MongoDBResourcesClient { - return MongoDBResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateUpdateMongoDBCollection create or update an Azure Cosmos DB MongoDB Collection -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// collectionName - cosmos DB collection name. -// createUpdateMongoDBCollectionParameters - the parameters to provide for the current MongoDB Collection. -func (client MongoDBResourcesClient) CreateUpdateMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, createUpdateMongoDBCollectionParameters MongoDBCollectionCreateUpdateParameters) (result MongoDBResourcesCreateUpdateMongoDBCollectionFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.CreateUpdateMongoDBCollection") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: createUpdateMongoDBCollectionParameters, - Constraints: []validation.Constraint{{Target: "createUpdateMongoDBCollectionParameters.MongoDBCollectionCreateUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateMongoDBCollectionParameters.MongoDBCollectionCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateMongoDBCollectionParameters.MongoDBCollectionCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBCollection", err.Error()) - } - - req, err := client.CreateUpdateMongoDBCollectionPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName, createUpdateMongoDBCollectionParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBCollection", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateMongoDBCollectionSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBCollection", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdateMongoDBCollectionPreparer prepares the CreateUpdateMongoDBCollection request. -func (client MongoDBResourcesClient) CreateUpdateMongoDBCollectionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, createUpdateMongoDBCollectionParameters MongoDBCollectionCreateUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "collectionName": autorest.Encode("path", collectionName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", pathParameters), - autorest.WithJSON(createUpdateMongoDBCollectionParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateUpdateMongoDBCollectionSender sends the CreateUpdateMongoDBCollection request. The method will close the -// http.Response Body if it receives an error. -func (client MongoDBResourcesClient) CreateUpdateMongoDBCollectionSender(req *http.Request) (future MongoDBResourcesCreateUpdateMongoDBCollectionFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// CreateUpdateMongoDBCollectionResponder handles the response to the CreateUpdateMongoDBCollection request. The method always -// closes the http.Response Body. -func (client MongoDBResourcesClient) CreateUpdateMongoDBCollectionResponder(resp *http.Response) (result MongoDBCollectionGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateUpdateMongoDBDatabase create or updates Azure Cosmos DB MongoDB database -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// createUpdateMongoDBDatabaseParameters - the parameters to provide for the current MongoDB database. -func (client MongoDBResourcesClient) CreateUpdateMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateMongoDBDatabaseParameters MongoDBDatabaseCreateUpdateParameters) (result MongoDBResourcesCreateUpdateMongoDBDatabaseFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.CreateUpdateMongoDBDatabase") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: createUpdateMongoDBDatabaseParameters, - Constraints: []validation.Constraint{{Target: "createUpdateMongoDBDatabaseParameters.MongoDBDatabaseCreateUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateMongoDBDatabaseParameters.MongoDBDatabaseCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateMongoDBDatabaseParameters.MongoDBDatabaseCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBDatabase", err.Error()) - } - - req, err := client.CreateUpdateMongoDBDatabasePreparer(ctx, resourceGroupName, accountName, databaseName, createUpdateMongoDBDatabaseParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBDatabase", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateMongoDBDatabaseSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "CreateUpdateMongoDBDatabase", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdateMongoDBDatabasePreparer prepares the CreateUpdateMongoDBDatabase request. -func (client MongoDBResourcesClient) CreateUpdateMongoDBDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateMongoDBDatabaseParameters MongoDBDatabaseCreateUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}", pathParameters), - autorest.WithJSON(createUpdateMongoDBDatabaseParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateUpdateMongoDBDatabaseSender sends the CreateUpdateMongoDBDatabase request. The method will close the -// http.Response Body if it receives an error. -func (client MongoDBResourcesClient) CreateUpdateMongoDBDatabaseSender(req *http.Request) (future MongoDBResourcesCreateUpdateMongoDBDatabaseFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// CreateUpdateMongoDBDatabaseResponder handles the response to the CreateUpdateMongoDBDatabase request. The method always -// closes the http.Response Body. -func (client MongoDBResourcesClient) CreateUpdateMongoDBDatabaseResponder(resp *http.Response) (result MongoDBDatabaseGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// DeleteMongoDBCollection deletes an existing Azure Cosmos DB MongoDB Collection. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// collectionName - cosmos DB collection name. -func (client MongoDBResourcesClient) DeleteMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result MongoDBResourcesDeleteMongoDBCollectionFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.DeleteMongoDBCollection") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.MongoDBResourcesClient", "DeleteMongoDBCollection", err.Error()) - } - - req, err := client.DeleteMongoDBCollectionPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "DeleteMongoDBCollection", nil, "Failure preparing request") - return - } - - result, err = client.DeleteMongoDBCollectionSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "DeleteMongoDBCollection", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteMongoDBCollectionPreparer prepares the DeleteMongoDBCollection request. -func (client MongoDBResourcesClient) DeleteMongoDBCollectionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "collectionName": autorest.Encode("path", collectionName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteMongoDBCollectionSender sends the DeleteMongoDBCollection request. The method will close the -// http.Response Body if it receives an error. -func (client MongoDBResourcesClient) DeleteMongoDBCollectionSender(req *http.Request) (future MongoDBResourcesDeleteMongoDBCollectionFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteMongoDBCollectionResponder handles the response to the DeleteMongoDBCollection request. The method always -// closes the http.Response Body. -func (client MongoDBResourcesClient) DeleteMongoDBCollectionResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// DeleteMongoDBDatabase deletes an existing Azure Cosmos DB MongoDB database. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client MongoDBResourcesClient) DeleteMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBResourcesDeleteMongoDBDatabaseFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.DeleteMongoDBDatabase") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.MongoDBResourcesClient", "DeleteMongoDBDatabase", err.Error()) - } - - req, err := client.DeleteMongoDBDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "DeleteMongoDBDatabase", nil, "Failure preparing request") - return - } - - result, err = client.DeleteMongoDBDatabaseSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "DeleteMongoDBDatabase", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteMongoDBDatabasePreparer prepares the DeleteMongoDBDatabase request. -func (client MongoDBResourcesClient) DeleteMongoDBDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteMongoDBDatabaseSender sends the DeleteMongoDBDatabase request. The method will close the -// http.Response Body if it receives an error. -func (client MongoDBResourcesClient) DeleteMongoDBDatabaseSender(req *http.Request) (future MongoDBResourcesDeleteMongoDBDatabaseFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteMongoDBDatabaseResponder handles the response to the DeleteMongoDBDatabase request. The method always -// closes the http.Response Body. -func (client MongoDBResourcesClient) DeleteMongoDBDatabaseResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// GetMongoDBCollection gets the MongoDB collection under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// collectionName - cosmos DB collection name. -func (client MongoDBResourcesClient) GetMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result MongoDBCollectionGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.GetMongoDBCollection") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.MongoDBResourcesClient", "GetMongoDBCollection", err.Error()) - } - - req, err := client.GetMongoDBCollectionPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollection", nil, "Failure preparing request") - return - } - - resp, err := client.GetMongoDBCollectionSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollection", resp, "Failure sending request") - return - } - - result, err = client.GetMongoDBCollectionResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollection", resp, "Failure responding to request") - return - } - - return -} - -// GetMongoDBCollectionPreparer prepares the GetMongoDBCollection request. -func (client MongoDBResourcesClient) GetMongoDBCollectionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "collectionName": autorest.Encode("path", collectionName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetMongoDBCollectionSender sends the GetMongoDBCollection request. The method will close the -// http.Response Body if it receives an error. -func (client MongoDBResourcesClient) GetMongoDBCollectionSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetMongoDBCollectionResponder handles the response to the GetMongoDBCollection request. The method always -// closes the http.Response Body. -func (client MongoDBResourcesClient) GetMongoDBCollectionResponder(resp *http.Response) (result MongoDBCollectionGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetMongoDBCollectionThroughput gets the RUs per second of the MongoDB collection under an existing Azure Cosmos DB -// database account with the provided name. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// collectionName - cosmos DB collection name. -func (client MongoDBResourcesClient) GetMongoDBCollectionThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result ThroughputSettingsGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.GetMongoDBCollectionThroughput") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.MongoDBResourcesClient", "GetMongoDBCollectionThroughput", err.Error()) - } - - req, err := client.GetMongoDBCollectionThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollectionThroughput", nil, "Failure preparing request") - return - } - - resp, err := client.GetMongoDBCollectionThroughputSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollectionThroughput", resp, "Failure sending request") - return - } - - result, err = client.GetMongoDBCollectionThroughputResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBCollectionThroughput", resp, "Failure responding to request") - return - } - - return -} - -// GetMongoDBCollectionThroughputPreparer prepares the GetMongoDBCollectionThroughput request. -func (client MongoDBResourcesClient) GetMongoDBCollectionThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "collectionName": autorest.Encode("path", collectionName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetMongoDBCollectionThroughputSender sends the GetMongoDBCollectionThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client MongoDBResourcesClient) GetMongoDBCollectionThroughputSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetMongoDBCollectionThroughputResponder handles the response to the GetMongoDBCollectionThroughput request. The method always -// closes the http.Response Body. -func (client MongoDBResourcesClient) GetMongoDBCollectionThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetMongoDBDatabase gets the MongoDB databases under an existing Azure Cosmos DB database account with the provided -// name. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client MongoDBResourcesClient) GetMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBDatabaseGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.GetMongoDBDatabase") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.MongoDBResourcesClient", "GetMongoDBDatabase", err.Error()) - } - - req, err := client.GetMongoDBDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabase", nil, "Failure preparing request") - return - } - - resp, err := client.GetMongoDBDatabaseSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabase", resp, "Failure sending request") - return - } - - result, err = client.GetMongoDBDatabaseResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabase", resp, "Failure responding to request") - return - } - - return -} - -// GetMongoDBDatabasePreparer prepares the GetMongoDBDatabase request. -func (client MongoDBResourcesClient) GetMongoDBDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetMongoDBDatabaseSender sends the GetMongoDBDatabase request. The method will close the -// http.Response Body if it receives an error. -func (client MongoDBResourcesClient) GetMongoDBDatabaseSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetMongoDBDatabaseResponder handles the response to the GetMongoDBDatabase request. The method always -// closes the http.Response Body. -func (client MongoDBResourcesClient) GetMongoDBDatabaseResponder(resp *http.Response) (result MongoDBDatabaseGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetMongoDBDatabaseThroughput gets the RUs per second of the MongoDB database under an existing Azure Cosmos DB -// database account with the provided name. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client MongoDBResourcesClient) GetMongoDBDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result ThroughputSettingsGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.GetMongoDBDatabaseThroughput") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.MongoDBResourcesClient", "GetMongoDBDatabaseThroughput", err.Error()) - } - - req, err := client.GetMongoDBDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabaseThroughput", nil, "Failure preparing request") - return - } - - resp, err := client.GetMongoDBDatabaseThroughputSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabaseThroughput", resp, "Failure sending request") - return - } - - result, err = client.GetMongoDBDatabaseThroughputResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "GetMongoDBDatabaseThroughput", resp, "Failure responding to request") - return - } - - return -} - -// GetMongoDBDatabaseThroughputPreparer prepares the GetMongoDBDatabaseThroughput request. -func (client MongoDBResourcesClient) GetMongoDBDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetMongoDBDatabaseThroughputSender sends the GetMongoDBDatabaseThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client MongoDBResourcesClient) GetMongoDBDatabaseThroughputSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetMongoDBDatabaseThroughputResponder handles the response to the GetMongoDBDatabaseThroughput request. The method always -// closes the http.Response Body. -func (client MongoDBResourcesClient) GetMongoDBDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListMongoDBCollections lists the MongoDB collection under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client MongoDBResourcesClient) ListMongoDBCollections(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBCollectionListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.ListMongoDBCollections") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.MongoDBResourcesClient", "ListMongoDBCollections", err.Error()) - } - - req, err := client.ListMongoDBCollectionsPreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBCollections", nil, "Failure preparing request") - return - } - - resp, err := client.ListMongoDBCollectionsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBCollections", resp, "Failure sending request") - return - } - - result, err = client.ListMongoDBCollectionsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBCollections", resp, "Failure responding to request") - return - } - - return -} - -// ListMongoDBCollectionsPreparer prepares the ListMongoDBCollections request. -func (client MongoDBResourcesClient) ListMongoDBCollectionsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListMongoDBCollectionsSender sends the ListMongoDBCollections request. The method will close the -// http.Response Body if it receives an error. -func (client MongoDBResourcesClient) ListMongoDBCollectionsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListMongoDBCollectionsResponder handles the response to the ListMongoDBCollections request. The method always -// closes the http.Response Body. -func (client MongoDBResourcesClient) ListMongoDBCollectionsResponder(resp *http.Response) (result MongoDBCollectionListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListMongoDBDatabases lists the MongoDB databases under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client MongoDBResourcesClient) ListMongoDBDatabases(ctx context.Context, resourceGroupName string, accountName string) (result MongoDBDatabaseListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.ListMongoDBDatabases") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.MongoDBResourcesClient", "ListMongoDBDatabases", err.Error()) - } - - req, err := client.ListMongoDBDatabasesPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBDatabases", nil, "Failure preparing request") - return - } - - resp, err := client.ListMongoDBDatabasesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBDatabases", resp, "Failure sending request") - return - } - - result, err = client.ListMongoDBDatabasesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "ListMongoDBDatabases", resp, "Failure responding to request") - return - } - - return -} - -// ListMongoDBDatabasesPreparer prepares the ListMongoDBDatabases request. -func (client MongoDBResourcesClient) ListMongoDBDatabasesPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListMongoDBDatabasesSender sends the ListMongoDBDatabases request. The method will close the -// http.Response Body if it receives an error. -func (client MongoDBResourcesClient) ListMongoDBDatabasesSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListMongoDBDatabasesResponder handles the response to the ListMongoDBDatabases request. The method always -// closes the http.Response Body. -func (client MongoDBResourcesClient) ListMongoDBDatabasesResponder(resp *http.Response) (result MongoDBDatabaseListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// MigrateMongoDBCollectionToAutoscale migrate an Azure Cosmos DB MongoDB collection from manual throughput to -// autoscale -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// collectionName - cosmos DB collection name. -func (client MongoDBResourcesClient) MigrateMongoDBCollectionToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.MigrateMongoDBCollectionToAutoscale") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToAutoscale", err.Error()) - } - - req, err := client.MigrateMongoDBCollectionToAutoscalePreparer(ctx, resourceGroupName, accountName, databaseName, collectionName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToAutoscale", nil, "Failure preparing request") - return - } - - result, err = client.MigrateMongoDBCollectionToAutoscaleSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToAutoscale", result.Response(), "Failure sending request") - return - } - - return -} - -// MigrateMongoDBCollectionToAutoscalePreparer prepares the MigrateMongoDBCollectionToAutoscale request. -func (client MongoDBResourcesClient) MigrateMongoDBCollectionToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "collectionName": autorest.Encode("path", collectionName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToAutoscale", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// MigrateMongoDBCollectionToAutoscaleSender sends the MigrateMongoDBCollectionToAutoscale request. The method will close the -// http.Response Body if it receives an error. -func (client MongoDBResourcesClient) MigrateMongoDBCollectionToAutoscaleSender(req *http.Request) (future MongoDBResourcesMigrateMongoDBCollectionToAutoscaleFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// MigrateMongoDBCollectionToAutoscaleResponder handles the response to the MigrateMongoDBCollectionToAutoscale request. The method always -// closes the http.Response Body. -func (client MongoDBResourcesClient) MigrateMongoDBCollectionToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// MigrateMongoDBCollectionToManualThroughput migrate an Azure Cosmos DB MongoDB collection from autoscale to manual -// throughput -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// collectionName - cosmos DB collection name. -func (client MongoDBResourcesClient) MigrateMongoDBCollectionToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.MigrateMongoDBCollectionToManualThroughput") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToManualThroughput", err.Error()) - } - - req, err := client.MigrateMongoDBCollectionToManualThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToManualThroughput", nil, "Failure preparing request") - return - } - - result, err = client.MigrateMongoDBCollectionToManualThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBCollectionToManualThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// MigrateMongoDBCollectionToManualThroughputPreparer prepares the MigrateMongoDBCollectionToManualThroughput request. -func (client MongoDBResourcesClient) MigrateMongoDBCollectionToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "collectionName": autorest.Encode("path", collectionName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToManualThroughput", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// MigrateMongoDBCollectionToManualThroughputSender sends the MigrateMongoDBCollectionToManualThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client MongoDBResourcesClient) MigrateMongoDBCollectionToManualThroughputSender(req *http.Request) (future MongoDBResourcesMigrateMongoDBCollectionToManualThroughputFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// MigrateMongoDBCollectionToManualThroughputResponder handles the response to the MigrateMongoDBCollectionToManualThroughput request. The method always -// closes the http.Response Body. -func (client MongoDBResourcesClient) MigrateMongoDBCollectionToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// MigrateMongoDBDatabaseToAutoscale migrate an Azure Cosmos DB MongoDB database from manual throughput to autoscale -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.MigrateMongoDBDatabaseToAutoscale") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToAutoscale", err.Error()) - } - - req, err := client.MigrateMongoDBDatabaseToAutoscalePreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToAutoscale", nil, "Failure preparing request") - return - } - - result, err = client.MigrateMongoDBDatabaseToAutoscaleSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToAutoscale", result.Response(), "Failure sending request") - return - } - - return -} - -// MigrateMongoDBDatabaseToAutoscalePreparer prepares the MigrateMongoDBDatabaseToAutoscale request. -func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// MigrateMongoDBDatabaseToAutoscaleSender sends the MigrateMongoDBDatabaseToAutoscale request. The method will close the -// http.Response Body if it receives an error. -func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToAutoscaleSender(req *http.Request) (future MongoDBResourcesMigrateMongoDBDatabaseToAutoscaleFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// MigrateMongoDBDatabaseToAutoscaleResponder handles the response to the MigrateMongoDBDatabaseToAutoscale request. The method always -// closes the http.Response Body. -func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// MigrateMongoDBDatabaseToManualThroughput migrate an Azure Cosmos DB MongoDB database from autoscale to manual -// throughput -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.MigrateMongoDBDatabaseToManualThroughput") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToManualThroughput", err.Error()) - } - - req, err := client.MigrateMongoDBDatabaseToManualThroughputPreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToManualThroughput", nil, "Failure preparing request") - return - } - - result, err = client.MigrateMongoDBDatabaseToManualThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "MigrateMongoDBDatabaseToManualThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// MigrateMongoDBDatabaseToManualThroughputPreparer prepares the MigrateMongoDBDatabaseToManualThroughput request. -func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// MigrateMongoDBDatabaseToManualThroughputSender sends the MigrateMongoDBDatabaseToManualThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToManualThroughputSender(req *http.Request) (future MongoDBResourcesMigrateMongoDBDatabaseToManualThroughputFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// MigrateMongoDBDatabaseToManualThroughputResponder handles the response to the MigrateMongoDBDatabaseToManualThroughput request. The method always -// closes the http.Response Body. -func (client MongoDBResourcesClient) MigrateMongoDBDatabaseToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// RetrieveContinuousBackupInformation retrieves continuous backup information for a Mongodb collection. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// collectionName - cosmos DB collection name. -// location - the name of the continuous backup restore location. -func (client MongoDBResourcesClient) RetrieveContinuousBackupInformation(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, location ContinuousBackupRestoreLocation) (result MongoDBResourcesRetrieveContinuousBackupInformationFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.RetrieveContinuousBackupInformation") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.MongoDBResourcesClient", "RetrieveContinuousBackupInformation", err.Error()) - } - - req, err := client.RetrieveContinuousBackupInformationPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName, location) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "RetrieveContinuousBackupInformation", nil, "Failure preparing request") - return - } - - result, err = client.RetrieveContinuousBackupInformationSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "RetrieveContinuousBackupInformation", result.Response(), "Failure sending request") - return - } - - return -} - -// RetrieveContinuousBackupInformationPreparer prepares the RetrieveContinuousBackupInformation request. -func (client MongoDBResourcesClient) RetrieveContinuousBackupInformationPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, location ContinuousBackupRestoreLocation) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "collectionName": autorest.Encode("path", collectionName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/retrieveContinuousBackupInformation", pathParameters), - autorest.WithJSON(location), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// RetrieveContinuousBackupInformationSender sends the RetrieveContinuousBackupInformation request. The method will close the -// http.Response Body if it receives an error. -func (client MongoDBResourcesClient) RetrieveContinuousBackupInformationSender(req *http.Request) (future MongoDBResourcesRetrieveContinuousBackupInformationFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// RetrieveContinuousBackupInformationResponder handles the response to the RetrieveContinuousBackupInformation request. The method always -// closes the http.Response Body. -func (client MongoDBResourcesClient) RetrieveContinuousBackupInformationResponder(resp *http.Response) (result BackupInformation, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// UpdateMongoDBCollectionThroughput update the RUs per second of an Azure Cosmos DB MongoDB collection -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// collectionName - cosmos DB collection name. -// updateThroughputParameters - the RUs per second of the parameters to provide for the current MongoDB -// collection. -func (client MongoDBResourcesClient) UpdateMongoDBCollectionThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result MongoDBResourcesUpdateMongoDBCollectionThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.UpdateMongoDBCollectionThroughput") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: updateThroughputParameters, - Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, - }}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.MongoDBResourcesClient", "UpdateMongoDBCollectionThroughput", err.Error()) - } - - req, err := client.UpdateMongoDBCollectionThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName, updateThroughputParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "UpdateMongoDBCollectionThroughput", nil, "Failure preparing request") - return - } - - result, err = client.UpdateMongoDBCollectionThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "UpdateMongoDBCollectionThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdateMongoDBCollectionThroughputPreparer prepares the UpdateMongoDBCollectionThroughput request. -func (client MongoDBResourcesClient) UpdateMongoDBCollectionThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "collectionName": autorest.Encode("path", collectionName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default", pathParameters), - autorest.WithJSON(updateThroughputParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateMongoDBCollectionThroughputSender sends the UpdateMongoDBCollectionThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client MongoDBResourcesClient) UpdateMongoDBCollectionThroughputSender(req *http.Request) (future MongoDBResourcesUpdateMongoDBCollectionThroughputFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// UpdateMongoDBCollectionThroughputResponder handles the response to the UpdateMongoDBCollectionThroughput request. The method always -// closes the http.Response Body. -func (client MongoDBResourcesClient) UpdateMongoDBCollectionThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// UpdateMongoDBDatabaseThroughput update RUs per second of the an Azure Cosmos DB MongoDB database -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// updateThroughputParameters - the RUs per second of the parameters to provide for the current MongoDB -// database. -func (client MongoDBResourcesClient) UpdateMongoDBDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MongoDBResourcesClient.UpdateMongoDBDatabaseThroughput") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: updateThroughputParameters, - Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, - }}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.MongoDBResourcesClient", "UpdateMongoDBDatabaseThroughput", err.Error()) - } - - req, err := client.UpdateMongoDBDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, updateThroughputParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "UpdateMongoDBDatabaseThroughput", nil, "Failure preparing request") - return - } - - result, err = client.UpdateMongoDBDatabaseThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.MongoDBResourcesClient", "UpdateMongoDBDatabaseThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdateMongoDBDatabaseThroughputPreparer prepares the UpdateMongoDBDatabaseThroughput request. -func (client MongoDBResourcesClient) UpdateMongoDBDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default", pathParameters), - autorest.WithJSON(updateThroughputParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateMongoDBDatabaseThroughputSender sends the UpdateMongoDBDatabaseThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client MongoDBResourcesClient) UpdateMongoDBDatabaseThroughputSender(req *http.Request) (future MongoDBResourcesUpdateMongoDBDatabaseThroughputFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// UpdateMongoDBDatabaseThroughputResponder handles the response to the UpdateMongoDBDatabaseThroughput request. The method always -// closes the http.Response Body. -func (client MongoDBResourcesClient) UpdateMongoDBDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/notebookworkspaces.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/notebookworkspaces.go deleted file mode 100644 index b6c87e17f530..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/notebookworkspaces.go +++ /dev/null @@ -1,674 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// NotebookWorkspacesClient is the client for the NotebookWorkspaces methods of the Documentdb service. -type NotebookWorkspacesClient struct { - BaseClient -} - -// NewNotebookWorkspacesClient creates an instance of the NotebookWorkspacesClient client. -func NewNotebookWorkspacesClient(subscriptionID string) NotebookWorkspacesClient { - return NewNotebookWorkspacesClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewNotebookWorkspacesClientWithBaseURI creates an instance of the NotebookWorkspacesClient client using a custom -// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure -// stack). -func NewNotebookWorkspacesClientWithBaseURI(baseURI string, subscriptionID string) NotebookWorkspacesClient { - return NotebookWorkspacesClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdate creates the notebook workspace for a Cosmos DB account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// notebookCreateUpdateParameters - the notebook workspace to create for the current database account. -func (client NotebookWorkspacesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, notebookCreateUpdateParameters NotebookWorkspaceCreateUpdateParameters) (result NotebookWorkspacesCreateOrUpdateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.CreateOrUpdate") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.NotebookWorkspacesClient", "CreateOrUpdate", err.Error()) - } - - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, accountName, notebookCreateUpdateParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = client.CreateOrUpdateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "CreateOrUpdate", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client NotebookWorkspacesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, notebookCreateUpdateParameters NotebookWorkspaceCreateUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "notebookWorkspaceName": autorest.Encode("path", "default"), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}", pathParameters), - autorest.WithJSON(notebookCreateUpdateParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client NotebookWorkspacesClient) CreateOrUpdateSender(req *http.Request) (future NotebookWorkspacesCreateOrUpdateFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client NotebookWorkspacesClient) CreateOrUpdateResponder(resp *http.Response) (result NotebookWorkspace, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete deletes the notebook workspace for a Cosmos DB account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client NotebookWorkspacesClient) Delete(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspacesDeleteFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.Delete") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.NotebookWorkspacesClient", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Delete", result.Response(), "Failure sending request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client NotebookWorkspacesClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "notebookWorkspaceName": autorest.Encode("path", "default"), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client NotebookWorkspacesClient) DeleteSender(req *http.Request) (future NotebookWorkspacesDeleteFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client NotebookWorkspacesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get gets the notebook workspace for a Cosmos DB account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client NotebookWorkspacesClient) Get(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspace, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.NotebookWorkspacesClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client NotebookWorkspacesClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "notebookWorkspaceName": autorest.Encode("path", "default"), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client NotebookWorkspacesClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client NotebookWorkspacesClient) GetResponder(resp *http.Response) (result NotebookWorkspace, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListByDatabaseAccount gets the notebook workspace resources of an existing Cosmos DB account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client NotebookWorkspacesClient) ListByDatabaseAccount(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspaceListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.ListByDatabaseAccount") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.NotebookWorkspacesClient", "ListByDatabaseAccount", err.Error()) - } - - req, err := client.ListByDatabaseAccountPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListByDatabaseAccount", nil, "Failure preparing request") - return - } - - resp, err := client.ListByDatabaseAccountSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListByDatabaseAccount", resp, "Failure sending request") - return - } - - result, err = client.ListByDatabaseAccountResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListByDatabaseAccount", resp, "Failure responding to request") - return - } - - return -} - -// ListByDatabaseAccountPreparer prepares the ListByDatabaseAccount request. -func (client NotebookWorkspacesClient) ListByDatabaseAccountPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListByDatabaseAccountSender sends the ListByDatabaseAccount request. The method will close the -// http.Response Body if it receives an error. -func (client NotebookWorkspacesClient) ListByDatabaseAccountSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListByDatabaseAccountResponder handles the response to the ListByDatabaseAccount request. The method always -// closes the http.Response Body. -func (client NotebookWorkspacesClient) ListByDatabaseAccountResponder(resp *http.Response) (result NotebookWorkspaceListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListConnectionInfo retrieves the connection info for the notebook workspace -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client NotebookWorkspacesClient) ListConnectionInfo(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspaceConnectionInfoResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.ListConnectionInfo") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.NotebookWorkspacesClient", "ListConnectionInfo", err.Error()) - } - - req, err := client.ListConnectionInfoPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListConnectionInfo", nil, "Failure preparing request") - return - } - - resp, err := client.ListConnectionInfoSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListConnectionInfo", resp, "Failure sending request") - return - } - - result, err = client.ListConnectionInfoResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "ListConnectionInfo", resp, "Failure responding to request") - return - } - - return -} - -// ListConnectionInfoPreparer prepares the ListConnectionInfo request. -func (client NotebookWorkspacesClient) ListConnectionInfoPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "notebookWorkspaceName": autorest.Encode("path", "default"), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/listConnectionInfo", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListConnectionInfoSender sends the ListConnectionInfo request. The method will close the -// http.Response Body if it receives an error. -func (client NotebookWorkspacesClient) ListConnectionInfoSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListConnectionInfoResponder handles the response to the ListConnectionInfo request. The method always -// closes the http.Response Body. -func (client NotebookWorkspacesClient) ListConnectionInfoResponder(resp *http.Response) (result NotebookWorkspaceConnectionInfoResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// RegenerateAuthToken regenerates the auth token for the notebook workspace -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client NotebookWorkspacesClient) RegenerateAuthToken(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspacesRegenerateAuthTokenFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.RegenerateAuthToken") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.NotebookWorkspacesClient", "RegenerateAuthToken", err.Error()) - } - - req, err := client.RegenerateAuthTokenPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "RegenerateAuthToken", nil, "Failure preparing request") - return - } - - result, err = client.RegenerateAuthTokenSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "RegenerateAuthToken", result.Response(), "Failure sending request") - return - } - - return -} - -// RegenerateAuthTokenPreparer prepares the RegenerateAuthToken request. -func (client NotebookWorkspacesClient) RegenerateAuthTokenPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "notebookWorkspaceName": autorest.Encode("path", "default"), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/regenerateAuthToken", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// RegenerateAuthTokenSender sends the RegenerateAuthToken request. The method will close the -// http.Response Body if it receives an error. -func (client NotebookWorkspacesClient) RegenerateAuthTokenSender(req *http.Request) (future NotebookWorkspacesRegenerateAuthTokenFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// RegenerateAuthTokenResponder handles the response to the RegenerateAuthToken request. The method always -// closes the http.Response Body. -func (client NotebookWorkspacesClient) RegenerateAuthTokenResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByClosing()) - result.Response = resp - return -} - -// Start starts the notebook workspace -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client NotebookWorkspacesClient) Start(ctx context.Context, resourceGroupName string, accountName string) (result NotebookWorkspacesStartFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NotebookWorkspacesClient.Start") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.NotebookWorkspacesClient", "Start", err.Error()) - } - - req, err := client.StartPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Start", nil, "Failure preparing request") - return - } - - result, err = client.StartSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.NotebookWorkspacesClient", "Start", result.Response(), "Failure sending request") - return - } - - return -} - -// StartPreparer prepares the Start request. -func (client NotebookWorkspacesClient) StartPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "notebookWorkspaceName": autorest.Encode("path", "default"), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/start", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// StartSender sends the Start request. The method will close the -// http.Response Body if it receives an error. -func (client NotebookWorkspacesClient) StartSender(req *http.Request) (future NotebookWorkspacesStartFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// StartResponder handles the response to the Start request. The method always -// closes the http.Response Body. -func (client NotebookWorkspacesClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByClosing()) - result.Response = resp - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/operations.go deleted file mode 100644 index 93237a83edb3..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/operations.go +++ /dev/null @@ -1,140 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// OperationsClient is the client for the Operations methods of the Documentdb service. -type OperationsClient struct { - BaseClient -} - -// NewOperationsClient creates an instance of the OperationsClient client. -func NewOperationsClient(subscriptionID string) OperationsClient { - return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this -// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { - return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// List lists all of the available Cosmos DB Resource Provider operations. -func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") - defer func() { - sc := -1 - if result.olr.Response.Response != nil { - sc = result.olr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.OperationsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.olr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.OperationsClient", "List", resp, "Failure sending request") - return - } - - result.olr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.OperationsClient", "List", resp, "Failure responding to request") - return - } - if result.olr.hasNextLink() && result.olr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListPreparer prepares the List request. -func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/providers/Microsoft.DocumentDB/operations"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { - req, err := lastResults.operationListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "documentdb.OperationsClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "documentdb.OperationsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.OperationsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/partitionkeyrangeid.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/partitionkeyrangeid.go deleted file mode 100644 index 35d464f7443f..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/partitionkeyrangeid.go +++ /dev/null @@ -1,132 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// PartitionKeyRangeIDClient is the client for the PartitionKeyRangeID methods of the Documentdb service. -type PartitionKeyRangeIDClient struct { - BaseClient -} - -// NewPartitionKeyRangeIDClient creates an instance of the PartitionKeyRangeIDClient client. -func NewPartitionKeyRangeIDClient(subscriptionID string) PartitionKeyRangeIDClient { - return NewPartitionKeyRangeIDClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewPartitionKeyRangeIDClientWithBaseURI creates an instance of the PartitionKeyRangeIDClient client using a custom -// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure -// stack). -func NewPartitionKeyRangeIDClientWithBaseURI(baseURI string, subscriptionID string) PartitionKeyRangeIDClient { - return PartitionKeyRangeIDClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// ListMetrics retrieves the metrics determined by the given filter for the given partition key range id. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseRid - cosmos DB database rid. -// collectionRid - cosmos DB collection rid. -// partitionKeyRangeID - partition Key Range Id for which to get data. -// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be -// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and -// timeGrain. The supported operator is eq. -func (client PartitionKeyRangeIDClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, partitionKeyRangeID string, filter string) (result PartitionMetricListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PartitionKeyRangeIDClient.ListMetrics") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.PartitionKeyRangeIDClient", "ListMetrics", err.Error()) - } - - req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, databaseRid, collectionRid, partitionKeyRangeID, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PartitionKeyRangeIDClient", "ListMetrics", nil, "Failure preparing request") - return - } - - resp, err := client.ListMetricsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.PartitionKeyRangeIDClient", "ListMetrics", resp, "Failure sending request") - return - } - - result, err = client.ListMetricsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PartitionKeyRangeIDClient", "ListMetrics", resp, "Failure responding to request") - return - } - - return -} - -// ListMetricsPreparer prepares the ListMetrics request. -func (client PartitionKeyRangeIDClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseRid string, collectionRid string, partitionKeyRangeID string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "collectionRid": autorest.Encode("path", collectionRid), - "databaseRid": autorest.Encode("path", databaseRid), - "partitionKeyRangeId": autorest.Encode("path", partitionKeyRangeID), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "$filter": autorest.Encode("query", filter), - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitionKeyRangeId/{partitionKeyRangeId}/metrics", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListMetricsSender sends the ListMetrics request. The method will close the -// http.Response Body if it receives an error. -func (client PartitionKeyRangeIDClient) ListMetricsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListMetricsResponder handles the response to the ListMetrics request. The method always -// closes the http.Response Body. -func (client PartitionKeyRangeIDClient) ListMetricsResponder(resp *http.Response) (result PartitionMetricListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/partitionkeyrangeidregion.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/partitionkeyrangeidregion.go deleted file mode 100644 index 16ccbbd5cd72..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/partitionkeyrangeidregion.go +++ /dev/null @@ -1,134 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// PartitionKeyRangeIDRegionClient is the client for the PartitionKeyRangeIDRegion methods of the Documentdb service. -type PartitionKeyRangeIDRegionClient struct { - BaseClient -} - -// NewPartitionKeyRangeIDRegionClient creates an instance of the PartitionKeyRangeIDRegionClient client. -func NewPartitionKeyRangeIDRegionClient(subscriptionID string) PartitionKeyRangeIDRegionClient { - return NewPartitionKeyRangeIDRegionClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewPartitionKeyRangeIDRegionClientWithBaseURI creates an instance of the PartitionKeyRangeIDRegionClient client -// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign -// clouds, Azure stack). -func NewPartitionKeyRangeIDRegionClientWithBaseURI(baseURI string, subscriptionID string) PartitionKeyRangeIDRegionClient { - return PartitionKeyRangeIDRegionClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// ListMetrics retrieves the metrics determined by the given filter for the given partition key range id and region. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// region - cosmos DB region, with spaces between words and each word capitalized. -// databaseRid - cosmos DB database rid. -// collectionRid - cosmos DB collection rid. -// partitionKeyRangeID - partition Key Range Id for which to get data. -// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be -// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and -// timeGrain. The supported operator is eq. -func (client PartitionKeyRangeIDRegionClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, partitionKeyRangeID string, filter string) (result PartitionMetricListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PartitionKeyRangeIDRegionClient.ListMetrics") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.PartitionKeyRangeIDRegionClient", "ListMetrics", err.Error()) - } - - req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, region, databaseRid, collectionRid, partitionKeyRangeID, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PartitionKeyRangeIDRegionClient", "ListMetrics", nil, "Failure preparing request") - return - } - - resp, err := client.ListMetricsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.PartitionKeyRangeIDRegionClient", "ListMetrics", resp, "Failure sending request") - return - } - - result, err = client.ListMetricsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PartitionKeyRangeIDRegionClient", "ListMetrics", resp, "Failure responding to request") - return - } - - return -} - -// ListMetricsPreparer prepares the ListMetrics request. -func (client PartitionKeyRangeIDRegionClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, region string, databaseRid string, collectionRid string, partitionKeyRangeID string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "collectionRid": autorest.Encode("path", collectionRid), - "databaseRid": autorest.Encode("path", databaseRid), - "partitionKeyRangeId": autorest.Encode("path", partitionKeyRangeID), - "region": autorest.Encode("path", region), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "$filter": autorest.Encode("query", filter), - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/partitionKeyRangeId/{partitionKeyRangeId}/metrics", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListMetricsSender sends the ListMetrics request. The method will close the -// http.Response Body if it receives an error. -func (client PartitionKeyRangeIDRegionClient) ListMetricsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListMetricsResponder handles the response to the ListMetrics request. The method always -// closes the http.Response Body. -func (client PartitionKeyRangeIDRegionClient) ListMetricsResponder(resp *http.Response) (result PartitionMetricListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/percentile.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/percentile.go deleted file mode 100644 index ac183729674e..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/percentile.go +++ /dev/null @@ -1,126 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// PercentileClient is the client for the Percentile methods of the Documentdb service. -type PercentileClient struct { - BaseClient -} - -// NewPercentileClient creates an instance of the PercentileClient client. -func NewPercentileClient(subscriptionID string) PercentileClient { - return NewPercentileClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewPercentileClientWithBaseURI creates an instance of the PercentileClient client using a custom endpoint. Use this -// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewPercentileClientWithBaseURI(baseURI string, subscriptionID string) PercentileClient { - return PercentileClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// ListMetrics retrieves the metrics determined by the given filter for the given database account. This url is only -// for PBS and Replication Latency data -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be -// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and -// timeGrain. The supported operator is eq. -func (client PercentileClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, filter string) (result PercentileMetricListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PercentileClient.ListMetrics") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.PercentileClient", "ListMetrics", err.Error()) - } - - req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PercentileClient", "ListMetrics", nil, "Failure preparing request") - return - } - - resp, err := client.ListMetricsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.PercentileClient", "ListMetrics", resp, "Failure sending request") - return - } - - result, err = client.ListMetricsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PercentileClient", "ListMetrics", resp, "Failure responding to request") - return - } - - return -} - -// ListMetricsPreparer prepares the ListMetrics request. -func (client PercentileClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "$filter": autorest.Encode("query", filter), - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/percentile/metrics", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListMetricsSender sends the ListMetrics request. The method will close the -// http.Response Body if it receives an error. -func (client PercentileClient) ListMetricsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListMetricsResponder handles the response to the ListMetrics request. The method always -// closes the http.Response Body. -func (client PercentileClient) ListMetricsResponder(resp *http.Response) (result PercentileMetricListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/percentilesourcetarget.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/percentilesourcetarget.go deleted file mode 100644 index 555671067730..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/percentilesourcetarget.go +++ /dev/null @@ -1,133 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// PercentileSourceTargetClient is the client for the PercentileSourceTarget methods of the Documentdb service. -type PercentileSourceTargetClient struct { - BaseClient -} - -// NewPercentileSourceTargetClient creates an instance of the PercentileSourceTargetClient client. -func NewPercentileSourceTargetClient(subscriptionID string) PercentileSourceTargetClient { - return NewPercentileSourceTargetClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewPercentileSourceTargetClientWithBaseURI creates an instance of the PercentileSourceTargetClient client using a -// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, -// Azure stack). -func NewPercentileSourceTargetClientWithBaseURI(baseURI string, subscriptionID string) PercentileSourceTargetClient { - return PercentileSourceTargetClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// ListMetrics retrieves the metrics determined by the given filter for the given account, source and target region. -// This url is only for PBS and Replication Latency data -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// sourceRegion - source region from which data is written. Cosmos DB region, with spaces between words and -// each word capitalized. -// targetRegion - target region to which data is written. Cosmos DB region, with spaces between words and each -// word capitalized. -// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be -// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and -// timeGrain. The supported operator is eq. -func (client PercentileSourceTargetClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, sourceRegion string, targetRegion string, filter string) (result PercentileMetricListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PercentileSourceTargetClient.ListMetrics") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.PercentileSourceTargetClient", "ListMetrics", err.Error()) - } - - req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, sourceRegion, targetRegion, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PercentileSourceTargetClient", "ListMetrics", nil, "Failure preparing request") - return - } - - resp, err := client.ListMetricsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.PercentileSourceTargetClient", "ListMetrics", resp, "Failure sending request") - return - } - - result, err = client.ListMetricsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PercentileSourceTargetClient", "ListMetrics", resp, "Failure responding to request") - return - } - - return -} - -// ListMetricsPreparer prepares the ListMetrics request. -func (client PercentileSourceTargetClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, sourceRegion string, targetRegion string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "sourceRegion": autorest.Encode("path", sourceRegion), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "targetRegion": autorest.Encode("path", targetRegion), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "$filter": autorest.Encode("query", filter), - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sourceRegion/{sourceRegion}/targetRegion/{targetRegion}/percentile/metrics", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListMetricsSender sends the ListMetrics request. The method will close the -// http.Response Body if it receives an error. -func (client PercentileSourceTargetClient) ListMetricsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListMetricsResponder handles the response to the ListMetrics request. The method always -// closes the http.Response Body. -func (client PercentileSourceTargetClient) ListMetricsResponder(resp *http.Response) (result PercentileMetricListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/percentiletarget.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/percentiletarget.go deleted file mode 100644 index 595496cee9c1..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/percentiletarget.go +++ /dev/null @@ -1,130 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// PercentileTargetClient is the client for the PercentileTarget methods of the Documentdb service. -type PercentileTargetClient struct { - BaseClient -} - -// NewPercentileTargetClient creates an instance of the PercentileTargetClient client. -func NewPercentileTargetClient(subscriptionID string) PercentileTargetClient { - return NewPercentileTargetClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewPercentileTargetClientWithBaseURI creates an instance of the PercentileTargetClient client using a custom -// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure -// stack). -func NewPercentileTargetClientWithBaseURI(baseURI string, subscriptionID string) PercentileTargetClient { - return PercentileTargetClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// ListMetrics retrieves the metrics determined by the given filter for the given account target region. This url is -// only for PBS and Replication Latency data -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// targetRegion - target region to which data is written. Cosmos DB region, with spaces between words and each -// word capitalized. -// filter - an OData filter expression that describes a subset of metrics to return. The parameters that can be -// filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and -// timeGrain. The supported operator is eq. -func (client PercentileTargetClient) ListMetrics(ctx context.Context, resourceGroupName string, accountName string, targetRegion string, filter string) (result PercentileMetricListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PercentileTargetClient.ListMetrics") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.PercentileTargetClient", "ListMetrics", err.Error()) - } - - req, err := client.ListMetricsPreparer(ctx, resourceGroupName, accountName, targetRegion, filter) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PercentileTargetClient", "ListMetrics", nil, "Failure preparing request") - return - } - - resp, err := client.ListMetricsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.PercentileTargetClient", "ListMetrics", resp, "Failure sending request") - return - } - - result, err = client.ListMetricsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PercentileTargetClient", "ListMetrics", resp, "Failure responding to request") - return - } - - return -} - -// ListMetricsPreparer prepares the ListMetrics request. -func (client PercentileTargetClient) ListMetricsPreparer(ctx context.Context, resourceGroupName string, accountName string, targetRegion string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "targetRegion": autorest.Encode("path", targetRegion), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "$filter": autorest.Encode("query", filter), - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/targetRegion/{targetRegion}/percentile/metrics", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListMetricsSender sends the ListMetrics request. The method will close the -// http.Response Body if it receives an error. -func (client PercentileTargetClient) ListMetricsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListMetricsResponder handles the response to the ListMetrics request. The method always -// closes the http.Response Body. -func (client PercentileTargetClient) ListMetricsResponder(resp *http.Response) (result PercentileMetricListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/privateendpointconnections.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/privateendpointconnections.go deleted file mode 100644 index 4548c9db5dad..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/privateendpointconnections.go +++ /dev/null @@ -1,402 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// PrivateEndpointConnectionsClient is the client for the PrivateEndpointConnections methods of the Documentdb service. -type PrivateEndpointConnectionsClient struct { - BaseClient -} - -// NewPrivateEndpointConnectionsClient creates an instance of the PrivateEndpointConnectionsClient client. -func NewPrivateEndpointConnectionsClient(subscriptionID string) PrivateEndpointConnectionsClient { - return NewPrivateEndpointConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewPrivateEndpointConnectionsClientWithBaseURI creates an instance of the PrivateEndpointConnectionsClient client -// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign -// clouds, Azure stack). -func NewPrivateEndpointConnectionsClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsClient { - return PrivateEndpointConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdate approve or reject a private endpoint connection with a given name. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// privateEndpointConnectionName - the name of the private endpoint connection. -func (client PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection) (result PrivateEndpointConnectionsCreateOrUpdateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.CreateOrUpdate") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.PrivateEndpointConnectionsClient", "CreateOrUpdate", err.Error()) - } - - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, accountName, privateEndpointConnectionName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = client.CreateOrUpdateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "CreateOrUpdate", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client PrivateEndpointConnectionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client PrivateEndpointConnectionsClient) CreateOrUpdateSender(req *http.Request) (future PrivateEndpointConnectionsCreateOrUpdateFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client PrivateEndpointConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete deletes a private endpoint connection with a given name. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// privateEndpointConnectionName - the name of the private endpoint connection. -func (client PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string) (result PrivateEndpointConnectionsDeleteFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Delete") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.PrivateEndpointConnectionsClient", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, privateEndpointConnectionName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "Delete", result.Response(), "Failure sending request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client PrivateEndpointConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client PrivateEndpointConnectionsClient) DeleteSender(req *http.Request) (future PrivateEndpointConnectionsDeleteFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client PrivateEndpointConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get gets a private endpoint connection. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// privateEndpointConnectionName - the name of the private endpoint connection. -func (client PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string) (result PrivateEndpointConnection, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.PrivateEndpointConnectionsClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, accountName, privateEndpointConnectionName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client PrivateEndpointConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client PrivateEndpointConnectionsClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client PrivateEndpointConnectionsClient) GetResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListByDatabaseAccount list all private endpoint connections on a Cosmos DB account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client PrivateEndpointConnectionsClient) ListByDatabaseAccount(ctx context.Context, resourceGroupName string, accountName string) (result PrivateEndpointConnectionListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.ListByDatabaseAccount") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.PrivateEndpointConnectionsClient", "ListByDatabaseAccount", err.Error()) - } - - req, err := client.ListByDatabaseAccountPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "ListByDatabaseAccount", nil, "Failure preparing request") - return - } - - resp, err := client.ListByDatabaseAccountSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "ListByDatabaseAccount", resp, "Failure sending request") - return - } - - result, err = client.ListByDatabaseAccountResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PrivateEndpointConnectionsClient", "ListByDatabaseAccount", resp, "Failure responding to request") - return - } - - return -} - -// ListByDatabaseAccountPreparer prepares the ListByDatabaseAccount request. -func (client PrivateEndpointConnectionsClient) ListByDatabaseAccountPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListByDatabaseAccountSender sends the ListByDatabaseAccount request. The method will close the -// http.Response Body if it receives an error. -func (client PrivateEndpointConnectionsClient) ListByDatabaseAccountSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListByDatabaseAccountResponder handles the response to the ListByDatabaseAccount request. The method always -// closes the http.Response Body. -func (client PrivateEndpointConnectionsClient) ListByDatabaseAccountResponder(resp *http.Response) (result PrivateEndpointConnectionListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/privatelinkresources.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/privatelinkresources.go deleted file mode 100644 index c557f3a24548..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/privatelinkresources.go +++ /dev/null @@ -1,213 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// PrivateLinkResourcesClient is the client for the PrivateLinkResources methods of the Documentdb service. -type PrivateLinkResourcesClient struct { - BaseClient -} - -// NewPrivateLinkResourcesClient creates an instance of the PrivateLinkResourcesClient client. -func NewPrivateLinkResourcesClient(subscriptionID string) PrivateLinkResourcesClient { - return NewPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewPrivateLinkResourcesClientWithBaseURI creates an instance of the PrivateLinkResourcesClient client using a custom -// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure -// stack). -func NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient { - return PrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// Get gets the private link resources that need to be created for a Cosmos DB account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// groupName - the name of the private link resource. -func (client PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, accountName string, groupName string) (result PrivateLinkResource, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.PrivateLinkResourcesClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, accountName, groupName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PrivateLinkResourcesClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.PrivateLinkResourcesClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PrivateLinkResourcesClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client PrivateLinkResourcesClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, groupName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "groupName": autorest.Encode("path", groupName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateLinkResources/{groupName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client PrivateLinkResourcesClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client PrivateLinkResourcesClient) GetResponder(resp *http.Response) (result PrivateLinkResource, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListByDatabaseAccount gets the private link resources that need to be created for a Cosmos DB account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client PrivateLinkResourcesClient) ListByDatabaseAccount(ctx context.Context, resourceGroupName string, accountName string) (result PrivateLinkResourceListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.ListByDatabaseAccount") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.PrivateLinkResourcesClient", "ListByDatabaseAccount", err.Error()) - } - - req, err := client.ListByDatabaseAccountPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PrivateLinkResourcesClient", "ListByDatabaseAccount", nil, "Failure preparing request") - return - } - - resp, err := client.ListByDatabaseAccountSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.PrivateLinkResourcesClient", "ListByDatabaseAccount", resp, "Failure sending request") - return - } - - result, err = client.ListByDatabaseAccountResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.PrivateLinkResourcesClient", "ListByDatabaseAccount", resp, "Failure responding to request") - return - } - - return -} - -// ListByDatabaseAccountPreparer prepares the ListByDatabaseAccount request. -func (client PrivateLinkResourcesClient) ListByDatabaseAccountPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateLinkResources", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListByDatabaseAccountSender sends the ListByDatabaseAccount request. The method will close the -// http.Response Body if it receives an error. -func (client PrivateLinkResourcesClient) ListByDatabaseAccountSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListByDatabaseAccountResponder handles the response to the ListByDatabaseAccount request. The method always -// closes the http.Response Body. -func (client PrivateLinkResourcesClient) ListByDatabaseAccountResponder(resp *http.Response) (result PrivateLinkResourceListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorabledatabaseaccounts.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorabledatabaseaccounts.go deleted file mode 100644 index 281b0ae5ee0a..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorabledatabaseaccounts.go +++ /dev/null @@ -1,275 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// RestorableDatabaseAccountsClient is the client for the RestorableDatabaseAccounts methods of the Documentdb service. -type RestorableDatabaseAccountsClient struct { - BaseClient -} - -// NewRestorableDatabaseAccountsClient creates an instance of the RestorableDatabaseAccountsClient client. -func NewRestorableDatabaseAccountsClient(subscriptionID string) RestorableDatabaseAccountsClient { - return NewRestorableDatabaseAccountsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewRestorableDatabaseAccountsClientWithBaseURI creates an instance of the RestorableDatabaseAccountsClient client -// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign -// clouds, Azure stack). -func NewRestorableDatabaseAccountsClientWithBaseURI(baseURI string, subscriptionID string) RestorableDatabaseAccountsClient { - return RestorableDatabaseAccountsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// GetByLocation retrieves the properties of an existing Azure Cosmos DB restorable database account. This call -// requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/read/*' permission. -// Parameters: -// location - cosmos DB region, with spaces between words and each word capitalized. -// instanceID - the instanceId GUID of a restorable database account. -func (client RestorableDatabaseAccountsClient) GetByLocation(ctx context.Context, location string, instanceID string) (result RestorableDatabaseAccountGetResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDatabaseAccountsClient.GetByLocation") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.RestorableDatabaseAccountsClient", "GetByLocation", err.Error()) - } - - req, err := client.GetByLocationPreparer(ctx, location, instanceID) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "GetByLocation", nil, "Failure preparing request") - return - } - - resp, err := client.GetByLocationSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "GetByLocation", resp, "Failure sending request") - return - } - - result, err = client.GetByLocationResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "GetByLocation", resp, "Failure responding to request") - return - } - - return -} - -// GetByLocationPreparer prepares the GetByLocation request. -func (client RestorableDatabaseAccountsClient) GetByLocationPreparer(ctx context.Context, location string, instanceID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "instanceId": autorest.Encode("path", instanceID), - "location": autorest.Encode("path", location), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetByLocationSender sends the GetByLocation request. The method will close the -// http.Response Body if it receives an error. -func (client RestorableDatabaseAccountsClient) GetByLocationSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetByLocationResponder handles the response to the GetByLocation request. The method always -// closes the http.Response Body. -func (client RestorableDatabaseAccountsClient) GetByLocationResponder(resp *http.Response) (result RestorableDatabaseAccountGetResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List lists all the restorable Azure Cosmos DB database accounts available under the subscription. This call requires -// 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/read' permission. -func (client RestorableDatabaseAccountsClient) List(ctx context.Context) (result RestorableDatabaseAccountsListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDatabaseAccountsClient.List") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.RestorableDatabaseAccountsClient", "List", err.Error()) - } - - req, err := client.ListPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "List", resp, "Failure sending request") - return - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "List", resp, "Failure responding to request") - return - } - - return -} - -// ListPreparer prepares the List request. -func (client RestorableDatabaseAccountsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/restorableDatabaseAccounts", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client RestorableDatabaseAccountsClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client RestorableDatabaseAccountsClient) ListResponder(resp *http.Response) (result RestorableDatabaseAccountsListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListByLocation lists all the restorable Azure Cosmos DB database accounts available under the subscription and in a -// region. This call requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/read' permission. -// Parameters: -// location - cosmos DB region, with spaces between words and each word capitalized. -func (client RestorableDatabaseAccountsClient) ListByLocation(ctx context.Context, location string) (result RestorableDatabaseAccountsListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RestorableDatabaseAccountsClient.ListByLocation") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.RestorableDatabaseAccountsClient", "ListByLocation", err.Error()) - } - - req, err := client.ListByLocationPreparer(ctx, location) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "ListByLocation", nil, "Failure preparing request") - return - } - - resp, err := client.ListByLocationSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "ListByLocation", resp, "Failure sending request") - return - } - - result, err = client.ListByLocationResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.RestorableDatabaseAccountsClient", "ListByLocation", resp, "Failure responding to request") - return - } - - return -} - -// ListByLocationPreparer prepares the ListByLocation request. -func (client RestorableDatabaseAccountsClient) ListByLocationPreparer(ctx context.Context, location string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "location": autorest.Encode("path", location), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListByLocationSender sends the ListByLocation request. The method will close the -// http.Response Body if it receives an error. -func (client RestorableDatabaseAccountsClient) ListByLocationSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListByLocationResponder handles the response to the ListByLocation request. The method always -// closes the http.Response Body. -func (client RestorableDatabaseAccountsClient) ListByLocationResponder(resp *http.Response) (result RestorableDatabaseAccountsListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablemongodbcollections.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablemongodbcollections.go deleted file mode 100644 index abb0c50ae967..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablemongodbcollections.go +++ /dev/null @@ -1,122 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// RestorableMongodbCollectionsClient is the client for the RestorableMongodbCollections methods of the Documentdb -// service. -type RestorableMongodbCollectionsClient struct { - BaseClient -} - -// NewRestorableMongodbCollectionsClient creates an instance of the RestorableMongodbCollectionsClient client. -func NewRestorableMongodbCollectionsClient(subscriptionID string) RestorableMongodbCollectionsClient { - return NewRestorableMongodbCollectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewRestorableMongodbCollectionsClientWithBaseURI creates an instance of the RestorableMongodbCollectionsClient -// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI -// (sovereign clouds, Azure stack). -func NewRestorableMongodbCollectionsClientWithBaseURI(baseURI string, subscriptionID string) RestorableMongodbCollectionsClient { - return RestorableMongodbCollectionsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// List show the event feed of all mutations done on all the Azure Cosmos DB MongoDB collections under a specific -// database. This helps in scenario where container was accidentally deleted. This API requires -// 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission -// Parameters: -// location - cosmos DB region, with spaces between words and each word capitalized. -// instanceID - the instanceId GUID of a restorable database account. -// restorableMongodbDatabaseRid - the resource ID of the MongoDB database. -func (client RestorableMongodbCollectionsClient) List(ctx context.Context, location string, instanceID string, restorableMongodbDatabaseRid string) (result RestorableMongodbCollectionsListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RestorableMongodbCollectionsClient.List") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.RestorableMongodbCollectionsClient", "List", err.Error()) - } - - req, err := client.ListPreparer(ctx, location, instanceID, restorableMongodbDatabaseRid) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbCollectionsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbCollectionsClient", "List", resp, "Failure sending request") - return - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbCollectionsClient", "List", resp, "Failure responding to request") - return - } - - return -} - -// ListPreparer prepares the List request. -func (client RestorableMongodbCollectionsClient) ListPreparer(ctx context.Context, location string, instanceID string, restorableMongodbDatabaseRid string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "instanceId": autorest.Encode("path", instanceID), - "location": autorest.Encode("path", location), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(restorableMongodbDatabaseRid) > 0 { - queryParameters["restorableMongodbDatabaseRid"] = autorest.Encode("query", restorableMongodbDatabaseRid) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbCollections", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client RestorableMongodbCollectionsClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client RestorableMongodbCollectionsClient) ListResponder(resp *http.Response) (result RestorableMongodbCollectionsListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablemongodbdatabases.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablemongodbdatabases.go deleted file mode 100644 index 5eb996a0e464..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablemongodbdatabases.go +++ /dev/null @@ -1,117 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// RestorableMongodbDatabasesClient is the client for the RestorableMongodbDatabases methods of the Documentdb service. -type RestorableMongodbDatabasesClient struct { - BaseClient -} - -// NewRestorableMongodbDatabasesClient creates an instance of the RestorableMongodbDatabasesClient client. -func NewRestorableMongodbDatabasesClient(subscriptionID string) RestorableMongodbDatabasesClient { - return NewRestorableMongodbDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewRestorableMongodbDatabasesClientWithBaseURI creates an instance of the RestorableMongodbDatabasesClient client -// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign -// clouds, Azure stack). -func NewRestorableMongodbDatabasesClientWithBaseURI(baseURI string, subscriptionID string) RestorableMongodbDatabasesClient { - return RestorableMongodbDatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// List show the event feed of all mutations done on all the Azure Cosmos DB MongoDB databases under the restorable -// account. This helps in scenario where database was accidentally deleted to get the deletion time. This API -// requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission -// Parameters: -// location - cosmos DB region, with spaces between words and each word capitalized. -// instanceID - the instanceId GUID of a restorable database account. -func (client RestorableMongodbDatabasesClient) List(ctx context.Context, location string, instanceID string) (result RestorableMongodbDatabasesListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RestorableMongodbDatabasesClient.List") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.RestorableMongodbDatabasesClient", "List", err.Error()) - } - - req, err := client.ListPreparer(ctx, location, instanceID) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbDatabasesClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbDatabasesClient", "List", resp, "Failure sending request") - return - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbDatabasesClient", "List", resp, "Failure responding to request") - return - } - - return -} - -// ListPreparer prepares the List request. -func (client RestorableMongodbDatabasesClient) ListPreparer(ctx context.Context, location string, instanceID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "instanceId": autorest.Encode("path", instanceID), - "location": autorest.Encode("path", location), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbDatabases", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client RestorableMongodbDatabasesClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client RestorableMongodbDatabasesClient) ListResponder(resp *http.Response) (result RestorableMongodbDatabasesListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablemongodbresources.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablemongodbresources.go deleted file mode 100644 index 0bd3935bf97f..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablemongodbresources.go +++ /dev/null @@ -1,125 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// RestorableMongodbResourcesClient is the client for the RestorableMongodbResources methods of the Documentdb service. -type RestorableMongodbResourcesClient struct { - BaseClient -} - -// NewRestorableMongodbResourcesClient creates an instance of the RestorableMongodbResourcesClient client. -func NewRestorableMongodbResourcesClient(subscriptionID string) RestorableMongodbResourcesClient { - return NewRestorableMongodbResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewRestorableMongodbResourcesClientWithBaseURI creates an instance of the RestorableMongodbResourcesClient client -// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign -// clouds, Azure stack). -func NewRestorableMongodbResourcesClientWithBaseURI(baseURI string, subscriptionID string) RestorableMongodbResourcesClient { - return RestorableMongodbResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// List return a list of database and collection combo that exist on the account at the given timestamp and location. -// This helps in scenarios to validate what resources exist at given timestamp and location. This API requires -// 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. -// Parameters: -// location - cosmos DB region, with spaces between words and each word capitalized. -// instanceID - the instanceId GUID of a restorable database account. -// restoreLocation - the location where the restorable resources are located. -// restoreTimestampInUtc - the timestamp when the restorable resources existed. -func (client RestorableMongodbResourcesClient) List(ctx context.Context, location string, instanceID string, restoreLocation string, restoreTimestampInUtc string) (result RestorableMongodbResourcesListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RestorableMongodbResourcesClient.List") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.RestorableMongodbResourcesClient", "List", err.Error()) - } - - req, err := client.ListPreparer(ctx, location, instanceID, restoreLocation, restoreTimestampInUtc) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbResourcesClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbResourcesClient", "List", resp, "Failure sending request") - return - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.RestorableMongodbResourcesClient", "List", resp, "Failure responding to request") - return - } - - return -} - -// ListPreparer prepares the List request. -func (client RestorableMongodbResourcesClient) ListPreparer(ctx context.Context, location string, instanceID string, restoreLocation string, restoreTimestampInUtc string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "instanceId": autorest.Encode("path", instanceID), - "location": autorest.Encode("path", location), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(restoreLocation) > 0 { - queryParameters["restoreLocation"] = autorest.Encode("query", restoreLocation) - } - if len(restoreTimestampInUtc) > 0 { - queryParameters["restoreTimestampInUtc"] = autorest.Encode("query", restoreTimestampInUtc) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbResources", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client RestorableMongodbResourcesClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client RestorableMongodbResourcesClient) ListResponder(resp *http.Response) (result RestorableMongodbResourcesListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablesqlcontainers.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablesqlcontainers.go deleted file mode 100644 index 01b33b085e66..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablesqlcontainers.go +++ /dev/null @@ -1,129 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// RestorableSQLContainersClient is the client for the RestorableSQLContainers methods of the Documentdb service. -type RestorableSQLContainersClient struct { - BaseClient -} - -// NewRestorableSQLContainersClient creates an instance of the RestorableSQLContainersClient client. -func NewRestorableSQLContainersClient(subscriptionID string) RestorableSQLContainersClient { - return NewRestorableSQLContainersClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewRestorableSQLContainersClientWithBaseURI creates an instance of the RestorableSQLContainersClient client using a -// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, -// Azure stack). -func NewRestorableSQLContainersClientWithBaseURI(baseURI string, subscriptionID string) RestorableSQLContainersClient { - return RestorableSQLContainersClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// List show the event feed of all mutations done on all the Azure Cosmos DB SQL containers under a specific database. -// This helps in scenario where container was accidentally deleted. This API requires -// 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission -// Parameters: -// location - cosmos DB region, with spaces between words and each word capitalized. -// instanceID - the instanceId GUID of a restorable database account. -// restorableSQLDatabaseRid - the resource ID of the SQL database. -// startTime - the snapshot create timestamp after which snapshots need to be listed. -// endTime - the snapshot create timestamp before which snapshots need to be listed. -func (client RestorableSQLContainersClient) List(ctx context.Context, location string, instanceID string, restorableSQLDatabaseRid string, startTime string, endTime string) (result RestorableSQLContainersListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RestorableSQLContainersClient.List") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.RestorableSQLContainersClient", "List", err.Error()) - } - - req, err := client.ListPreparer(ctx, location, instanceID, restorableSQLDatabaseRid, startTime, endTime) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLContainersClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLContainersClient", "List", resp, "Failure sending request") - return - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLContainersClient", "List", resp, "Failure responding to request") - return - } - - return -} - -// ListPreparer prepares the List request. -func (client RestorableSQLContainersClient) ListPreparer(ctx context.Context, location string, instanceID string, restorableSQLDatabaseRid string, startTime string, endTime string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "instanceId": autorest.Encode("path", instanceID), - "location": autorest.Encode("path", location), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(restorableSQLDatabaseRid) > 0 { - queryParameters["restorableSqlDatabaseRid"] = autorest.Encode("query", restorableSQLDatabaseRid) - } - if len(startTime) > 0 { - queryParameters["startTime"] = autorest.Encode("query", startTime) - } - if len(endTime) > 0 { - queryParameters["endTime"] = autorest.Encode("query", endTime) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlContainers", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client RestorableSQLContainersClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client RestorableSQLContainersClient) ListResponder(resp *http.Response) (result RestorableSQLContainersListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablesqldatabases.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablesqldatabases.go deleted file mode 100644 index 542075861a99..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablesqldatabases.go +++ /dev/null @@ -1,117 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// RestorableSQLDatabasesClient is the client for the RestorableSQLDatabases methods of the Documentdb service. -type RestorableSQLDatabasesClient struct { - BaseClient -} - -// NewRestorableSQLDatabasesClient creates an instance of the RestorableSQLDatabasesClient client. -func NewRestorableSQLDatabasesClient(subscriptionID string) RestorableSQLDatabasesClient { - return NewRestorableSQLDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewRestorableSQLDatabasesClientWithBaseURI creates an instance of the RestorableSQLDatabasesClient client using a -// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, -// Azure stack). -func NewRestorableSQLDatabasesClientWithBaseURI(baseURI string, subscriptionID string) RestorableSQLDatabasesClient { - return RestorableSQLDatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// List show the event feed of all mutations done on all the Azure Cosmos DB SQL databases under the restorable -// account. This helps in scenario where database was accidentally deleted to get the deletion time. This API -// requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission -// Parameters: -// location - cosmos DB region, with spaces between words and each word capitalized. -// instanceID - the instanceId GUID of a restorable database account. -func (client RestorableSQLDatabasesClient) List(ctx context.Context, location string, instanceID string) (result RestorableSQLDatabasesListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RestorableSQLDatabasesClient.List") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.RestorableSQLDatabasesClient", "List", err.Error()) - } - - req, err := client.ListPreparer(ctx, location, instanceID) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLDatabasesClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLDatabasesClient", "List", resp, "Failure sending request") - return - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLDatabasesClient", "List", resp, "Failure responding to request") - return - } - - return -} - -// ListPreparer prepares the List request. -func (client RestorableSQLDatabasesClient) ListPreparer(ctx context.Context, location string, instanceID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "instanceId": autorest.Encode("path", instanceID), - "location": autorest.Encode("path", location), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlDatabases", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client RestorableSQLDatabasesClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client RestorableSQLDatabasesClient) ListResponder(resp *http.Response) (result RestorableSQLDatabasesListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablesqlresources.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablesqlresources.go deleted file mode 100644 index b9b4eb7c2298..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/restorablesqlresources.go +++ /dev/null @@ -1,125 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// RestorableSQLResourcesClient is the client for the RestorableSQLResources methods of the Documentdb service. -type RestorableSQLResourcesClient struct { - BaseClient -} - -// NewRestorableSQLResourcesClient creates an instance of the RestorableSQLResourcesClient client. -func NewRestorableSQLResourcesClient(subscriptionID string) RestorableSQLResourcesClient { - return NewRestorableSQLResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewRestorableSQLResourcesClientWithBaseURI creates an instance of the RestorableSQLResourcesClient client using a -// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, -// Azure stack). -func NewRestorableSQLResourcesClientWithBaseURI(baseURI string, subscriptionID string) RestorableSQLResourcesClient { - return RestorableSQLResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// List return a list of database and container combo that exist on the account at the given timestamp and location. -// This helps in scenarios to validate what resources exist at given timestamp and location. This API requires -// 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. -// Parameters: -// location - cosmos DB region, with spaces between words and each word capitalized. -// instanceID - the instanceId GUID of a restorable database account. -// restoreLocation - the location where the restorable resources are located. -// restoreTimestampInUtc - the timestamp when the restorable resources existed. -func (client RestorableSQLResourcesClient) List(ctx context.Context, location string, instanceID string, restoreLocation string, restoreTimestampInUtc string) (result RestorableSQLResourcesListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RestorableSQLResourcesClient.List") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.RestorableSQLResourcesClient", "List", err.Error()) - } - - req, err := client.ListPreparer(ctx, location, instanceID, restoreLocation, restoreTimestampInUtc) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLResourcesClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLResourcesClient", "List", resp, "Failure sending request") - return - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.RestorableSQLResourcesClient", "List", resp, "Failure responding to request") - return - } - - return -} - -// ListPreparer prepares the List request. -func (client RestorableSQLResourcesClient) ListPreparer(ctx context.Context, location string, instanceID string, restoreLocation string, restoreTimestampInUtc string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "instanceId": autorest.Encode("path", instanceID), - "location": autorest.Encode("path", location), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(restoreLocation) > 0 { - queryParameters["restoreLocation"] = autorest.Encode("query", restoreLocation) - } - if len(restoreTimestampInUtc) > 0 { - queryParameters["restoreTimestampInUtc"] = autorest.Encode("query", restoreTimestampInUtc) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlResources", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client RestorableSQLResourcesClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client RestorableSQLResourcesClient) ListResponder(resp *http.Response) (result RestorableSQLResourcesListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/sqlresources.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/sqlresources.go deleted file mode 100644 index caea93806c86..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/sqlresources.go +++ /dev/null @@ -1,3586 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// SQLResourcesClient is the client for the SQLResources methods of the Documentdb service. -type SQLResourcesClient struct { - BaseClient -} - -// NewSQLResourcesClient creates an instance of the SQLResourcesClient client. -func NewSQLResourcesClient(subscriptionID string) SQLResourcesClient { - return NewSQLResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewSQLResourcesClientWithBaseURI creates an instance of the SQLResourcesClient client using a custom endpoint. Use -// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewSQLResourcesClientWithBaseURI(baseURI string, subscriptionID string) SQLResourcesClient { - return SQLResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateUpdateSQLContainer create or update an Azure Cosmos DB SQL container -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// containerName - cosmos DB container name. -// createUpdateSQLContainerParameters - the parameters to provide for the current SQL container. -func (client SQLResourcesClient) CreateUpdateSQLContainer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, createUpdateSQLContainerParameters SQLContainerCreateUpdateParameters) (result SQLResourcesCreateUpdateSQLContainerFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.CreateUpdateSQLContainer") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: createUpdateSQLContainerParameters, - Constraints: []validation.Constraint{{Target: "createUpdateSQLContainerParameters.SQLContainerCreateUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateSQLContainerParameters.SQLContainerCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateSQLContainerParameters.SQLContainerCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "createUpdateSQLContainerParameters.SQLContainerCreateUpdateProperties.Resource.PartitionKey", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "createUpdateSQLContainerParameters.SQLContainerCreateUpdateProperties.Resource.PartitionKey.Version", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "createUpdateSQLContainerParameters.SQLContainerCreateUpdateProperties.Resource.PartitionKey.Version", Name: validation.InclusiveMaximum, Rule: int64(2), Chain: nil}, - {Target: "createUpdateSQLContainerParameters.SQLContainerCreateUpdateProperties.Resource.PartitionKey.Version", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, - }}, - }}, - }}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "CreateUpdateSQLContainer", err.Error()) - } - - req, err := client.CreateUpdateSQLContainerPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, createUpdateSQLContainerParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLContainer", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateSQLContainerSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLContainer", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdateSQLContainerPreparer prepares the CreateUpdateSQLContainer request. -func (client SQLResourcesClient) CreateUpdateSQLContainerPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, createUpdateSQLContainerParameters SQLContainerCreateUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "containerName": autorest.Encode("path", containerName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}", pathParameters), - autorest.WithJSON(createUpdateSQLContainerParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateUpdateSQLContainerSender sends the CreateUpdateSQLContainer request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) CreateUpdateSQLContainerSender(req *http.Request) (future SQLResourcesCreateUpdateSQLContainerFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// CreateUpdateSQLContainerResponder handles the response to the CreateUpdateSQLContainer request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) CreateUpdateSQLContainerResponder(resp *http.Response) (result SQLContainerGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateUpdateSQLDatabase create or update an Azure Cosmos DB SQL database -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// createUpdateSQLDatabaseParameters - the parameters to provide for the current SQL database. -func (client SQLResourcesClient) CreateUpdateSQLDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateSQLDatabaseParameters SQLDatabaseCreateUpdateParameters) (result SQLResourcesCreateUpdateSQLDatabaseFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.CreateUpdateSQLDatabase") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: createUpdateSQLDatabaseParameters, - Constraints: []validation.Constraint{{Target: "createUpdateSQLDatabaseParameters.SQLDatabaseCreateUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateSQLDatabaseParameters.SQLDatabaseCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateSQLDatabaseParameters.SQLDatabaseCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "CreateUpdateSQLDatabase", err.Error()) - } - - req, err := client.CreateUpdateSQLDatabasePreparer(ctx, resourceGroupName, accountName, databaseName, createUpdateSQLDatabaseParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLDatabase", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateSQLDatabaseSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLDatabase", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdateSQLDatabasePreparer prepares the CreateUpdateSQLDatabase request. -func (client SQLResourcesClient) CreateUpdateSQLDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateSQLDatabaseParameters SQLDatabaseCreateUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}", pathParameters), - autorest.WithJSON(createUpdateSQLDatabaseParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateUpdateSQLDatabaseSender sends the CreateUpdateSQLDatabase request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) CreateUpdateSQLDatabaseSender(req *http.Request) (future SQLResourcesCreateUpdateSQLDatabaseFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// CreateUpdateSQLDatabaseResponder handles the response to the CreateUpdateSQLDatabase request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) CreateUpdateSQLDatabaseResponder(resp *http.Response) (result SQLDatabaseGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateUpdateSQLRoleAssignment creates or updates an Azure Cosmos DB SQL Role Assignment. -// Parameters: -// roleAssignmentID - the GUID for the Role Assignment. -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// createUpdateSQLRoleAssignmentParameters - the properties required to create or update a Role Assignment. -func (client SQLResourcesClient) CreateUpdateSQLRoleAssignment(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string, createUpdateSQLRoleAssignmentParameters SQLRoleAssignmentCreateUpdateParameters) (result SQLResourcesCreateUpdateSQLRoleAssignmentFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.CreateUpdateSQLRoleAssignment") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "CreateUpdateSQLRoleAssignment", err.Error()) - } - - req, err := client.CreateUpdateSQLRoleAssignmentPreparer(ctx, roleAssignmentID, resourceGroupName, accountName, createUpdateSQLRoleAssignmentParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLRoleAssignment", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateSQLRoleAssignmentSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLRoleAssignment", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdateSQLRoleAssignmentPreparer prepares the CreateUpdateSQLRoleAssignment request. -func (client SQLResourcesClient) CreateUpdateSQLRoleAssignmentPreparer(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string, createUpdateSQLRoleAssignmentParameters SQLRoleAssignmentCreateUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "roleAssignmentId": autorest.Encode("path", roleAssignmentID), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}", pathParameters), - autorest.WithJSON(createUpdateSQLRoleAssignmentParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateUpdateSQLRoleAssignmentSender sends the CreateUpdateSQLRoleAssignment request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) CreateUpdateSQLRoleAssignmentSender(req *http.Request) (future SQLResourcesCreateUpdateSQLRoleAssignmentFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// CreateUpdateSQLRoleAssignmentResponder handles the response to the CreateUpdateSQLRoleAssignment request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) CreateUpdateSQLRoleAssignmentResponder(resp *http.Response) (result SQLRoleAssignmentGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateUpdateSQLRoleDefinition creates or updates an Azure Cosmos DB SQL Role Definition. -// Parameters: -// roleDefinitionID - the GUID for the Role Definition. -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// createUpdateSQLRoleDefinitionParameters - the properties required to create or update a Role Definition. -func (client SQLResourcesClient) CreateUpdateSQLRoleDefinition(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string, createUpdateSQLRoleDefinitionParameters SQLRoleDefinitionCreateUpdateParameters) (result SQLResourcesCreateUpdateSQLRoleDefinitionFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.CreateUpdateSQLRoleDefinition") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "CreateUpdateSQLRoleDefinition", err.Error()) - } - - req, err := client.CreateUpdateSQLRoleDefinitionPreparer(ctx, roleDefinitionID, resourceGroupName, accountName, createUpdateSQLRoleDefinitionParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLRoleDefinition", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateSQLRoleDefinitionSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLRoleDefinition", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdateSQLRoleDefinitionPreparer prepares the CreateUpdateSQLRoleDefinition request. -func (client SQLResourcesClient) CreateUpdateSQLRoleDefinitionPreparer(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string, createUpdateSQLRoleDefinitionParameters SQLRoleDefinitionCreateUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "roleDefinitionId": autorest.Encode("path", roleDefinitionID), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}", pathParameters), - autorest.WithJSON(createUpdateSQLRoleDefinitionParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateUpdateSQLRoleDefinitionSender sends the CreateUpdateSQLRoleDefinition request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) CreateUpdateSQLRoleDefinitionSender(req *http.Request) (future SQLResourcesCreateUpdateSQLRoleDefinitionFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// CreateUpdateSQLRoleDefinitionResponder handles the response to the CreateUpdateSQLRoleDefinition request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) CreateUpdateSQLRoleDefinitionResponder(resp *http.Response) (result SQLRoleDefinitionGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateUpdateSQLStoredProcedure create or update an Azure Cosmos DB SQL storedProcedure -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// containerName - cosmos DB container name. -// storedProcedureName - cosmos DB storedProcedure name. -// createUpdateSQLStoredProcedureParameters - the parameters to provide for the current SQL storedProcedure. -func (client SQLResourcesClient) CreateUpdateSQLStoredProcedure(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string, createUpdateSQLStoredProcedureParameters SQLStoredProcedureCreateUpdateParameters) (result SQLResourcesCreateUpdateSQLStoredProcedureFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.CreateUpdateSQLStoredProcedure") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: createUpdateSQLStoredProcedureParameters, - Constraints: []validation.Constraint{{Target: "createUpdateSQLStoredProcedureParameters.SQLStoredProcedureCreateUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateSQLStoredProcedureParameters.SQLStoredProcedureCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateSQLStoredProcedureParameters.SQLStoredProcedureCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "CreateUpdateSQLStoredProcedure", err.Error()) - } - - req, err := client.CreateUpdateSQLStoredProcedurePreparer(ctx, resourceGroupName, accountName, databaseName, containerName, storedProcedureName, createUpdateSQLStoredProcedureParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLStoredProcedure", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateSQLStoredProcedureSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLStoredProcedure", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdateSQLStoredProcedurePreparer prepares the CreateUpdateSQLStoredProcedure request. -func (client SQLResourcesClient) CreateUpdateSQLStoredProcedurePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string, createUpdateSQLStoredProcedureParameters SQLStoredProcedureCreateUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "containerName": autorest.Encode("path", containerName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "storedProcedureName": autorest.Encode("path", storedProcedureName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}", pathParameters), - autorest.WithJSON(createUpdateSQLStoredProcedureParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateUpdateSQLStoredProcedureSender sends the CreateUpdateSQLStoredProcedure request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) CreateUpdateSQLStoredProcedureSender(req *http.Request) (future SQLResourcesCreateUpdateSQLStoredProcedureFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// CreateUpdateSQLStoredProcedureResponder handles the response to the CreateUpdateSQLStoredProcedure request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) CreateUpdateSQLStoredProcedureResponder(resp *http.Response) (result SQLStoredProcedureGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateUpdateSQLTrigger create or update an Azure Cosmos DB SQL trigger -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// containerName - cosmos DB container name. -// triggerName - cosmos DB trigger name. -// createUpdateSQLTriggerParameters - the parameters to provide for the current SQL trigger. -func (client SQLResourcesClient) CreateUpdateSQLTrigger(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string, createUpdateSQLTriggerParameters SQLTriggerCreateUpdateParameters) (result SQLResourcesCreateUpdateSQLTriggerFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.CreateUpdateSQLTrigger") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: createUpdateSQLTriggerParameters, - Constraints: []validation.Constraint{{Target: "createUpdateSQLTriggerParameters.SQLTriggerCreateUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateSQLTriggerParameters.SQLTriggerCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateSQLTriggerParameters.SQLTriggerCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "CreateUpdateSQLTrigger", err.Error()) - } - - req, err := client.CreateUpdateSQLTriggerPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, triggerName, createUpdateSQLTriggerParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLTrigger", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateSQLTriggerSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLTrigger", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdateSQLTriggerPreparer prepares the CreateUpdateSQLTrigger request. -func (client SQLResourcesClient) CreateUpdateSQLTriggerPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string, createUpdateSQLTriggerParameters SQLTriggerCreateUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "containerName": autorest.Encode("path", containerName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "triggerName": autorest.Encode("path", triggerName), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}", pathParameters), - autorest.WithJSON(createUpdateSQLTriggerParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateUpdateSQLTriggerSender sends the CreateUpdateSQLTrigger request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) CreateUpdateSQLTriggerSender(req *http.Request) (future SQLResourcesCreateUpdateSQLTriggerFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// CreateUpdateSQLTriggerResponder handles the response to the CreateUpdateSQLTrigger request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) CreateUpdateSQLTriggerResponder(resp *http.Response) (result SQLTriggerGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateUpdateSQLUserDefinedFunction create or update an Azure Cosmos DB SQL userDefinedFunction -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// containerName - cosmos DB container name. -// userDefinedFunctionName - cosmos DB userDefinedFunction name. -// createUpdateSQLUserDefinedFunctionParameters - the parameters to provide for the current SQL -// userDefinedFunction. -func (client SQLResourcesClient) CreateUpdateSQLUserDefinedFunction(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string, createUpdateSQLUserDefinedFunctionParameters SQLUserDefinedFunctionCreateUpdateParameters) (result SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.CreateUpdateSQLUserDefinedFunction") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: createUpdateSQLUserDefinedFunctionParameters, - Constraints: []validation.Constraint{{Target: "createUpdateSQLUserDefinedFunctionParameters.SQLUserDefinedFunctionCreateUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateSQLUserDefinedFunctionParameters.SQLUserDefinedFunctionCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateSQLUserDefinedFunctionParameters.SQLUserDefinedFunctionCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "CreateUpdateSQLUserDefinedFunction", err.Error()) - } - - req, err := client.CreateUpdateSQLUserDefinedFunctionPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, userDefinedFunctionName, createUpdateSQLUserDefinedFunctionParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLUserDefinedFunction", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateSQLUserDefinedFunctionSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "CreateUpdateSQLUserDefinedFunction", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdateSQLUserDefinedFunctionPreparer prepares the CreateUpdateSQLUserDefinedFunction request. -func (client SQLResourcesClient) CreateUpdateSQLUserDefinedFunctionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string, createUpdateSQLUserDefinedFunctionParameters SQLUserDefinedFunctionCreateUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "containerName": autorest.Encode("path", containerName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "userDefinedFunctionName": autorest.Encode("path", userDefinedFunctionName), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}", pathParameters), - autorest.WithJSON(createUpdateSQLUserDefinedFunctionParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateUpdateSQLUserDefinedFunctionSender sends the CreateUpdateSQLUserDefinedFunction request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) CreateUpdateSQLUserDefinedFunctionSender(req *http.Request) (future SQLResourcesCreateUpdateSQLUserDefinedFunctionFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// CreateUpdateSQLUserDefinedFunctionResponder handles the response to the CreateUpdateSQLUserDefinedFunction request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) CreateUpdateSQLUserDefinedFunctionResponder(resp *http.Response) (result SQLUserDefinedFunctionGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// DeleteSQLContainer deletes an existing Azure Cosmos DB SQL container. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// containerName - cosmos DB container name. -func (client SQLResourcesClient) DeleteSQLContainer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result SQLResourcesDeleteSQLContainerFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.DeleteSQLContainer") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "DeleteSQLContainer", err.Error()) - } - - req, err := client.DeleteSQLContainerPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLContainer", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSQLContainerSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLContainer", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteSQLContainerPreparer prepares the DeleteSQLContainer request. -func (client SQLResourcesClient) DeleteSQLContainerPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "containerName": autorest.Encode("path", containerName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSQLContainerSender sends the DeleteSQLContainer request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) DeleteSQLContainerSender(req *http.Request) (future SQLResourcesDeleteSQLContainerFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteSQLContainerResponder handles the response to the DeleteSQLContainer request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) DeleteSQLContainerResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// DeleteSQLDatabase deletes an existing Azure Cosmos DB SQL database. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client SQLResourcesClient) DeleteSQLDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result SQLResourcesDeleteSQLDatabaseFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.DeleteSQLDatabase") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "DeleteSQLDatabase", err.Error()) - } - - req, err := client.DeleteSQLDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLDatabase", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSQLDatabaseSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLDatabase", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteSQLDatabasePreparer prepares the DeleteSQLDatabase request. -func (client SQLResourcesClient) DeleteSQLDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSQLDatabaseSender sends the DeleteSQLDatabase request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) DeleteSQLDatabaseSender(req *http.Request) (future SQLResourcesDeleteSQLDatabaseFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteSQLDatabaseResponder handles the response to the DeleteSQLDatabase request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) DeleteSQLDatabaseResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// DeleteSQLRoleAssignment deletes an existing Azure Cosmos DB SQL Role Assignment. -// Parameters: -// roleAssignmentID - the GUID for the Role Assignment. -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client SQLResourcesClient) DeleteSQLRoleAssignment(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string) (result SQLResourcesDeleteSQLRoleAssignmentFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.DeleteSQLRoleAssignment") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "DeleteSQLRoleAssignment", err.Error()) - } - - req, err := client.DeleteSQLRoleAssignmentPreparer(ctx, roleAssignmentID, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLRoleAssignment", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSQLRoleAssignmentSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLRoleAssignment", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteSQLRoleAssignmentPreparer prepares the DeleteSQLRoleAssignment request. -func (client SQLResourcesClient) DeleteSQLRoleAssignmentPreparer(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "roleAssignmentId": autorest.Encode("path", roleAssignmentID), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSQLRoleAssignmentSender sends the DeleteSQLRoleAssignment request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) DeleteSQLRoleAssignmentSender(req *http.Request) (future SQLResourcesDeleteSQLRoleAssignmentFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteSQLRoleAssignmentResponder handles the response to the DeleteSQLRoleAssignment request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) DeleteSQLRoleAssignmentResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// DeleteSQLRoleDefinition deletes an existing Azure Cosmos DB SQL Role Definition. -// Parameters: -// roleDefinitionID - the GUID for the Role Definition. -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client SQLResourcesClient) DeleteSQLRoleDefinition(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string) (result SQLResourcesDeleteSQLRoleDefinitionFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.DeleteSQLRoleDefinition") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "DeleteSQLRoleDefinition", err.Error()) - } - - req, err := client.DeleteSQLRoleDefinitionPreparer(ctx, roleDefinitionID, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLRoleDefinition", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSQLRoleDefinitionSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLRoleDefinition", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteSQLRoleDefinitionPreparer prepares the DeleteSQLRoleDefinition request. -func (client SQLResourcesClient) DeleteSQLRoleDefinitionPreparer(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "roleDefinitionId": autorest.Encode("path", roleDefinitionID), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSQLRoleDefinitionSender sends the DeleteSQLRoleDefinition request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) DeleteSQLRoleDefinitionSender(req *http.Request) (future SQLResourcesDeleteSQLRoleDefinitionFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteSQLRoleDefinitionResponder handles the response to the DeleteSQLRoleDefinition request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) DeleteSQLRoleDefinitionResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// DeleteSQLStoredProcedure deletes an existing Azure Cosmos DB SQL storedProcedure. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// containerName - cosmos DB container name. -// storedProcedureName - cosmos DB storedProcedure name. -func (client SQLResourcesClient) DeleteSQLStoredProcedure(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string) (result SQLResourcesDeleteSQLStoredProcedureFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.DeleteSQLStoredProcedure") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "DeleteSQLStoredProcedure", err.Error()) - } - - req, err := client.DeleteSQLStoredProcedurePreparer(ctx, resourceGroupName, accountName, databaseName, containerName, storedProcedureName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLStoredProcedure", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSQLStoredProcedureSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLStoredProcedure", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteSQLStoredProcedurePreparer prepares the DeleteSQLStoredProcedure request. -func (client SQLResourcesClient) DeleteSQLStoredProcedurePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "containerName": autorest.Encode("path", containerName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "storedProcedureName": autorest.Encode("path", storedProcedureName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSQLStoredProcedureSender sends the DeleteSQLStoredProcedure request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) DeleteSQLStoredProcedureSender(req *http.Request) (future SQLResourcesDeleteSQLStoredProcedureFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteSQLStoredProcedureResponder handles the response to the DeleteSQLStoredProcedure request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) DeleteSQLStoredProcedureResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// DeleteSQLTrigger deletes an existing Azure Cosmos DB SQL trigger. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// containerName - cosmos DB container name. -// triggerName - cosmos DB trigger name. -func (client SQLResourcesClient) DeleteSQLTrigger(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string) (result SQLResourcesDeleteSQLTriggerFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.DeleteSQLTrigger") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "DeleteSQLTrigger", err.Error()) - } - - req, err := client.DeleteSQLTriggerPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, triggerName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLTrigger", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSQLTriggerSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLTrigger", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteSQLTriggerPreparer prepares the DeleteSQLTrigger request. -func (client SQLResourcesClient) DeleteSQLTriggerPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "containerName": autorest.Encode("path", containerName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "triggerName": autorest.Encode("path", triggerName), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSQLTriggerSender sends the DeleteSQLTrigger request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) DeleteSQLTriggerSender(req *http.Request) (future SQLResourcesDeleteSQLTriggerFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteSQLTriggerResponder handles the response to the DeleteSQLTrigger request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) DeleteSQLTriggerResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// DeleteSQLUserDefinedFunction deletes an existing Azure Cosmos DB SQL userDefinedFunction. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// containerName - cosmos DB container name. -// userDefinedFunctionName - cosmos DB userDefinedFunction name. -func (client SQLResourcesClient) DeleteSQLUserDefinedFunction(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string) (result SQLResourcesDeleteSQLUserDefinedFunctionFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.DeleteSQLUserDefinedFunction") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "DeleteSQLUserDefinedFunction", err.Error()) - } - - req, err := client.DeleteSQLUserDefinedFunctionPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, userDefinedFunctionName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLUserDefinedFunction", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSQLUserDefinedFunctionSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "DeleteSQLUserDefinedFunction", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteSQLUserDefinedFunctionPreparer prepares the DeleteSQLUserDefinedFunction request. -func (client SQLResourcesClient) DeleteSQLUserDefinedFunctionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "containerName": autorest.Encode("path", containerName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "userDefinedFunctionName": autorest.Encode("path", userDefinedFunctionName), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSQLUserDefinedFunctionSender sends the DeleteSQLUserDefinedFunction request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) DeleteSQLUserDefinedFunctionSender(req *http.Request) (future SQLResourcesDeleteSQLUserDefinedFunctionFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteSQLUserDefinedFunctionResponder handles the response to the DeleteSQLUserDefinedFunction request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) DeleteSQLUserDefinedFunctionResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// GetSQLContainer gets the SQL container under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// containerName - cosmos DB container name. -func (client SQLResourcesClient) GetSQLContainer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result SQLContainerGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLContainer") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLContainer", err.Error()) - } - - req, err := client.GetSQLContainerPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLContainer", nil, "Failure preparing request") - return - } - - resp, err := client.GetSQLContainerSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLContainer", resp, "Failure sending request") - return - } - - result, err = client.GetSQLContainerResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLContainer", resp, "Failure responding to request") - return - } - - return -} - -// GetSQLContainerPreparer prepares the GetSQLContainer request. -func (client SQLResourcesClient) GetSQLContainerPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "containerName": autorest.Encode("path", containerName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSQLContainerSender sends the GetSQLContainer request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) GetSQLContainerSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetSQLContainerResponder handles the response to the GetSQLContainer request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) GetSQLContainerResponder(resp *http.Response) (result SQLContainerGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetSQLContainerThroughput gets the RUs per second of the SQL container under an existing Azure Cosmos DB database -// account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// containerName - cosmos DB container name. -func (client SQLResourcesClient) GetSQLContainerThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result ThroughputSettingsGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLContainerThroughput") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLContainerThroughput", err.Error()) - } - - req, err := client.GetSQLContainerThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLContainerThroughput", nil, "Failure preparing request") - return - } - - resp, err := client.GetSQLContainerThroughputSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLContainerThroughput", resp, "Failure sending request") - return - } - - result, err = client.GetSQLContainerThroughputResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLContainerThroughput", resp, "Failure responding to request") - return - } - - return -} - -// GetSQLContainerThroughputPreparer prepares the GetSQLContainerThroughput request. -func (client SQLResourcesClient) GetSQLContainerThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "containerName": autorest.Encode("path", containerName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSQLContainerThroughputSender sends the GetSQLContainerThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) GetSQLContainerThroughputSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetSQLContainerThroughputResponder handles the response to the GetSQLContainerThroughput request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) GetSQLContainerThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetSQLDatabase gets the SQL database under an existing Azure Cosmos DB database account with the provided name. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client SQLResourcesClient) GetSQLDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result SQLDatabaseGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLDatabase") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLDatabase", err.Error()) - } - - req, err := client.GetSQLDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLDatabase", nil, "Failure preparing request") - return - } - - resp, err := client.GetSQLDatabaseSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLDatabase", resp, "Failure sending request") - return - } - - result, err = client.GetSQLDatabaseResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLDatabase", resp, "Failure responding to request") - return - } - - return -} - -// GetSQLDatabasePreparer prepares the GetSQLDatabase request. -func (client SQLResourcesClient) GetSQLDatabasePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSQLDatabaseSender sends the GetSQLDatabase request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) GetSQLDatabaseSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetSQLDatabaseResponder handles the response to the GetSQLDatabase request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) GetSQLDatabaseResponder(resp *http.Response) (result SQLDatabaseGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetSQLDatabaseThroughput gets the RUs per second of the SQL database under an existing Azure Cosmos DB database -// account with the provided name. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client SQLResourcesClient) GetSQLDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result ThroughputSettingsGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLDatabaseThroughput") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLDatabaseThroughput", err.Error()) - } - - req, err := client.GetSQLDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLDatabaseThroughput", nil, "Failure preparing request") - return - } - - resp, err := client.GetSQLDatabaseThroughputSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLDatabaseThroughput", resp, "Failure sending request") - return - } - - result, err = client.GetSQLDatabaseThroughputResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLDatabaseThroughput", resp, "Failure responding to request") - return - } - - return -} - -// GetSQLDatabaseThroughputPreparer prepares the GetSQLDatabaseThroughput request. -func (client SQLResourcesClient) GetSQLDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSQLDatabaseThroughputSender sends the GetSQLDatabaseThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) GetSQLDatabaseThroughputSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetSQLDatabaseThroughputResponder handles the response to the GetSQLDatabaseThroughput request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) GetSQLDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetSQLRoleAssignment retrieves the properties of an existing Azure Cosmos DB SQL Role Assignment with the given Id. -// Parameters: -// roleAssignmentID - the GUID for the Role Assignment. -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client SQLResourcesClient) GetSQLRoleAssignment(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string) (result SQLRoleAssignmentGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLRoleAssignment") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLRoleAssignment", err.Error()) - } - - req, err := client.GetSQLRoleAssignmentPreparer(ctx, roleAssignmentID, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLRoleAssignment", nil, "Failure preparing request") - return - } - - resp, err := client.GetSQLRoleAssignmentSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLRoleAssignment", resp, "Failure sending request") - return - } - - result, err = client.GetSQLRoleAssignmentResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLRoleAssignment", resp, "Failure responding to request") - return - } - - return -} - -// GetSQLRoleAssignmentPreparer prepares the GetSQLRoleAssignment request. -func (client SQLResourcesClient) GetSQLRoleAssignmentPreparer(ctx context.Context, roleAssignmentID string, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "roleAssignmentId": autorest.Encode("path", roleAssignmentID), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSQLRoleAssignmentSender sends the GetSQLRoleAssignment request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) GetSQLRoleAssignmentSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetSQLRoleAssignmentResponder handles the response to the GetSQLRoleAssignment request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) GetSQLRoleAssignmentResponder(resp *http.Response) (result SQLRoleAssignmentGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetSQLRoleDefinition retrieves the properties of an existing Azure Cosmos DB SQL Role Definition with the given Id. -// Parameters: -// roleDefinitionID - the GUID for the Role Definition. -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client SQLResourcesClient) GetSQLRoleDefinition(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string) (result SQLRoleDefinitionGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLRoleDefinition") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLRoleDefinition", err.Error()) - } - - req, err := client.GetSQLRoleDefinitionPreparer(ctx, roleDefinitionID, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLRoleDefinition", nil, "Failure preparing request") - return - } - - resp, err := client.GetSQLRoleDefinitionSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLRoleDefinition", resp, "Failure sending request") - return - } - - result, err = client.GetSQLRoleDefinitionResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLRoleDefinition", resp, "Failure responding to request") - return - } - - return -} - -// GetSQLRoleDefinitionPreparer prepares the GetSQLRoleDefinition request. -func (client SQLResourcesClient) GetSQLRoleDefinitionPreparer(ctx context.Context, roleDefinitionID string, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "roleDefinitionId": autorest.Encode("path", roleDefinitionID), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSQLRoleDefinitionSender sends the GetSQLRoleDefinition request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) GetSQLRoleDefinitionSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetSQLRoleDefinitionResponder handles the response to the GetSQLRoleDefinition request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) GetSQLRoleDefinitionResponder(resp *http.Response) (result SQLRoleDefinitionGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetSQLStoredProcedure gets the SQL storedProcedure under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// containerName - cosmos DB container name. -// storedProcedureName - cosmos DB storedProcedure name. -func (client SQLResourcesClient) GetSQLStoredProcedure(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string) (result SQLStoredProcedureGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLStoredProcedure") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLStoredProcedure", err.Error()) - } - - req, err := client.GetSQLStoredProcedurePreparer(ctx, resourceGroupName, accountName, databaseName, containerName, storedProcedureName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLStoredProcedure", nil, "Failure preparing request") - return - } - - resp, err := client.GetSQLStoredProcedureSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLStoredProcedure", resp, "Failure sending request") - return - } - - result, err = client.GetSQLStoredProcedureResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLStoredProcedure", resp, "Failure responding to request") - return - } - - return -} - -// GetSQLStoredProcedurePreparer prepares the GetSQLStoredProcedure request. -func (client SQLResourcesClient) GetSQLStoredProcedurePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, storedProcedureName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "containerName": autorest.Encode("path", containerName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "storedProcedureName": autorest.Encode("path", storedProcedureName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSQLStoredProcedureSender sends the GetSQLStoredProcedure request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) GetSQLStoredProcedureSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetSQLStoredProcedureResponder handles the response to the GetSQLStoredProcedure request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) GetSQLStoredProcedureResponder(resp *http.Response) (result SQLStoredProcedureGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetSQLTrigger gets the SQL trigger under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// containerName - cosmos DB container name. -// triggerName - cosmos DB trigger name. -func (client SQLResourcesClient) GetSQLTrigger(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string) (result SQLTriggerGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLTrigger") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLTrigger", err.Error()) - } - - req, err := client.GetSQLTriggerPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, triggerName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLTrigger", nil, "Failure preparing request") - return - } - - resp, err := client.GetSQLTriggerSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLTrigger", resp, "Failure sending request") - return - } - - result, err = client.GetSQLTriggerResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLTrigger", resp, "Failure responding to request") - return - } - - return -} - -// GetSQLTriggerPreparer prepares the GetSQLTrigger request. -func (client SQLResourcesClient) GetSQLTriggerPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "containerName": autorest.Encode("path", containerName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "triggerName": autorest.Encode("path", triggerName), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSQLTriggerSender sends the GetSQLTrigger request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) GetSQLTriggerSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetSQLTriggerResponder handles the response to the GetSQLTrigger request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) GetSQLTriggerResponder(resp *http.Response) (result SQLTriggerGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetSQLUserDefinedFunction gets the SQL userDefinedFunction under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// containerName - cosmos DB container name. -// userDefinedFunctionName - cosmos DB userDefinedFunction name. -func (client SQLResourcesClient) GetSQLUserDefinedFunction(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string) (result SQLUserDefinedFunctionGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.GetSQLUserDefinedFunction") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "GetSQLUserDefinedFunction", err.Error()) - } - - req, err := client.GetSQLUserDefinedFunctionPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, userDefinedFunctionName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLUserDefinedFunction", nil, "Failure preparing request") - return - } - - resp, err := client.GetSQLUserDefinedFunctionSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLUserDefinedFunction", resp, "Failure sending request") - return - } - - result, err = client.GetSQLUserDefinedFunctionResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "GetSQLUserDefinedFunction", resp, "Failure responding to request") - return - } - - return -} - -// GetSQLUserDefinedFunctionPreparer prepares the GetSQLUserDefinedFunction request. -func (client SQLResourcesClient) GetSQLUserDefinedFunctionPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "containerName": autorest.Encode("path", containerName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "userDefinedFunctionName": autorest.Encode("path", userDefinedFunctionName), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSQLUserDefinedFunctionSender sends the GetSQLUserDefinedFunction request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) GetSQLUserDefinedFunctionSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetSQLUserDefinedFunctionResponder handles the response to the GetSQLUserDefinedFunction request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) GetSQLUserDefinedFunctionResponder(resp *http.Response) (result SQLUserDefinedFunctionGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListSQLContainers lists the SQL container under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client SQLResourcesClient) ListSQLContainers(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result SQLContainerListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.ListSQLContainers") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "ListSQLContainers", err.Error()) - } - - req, err := client.ListSQLContainersPreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLContainers", nil, "Failure preparing request") - return - } - - resp, err := client.ListSQLContainersSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLContainers", resp, "Failure sending request") - return - } - - result, err = client.ListSQLContainersResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLContainers", resp, "Failure responding to request") - return - } - - return -} - -// ListSQLContainersPreparer prepares the ListSQLContainers request. -func (client SQLResourcesClient) ListSQLContainersPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSQLContainersSender sends the ListSQLContainers request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) ListSQLContainersSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListSQLContainersResponder handles the response to the ListSQLContainers request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) ListSQLContainersResponder(resp *http.Response) (result SQLContainerListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListSQLDatabases lists the SQL databases under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client SQLResourcesClient) ListSQLDatabases(ctx context.Context, resourceGroupName string, accountName string) (result SQLDatabaseListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.ListSQLDatabases") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "ListSQLDatabases", err.Error()) - } - - req, err := client.ListSQLDatabasesPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLDatabases", nil, "Failure preparing request") - return - } - - resp, err := client.ListSQLDatabasesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLDatabases", resp, "Failure sending request") - return - } - - result, err = client.ListSQLDatabasesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLDatabases", resp, "Failure responding to request") - return - } - - return -} - -// ListSQLDatabasesPreparer prepares the ListSQLDatabases request. -func (client SQLResourcesClient) ListSQLDatabasesPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSQLDatabasesSender sends the ListSQLDatabases request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) ListSQLDatabasesSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListSQLDatabasesResponder handles the response to the ListSQLDatabases request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) ListSQLDatabasesResponder(resp *http.Response) (result SQLDatabaseListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListSQLRoleAssignments retrieves the list of all Azure Cosmos DB SQL Role Assignments. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client SQLResourcesClient) ListSQLRoleAssignments(ctx context.Context, resourceGroupName string, accountName string) (result SQLRoleAssignmentListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.ListSQLRoleAssignments") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "ListSQLRoleAssignments", err.Error()) - } - - req, err := client.ListSQLRoleAssignmentsPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLRoleAssignments", nil, "Failure preparing request") - return - } - - resp, err := client.ListSQLRoleAssignmentsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLRoleAssignments", resp, "Failure sending request") - return - } - - result, err = client.ListSQLRoleAssignmentsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLRoleAssignments", resp, "Failure responding to request") - return - } - - return -} - -// ListSQLRoleAssignmentsPreparer prepares the ListSQLRoleAssignments request. -func (client SQLResourcesClient) ListSQLRoleAssignmentsPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSQLRoleAssignmentsSender sends the ListSQLRoleAssignments request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) ListSQLRoleAssignmentsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListSQLRoleAssignmentsResponder handles the response to the ListSQLRoleAssignments request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) ListSQLRoleAssignmentsResponder(resp *http.Response) (result SQLRoleAssignmentListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListSQLRoleDefinitions retrieves the list of all Azure Cosmos DB SQL Role Definitions. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client SQLResourcesClient) ListSQLRoleDefinitions(ctx context.Context, resourceGroupName string, accountName string) (result SQLRoleDefinitionListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.ListSQLRoleDefinitions") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "ListSQLRoleDefinitions", err.Error()) - } - - req, err := client.ListSQLRoleDefinitionsPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLRoleDefinitions", nil, "Failure preparing request") - return - } - - resp, err := client.ListSQLRoleDefinitionsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLRoleDefinitions", resp, "Failure sending request") - return - } - - result, err = client.ListSQLRoleDefinitionsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLRoleDefinitions", resp, "Failure responding to request") - return - } - - return -} - -// ListSQLRoleDefinitionsPreparer prepares the ListSQLRoleDefinitions request. -func (client SQLResourcesClient) ListSQLRoleDefinitionsPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSQLRoleDefinitionsSender sends the ListSQLRoleDefinitions request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) ListSQLRoleDefinitionsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListSQLRoleDefinitionsResponder handles the response to the ListSQLRoleDefinitions request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) ListSQLRoleDefinitionsResponder(resp *http.Response) (result SQLRoleDefinitionListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListSQLStoredProcedures lists the SQL storedProcedure under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// containerName - cosmos DB container name. -func (client SQLResourcesClient) ListSQLStoredProcedures(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result SQLStoredProcedureListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.ListSQLStoredProcedures") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "ListSQLStoredProcedures", err.Error()) - } - - req, err := client.ListSQLStoredProceduresPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLStoredProcedures", nil, "Failure preparing request") - return - } - - resp, err := client.ListSQLStoredProceduresSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLStoredProcedures", resp, "Failure sending request") - return - } - - result, err = client.ListSQLStoredProceduresResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLStoredProcedures", resp, "Failure responding to request") - return - } - - return -} - -// ListSQLStoredProceduresPreparer prepares the ListSQLStoredProcedures request. -func (client SQLResourcesClient) ListSQLStoredProceduresPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "containerName": autorest.Encode("path", containerName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSQLStoredProceduresSender sends the ListSQLStoredProcedures request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) ListSQLStoredProceduresSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListSQLStoredProceduresResponder handles the response to the ListSQLStoredProcedures request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) ListSQLStoredProceduresResponder(resp *http.Response) (result SQLStoredProcedureListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListSQLTriggers lists the SQL trigger under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// containerName - cosmos DB container name. -func (client SQLResourcesClient) ListSQLTriggers(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result SQLTriggerListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.ListSQLTriggers") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "ListSQLTriggers", err.Error()) - } - - req, err := client.ListSQLTriggersPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLTriggers", nil, "Failure preparing request") - return - } - - resp, err := client.ListSQLTriggersSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLTriggers", resp, "Failure sending request") - return - } - - result, err = client.ListSQLTriggersResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLTriggers", resp, "Failure responding to request") - return - } - - return -} - -// ListSQLTriggersPreparer prepares the ListSQLTriggers request. -func (client SQLResourcesClient) ListSQLTriggersPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "containerName": autorest.Encode("path", containerName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSQLTriggersSender sends the ListSQLTriggers request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) ListSQLTriggersSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListSQLTriggersResponder handles the response to the ListSQLTriggers request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) ListSQLTriggersResponder(resp *http.Response) (result SQLTriggerListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListSQLUserDefinedFunctions lists the SQL userDefinedFunction under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// containerName - cosmos DB container name. -func (client SQLResourcesClient) ListSQLUserDefinedFunctions(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result SQLUserDefinedFunctionListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.ListSQLUserDefinedFunctions") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "ListSQLUserDefinedFunctions", err.Error()) - } - - req, err := client.ListSQLUserDefinedFunctionsPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLUserDefinedFunctions", nil, "Failure preparing request") - return - } - - resp, err := client.ListSQLUserDefinedFunctionsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLUserDefinedFunctions", resp, "Failure sending request") - return - } - - result, err = client.ListSQLUserDefinedFunctionsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "ListSQLUserDefinedFunctions", resp, "Failure responding to request") - return - } - - return -} - -// ListSQLUserDefinedFunctionsPreparer prepares the ListSQLUserDefinedFunctions request. -func (client SQLResourcesClient) ListSQLUserDefinedFunctionsPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "containerName": autorest.Encode("path", containerName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSQLUserDefinedFunctionsSender sends the ListSQLUserDefinedFunctions request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) ListSQLUserDefinedFunctionsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListSQLUserDefinedFunctionsResponder handles the response to the ListSQLUserDefinedFunctions request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) ListSQLUserDefinedFunctionsResponder(resp *http.Response) (result SQLUserDefinedFunctionListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// MigrateSQLContainerToAutoscale migrate an Azure Cosmos DB SQL container from manual throughput to autoscale -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// containerName - cosmos DB container name. -func (client SQLResourcesClient) MigrateSQLContainerToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result SQLResourcesMigrateSQLContainerToAutoscaleFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.MigrateSQLContainerToAutoscale") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "MigrateSQLContainerToAutoscale", err.Error()) - } - - req, err := client.MigrateSQLContainerToAutoscalePreparer(ctx, resourceGroupName, accountName, databaseName, containerName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLContainerToAutoscale", nil, "Failure preparing request") - return - } - - result, err = client.MigrateSQLContainerToAutoscaleSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLContainerToAutoscale", result.Response(), "Failure sending request") - return - } - - return -} - -// MigrateSQLContainerToAutoscalePreparer prepares the MigrateSQLContainerToAutoscale request. -func (client SQLResourcesClient) MigrateSQLContainerToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "containerName": autorest.Encode("path", containerName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/migrateToAutoscale", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// MigrateSQLContainerToAutoscaleSender sends the MigrateSQLContainerToAutoscale request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) MigrateSQLContainerToAutoscaleSender(req *http.Request) (future SQLResourcesMigrateSQLContainerToAutoscaleFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// MigrateSQLContainerToAutoscaleResponder handles the response to the MigrateSQLContainerToAutoscale request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) MigrateSQLContainerToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// MigrateSQLContainerToManualThroughput migrate an Azure Cosmos DB SQL container from autoscale to manual throughput -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// containerName - cosmos DB container name. -func (client SQLResourcesClient) MigrateSQLContainerToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result SQLResourcesMigrateSQLContainerToManualThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.MigrateSQLContainerToManualThroughput") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "MigrateSQLContainerToManualThroughput", err.Error()) - } - - req, err := client.MigrateSQLContainerToManualThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLContainerToManualThroughput", nil, "Failure preparing request") - return - } - - result, err = client.MigrateSQLContainerToManualThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLContainerToManualThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// MigrateSQLContainerToManualThroughputPreparer prepares the MigrateSQLContainerToManualThroughput request. -func (client SQLResourcesClient) MigrateSQLContainerToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "containerName": autorest.Encode("path", containerName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/migrateToManualThroughput", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// MigrateSQLContainerToManualThroughputSender sends the MigrateSQLContainerToManualThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) MigrateSQLContainerToManualThroughputSender(req *http.Request) (future SQLResourcesMigrateSQLContainerToManualThroughputFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// MigrateSQLContainerToManualThroughputResponder handles the response to the MigrateSQLContainerToManualThroughput request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) MigrateSQLContainerToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// MigrateSQLDatabaseToAutoscale migrate an Azure Cosmos DB SQL database from manual throughput to autoscale -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client SQLResourcesClient) MigrateSQLDatabaseToAutoscale(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result SQLResourcesMigrateSQLDatabaseToAutoscaleFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.MigrateSQLDatabaseToAutoscale") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "MigrateSQLDatabaseToAutoscale", err.Error()) - } - - req, err := client.MigrateSQLDatabaseToAutoscalePreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLDatabaseToAutoscale", nil, "Failure preparing request") - return - } - - result, err = client.MigrateSQLDatabaseToAutoscaleSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLDatabaseToAutoscale", result.Response(), "Failure sending request") - return - } - - return -} - -// MigrateSQLDatabaseToAutoscalePreparer prepares the MigrateSQLDatabaseToAutoscale request. -func (client SQLResourcesClient) MigrateSQLDatabaseToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// MigrateSQLDatabaseToAutoscaleSender sends the MigrateSQLDatabaseToAutoscale request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) MigrateSQLDatabaseToAutoscaleSender(req *http.Request) (future SQLResourcesMigrateSQLDatabaseToAutoscaleFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// MigrateSQLDatabaseToAutoscaleResponder handles the response to the MigrateSQLDatabaseToAutoscale request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) MigrateSQLDatabaseToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// MigrateSQLDatabaseToManualThroughput migrate an Azure Cosmos DB SQL database from autoscale to manual throughput -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client SQLResourcesClient) MigrateSQLDatabaseToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result SQLResourcesMigrateSQLDatabaseToManualThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.MigrateSQLDatabaseToManualThroughput") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "MigrateSQLDatabaseToManualThroughput", err.Error()) - } - - req, err := client.MigrateSQLDatabaseToManualThroughputPreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLDatabaseToManualThroughput", nil, "Failure preparing request") - return - } - - result, err = client.MigrateSQLDatabaseToManualThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "MigrateSQLDatabaseToManualThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// MigrateSQLDatabaseToManualThroughputPreparer prepares the MigrateSQLDatabaseToManualThroughput request. -func (client SQLResourcesClient) MigrateSQLDatabaseToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// MigrateSQLDatabaseToManualThroughputSender sends the MigrateSQLDatabaseToManualThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) MigrateSQLDatabaseToManualThroughputSender(req *http.Request) (future SQLResourcesMigrateSQLDatabaseToManualThroughputFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// MigrateSQLDatabaseToManualThroughputResponder handles the response to the MigrateSQLDatabaseToManualThroughput request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) MigrateSQLDatabaseToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// RetrieveContinuousBackupInformation retrieves continuous backup information for a container resource. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// containerName - cosmos DB container name. -// location - the name of the continuous backup restore location. -func (client SQLResourcesClient) RetrieveContinuousBackupInformation(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, location ContinuousBackupRestoreLocation) (result SQLResourcesRetrieveContinuousBackupInformationFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.RetrieveContinuousBackupInformation") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "RetrieveContinuousBackupInformation", err.Error()) - } - - req, err := client.RetrieveContinuousBackupInformationPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, location) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "RetrieveContinuousBackupInformation", nil, "Failure preparing request") - return - } - - result, err = client.RetrieveContinuousBackupInformationSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "RetrieveContinuousBackupInformation", result.Response(), "Failure sending request") - return - } - - return -} - -// RetrieveContinuousBackupInformationPreparer prepares the RetrieveContinuousBackupInformation request. -func (client SQLResourcesClient) RetrieveContinuousBackupInformationPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, location ContinuousBackupRestoreLocation) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "containerName": autorest.Encode("path", containerName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/retrieveContinuousBackupInformation", pathParameters), - autorest.WithJSON(location), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// RetrieveContinuousBackupInformationSender sends the RetrieveContinuousBackupInformation request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) RetrieveContinuousBackupInformationSender(req *http.Request) (future SQLResourcesRetrieveContinuousBackupInformationFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// RetrieveContinuousBackupInformationResponder handles the response to the RetrieveContinuousBackupInformation request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) RetrieveContinuousBackupInformationResponder(resp *http.Response) (result BackupInformation, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// UpdateSQLContainerThroughput update RUs per second of an Azure Cosmos DB SQL container -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// containerName - cosmos DB container name. -// updateThroughputParameters - the parameters to provide for the RUs per second of the current SQL container. -func (client SQLResourcesClient) UpdateSQLContainerThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result SQLResourcesUpdateSQLContainerThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.UpdateSQLContainerThroughput") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: updateThroughputParameters, - Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, - }}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "UpdateSQLContainerThroughput", err.Error()) - } - - req, err := client.UpdateSQLContainerThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, updateThroughputParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "UpdateSQLContainerThroughput", nil, "Failure preparing request") - return - } - - result, err = client.UpdateSQLContainerThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "UpdateSQLContainerThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdateSQLContainerThroughputPreparer prepares the UpdateSQLContainerThroughput request. -func (client SQLResourcesClient) UpdateSQLContainerThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "containerName": autorest.Encode("path", containerName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default", pathParameters), - autorest.WithJSON(updateThroughputParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateSQLContainerThroughputSender sends the UpdateSQLContainerThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) UpdateSQLContainerThroughputSender(req *http.Request) (future SQLResourcesUpdateSQLContainerThroughputFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// UpdateSQLContainerThroughputResponder handles the response to the UpdateSQLContainerThroughput request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) UpdateSQLContainerThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// UpdateSQLDatabaseThroughput update RUs per second of an Azure Cosmos DB SQL database -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// updateThroughputParameters - the parameters to provide for the RUs per second of the current SQL database. -func (client SQLResourcesClient) UpdateSQLDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result SQLResourcesUpdateSQLDatabaseThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SQLResourcesClient.UpdateSQLDatabaseThroughput") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: updateThroughputParameters, - Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, - }}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.SQLResourcesClient", "UpdateSQLDatabaseThroughput", err.Error()) - } - - req, err := client.UpdateSQLDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, updateThroughputParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "UpdateSQLDatabaseThroughput", nil, "Failure preparing request") - return - } - - result, err = client.UpdateSQLDatabaseThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.SQLResourcesClient", "UpdateSQLDatabaseThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdateSQLDatabaseThroughputPreparer prepares the UpdateSQLDatabaseThroughput request. -func (client SQLResourcesClient) UpdateSQLDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "databaseName": autorest.Encode("path", databaseName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default", pathParameters), - autorest.WithJSON(updateThroughputParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateSQLDatabaseThroughputSender sends the UpdateSQLDatabaseThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client SQLResourcesClient) UpdateSQLDatabaseThroughputSender(req *http.Request) (future SQLResourcesUpdateSQLDatabaseThroughputFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// UpdateSQLDatabaseThroughputResponder handles the response to the UpdateSQLDatabaseThroughput request. The method always -// closes the http.Response Body. -func (client SQLResourcesClient) UpdateSQLDatabaseThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/tableresources.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/tableresources.go deleted file mode 100644 index 1ee023ea103b..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/tableresources.go +++ /dev/null @@ -1,791 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// TableResourcesClient is the client for the TableResources methods of the Documentdb service. -type TableResourcesClient struct { - BaseClient -} - -// NewTableResourcesClient creates an instance of the TableResourcesClient client. -func NewTableResourcesClient(subscriptionID string) TableResourcesClient { - return NewTableResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewTableResourcesClientWithBaseURI creates an instance of the TableResourcesClient client using a custom endpoint. -// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewTableResourcesClientWithBaseURI(baseURI string, subscriptionID string) TableResourcesClient { - return TableResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateUpdateTable create or update an Azure Cosmos DB Table -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// tableName - cosmos DB table name. -// createUpdateTableParameters - the parameters to provide for the current Table. -func (client TableResourcesClient) CreateUpdateTable(ctx context.Context, resourceGroupName string, accountName string, tableName string, createUpdateTableParameters TableCreateUpdateParameters) (result TableResourcesCreateUpdateTableFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.CreateUpdateTable") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: createUpdateTableParameters, - Constraints: []validation.Constraint{{Target: "createUpdateTableParameters.TableCreateUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateTableParameters.TableCreateUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "createUpdateTableParameters.TableCreateUpdateProperties.Resource.ID", Name: validation.Null, Rule: true, Chain: nil}}}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.TableResourcesClient", "CreateUpdateTable", err.Error()) - } - - req, err := client.CreateUpdateTablePreparer(ctx, resourceGroupName, accountName, tableName, createUpdateTableParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "CreateUpdateTable", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateTableSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "CreateUpdateTable", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdateTablePreparer prepares the CreateUpdateTable request. -func (client TableResourcesClient) CreateUpdateTablePreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string, createUpdateTableParameters TableCreateUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "tableName": autorest.Encode("path", tableName), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}", pathParameters), - autorest.WithJSON(createUpdateTableParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateUpdateTableSender sends the CreateUpdateTable request. The method will close the -// http.Response Body if it receives an error. -func (client TableResourcesClient) CreateUpdateTableSender(req *http.Request) (future TableResourcesCreateUpdateTableFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// CreateUpdateTableResponder handles the response to the CreateUpdateTable request. The method always -// closes the http.Response Body. -func (client TableResourcesClient) CreateUpdateTableResponder(resp *http.Response) (result TableGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// DeleteTable deletes an existing Azure Cosmos DB Table. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// tableName - cosmos DB table name. -func (client TableResourcesClient) DeleteTable(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result TableResourcesDeleteTableFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.DeleteTable") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.TableResourcesClient", "DeleteTable", err.Error()) - } - - req, err := client.DeleteTablePreparer(ctx, resourceGroupName, accountName, tableName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "DeleteTable", nil, "Failure preparing request") - return - } - - result, err = client.DeleteTableSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "DeleteTable", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteTablePreparer prepares the DeleteTable request. -func (client TableResourcesClient) DeleteTablePreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "tableName": autorest.Encode("path", tableName), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteTableSender sends the DeleteTable request. The method will close the -// http.Response Body if it receives an error. -func (client TableResourcesClient) DeleteTableSender(req *http.Request) (future TableResourcesDeleteTableFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteTableResponder handles the response to the DeleteTable request. The method always -// closes the http.Response Body. -func (client TableResourcesClient) DeleteTableResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// GetTable gets the Tables under an existing Azure Cosmos DB database account with the provided name. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// tableName - cosmos DB table name. -func (client TableResourcesClient) GetTable(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result TableGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.GetTable") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.TableResourcesClient", "GetTable", err.Error()) - } - - req, err := client.GetTablePreparer(ctx, resourceGroupName, accountName, tableName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTable", nil, "Failure preparing request") - return - } - - resp, err := client.GetTableSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTable", resp, "Failure sending request") - return - } - - result, err = client.GetTableResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTable", resp, "Failure responding to request") - return - } - - return -} - -// GetTablePreparer prepares the GetTable request. -func (client TableResourcesClient) GetTablePreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "tableName": autorest.Encode("path", tableName), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetTableSender sends the GetTable request. The method will close the -// http.Response Body if it receives an error. -func (client TableResourcesClient) GetTableSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetTableResponder handles the response to the GetTable request. The method always -// closes the http.Response Body. -func (client TableResourcesClient) GetTableResponder(resp *http.Response) (result TableGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetTableThroughput gets the RUs per second of the Table under an existing Azure Cosmos DB database account with the -// provided name. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// tableName - cosmos DB table name. -func (client TableResourcesClient) GetTableThroughput(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result ThroughputSettingsGetResults, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.GetTableThroughput") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.TableResourcesClient", "GetTableThroughput", err.Error()) - } - - req, err := client.GetTableThroughputPreparer(ctx, resourceGroupName, accountName, tableName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTableThroughput", nil, "Failure preparing request") - return - } - - resp, err := client.GetTableThroughputSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTableThroughput", resp, "Failure sending request") - return - } - - result, err = client.GetTableThroughputResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "GetTableThroughput", resp, "Failure responding to request") - return - } - - return -} - -// GetTableThroughputPreparer prepares the GetTableThroughput request. -func (client TableResourcesClient) GetTableThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "tableName": autorest.Encode("path", tableName), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetTableThroughputSender sends the GetTableThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client TableResourcesClient) GetTableThroughputSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetTableThroughputResponder handles the response to the GetTableThroughput request. The method always -// closes the http.Response Body. -func (client TableResourcesClient) GetTableThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListTables lists the Tables under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -func (client TableResourcesClient) ListTables(ctx context.Context, resourceGroupName string, accountName string) (result TableListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.ListTables") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.TableResourcesClient", "ListTables", err.Error()) - } - - req, err := client.ListTablesPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "ListTables", nil, "Failure preparing request") - return - } - - resp, err := client.ListTablesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "ListTables", resp, "Failure sending request") - return - } - - result, err = client.ListTablesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "ListTables", resp, "Failure responding to request") - return - } - - return -} - -// ListTablesPreparer prepares the ListTables request. -func (client TableResourcesClient) ListTablesPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListTablesSender sends the ListTables request. The method will close the -// http.Response Body if it receives an error. -func (client TableResourcesClient) ListTablesSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListTablesResponder handles the response to the ListTables request. The method always -// closes the http.Response Body. -func (client TableResourcesClient) ListTablesResponder(resp *http.Response) (result TableListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// MigrateTableToAutoscale migrate an Azure Cosmos DB Table from manual throughput to autoscale -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// tableName - cosmos DB table name. -func (client TableResourcesClient) MigrateTableToAutoscale(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result TableResourcesMigrateTableToAutoscaleFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.MigrateTableToAutoscale") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.TableResourcesClient", "MigrateTableToAutoscale", err.Error()) - } - - req, err := client.MigrateTableToAutoscalePreparer(ctx, resourceGroupName, accountName, tableName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "MigrateTableToAutoscale", nil, "Failure preparing request") - return - } - - result, err = client.MigrateTableToAutoscaleSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "MigrateTableToAutoscale", result.Response(), "Failure sending request") - return - } - - return -} - -// MigrateTableToAutoscalePreparer prepares the MigrateTableToAutoscale request. -func (client TableResourcesClient) MigrateTableToAutoscalePreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "tableName": autorest.Encode("path", tableName), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToAutoscale", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// MigrateTableToAutoscaleSender sends the MigrateTableToAutoscale request. The method will close the -// http.Response Body if it receives an error. -func (client TableResourcesClient) MigrateTableToAutoscaleSender(req *http.Request) (future TableResourcesMigrateTableToAutoscaleFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// MigrateTableToAutoscaleResponder handles the response to the MigrateTableToAutoscale request. The method always -// closes the http.Response Body. -func (client TableResourcesClient) MigrateTableToAutoscaleResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// MigrateTableToManualThroughput migrate an Azure Cosmos DB Table from autoscale to manual throughput -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// tableName - cosmos DB table name. -func (client TableResourcesClient) MigrateTableToManualThroughput(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result TableResourcesMigrateTableToManualThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.MigrateTableToManualThroughput") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}}); err != nil { - return result, validation.NewError("documentdb.TableResourcesClient", "MigrateTableToManualThroughput", err.Error()) - } - - req, err := client.MigrateTableToManualThroughputPreparer(ctx, resourceGroupName, accountName, tableName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "MigrateTableToManualThroughput", nil, "Failure preparing request") - return - } - - result, err = client.MigrateTableToManualThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "MigrateTableToManualThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// MigrateTableToManualThroughputPreparer prepares the MigrateTableToManualThroughput request. -func (client TableResourcesClient) MigrateTableToManualThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "tableName": autorest.Encode("path", tableName), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// MigrateTableToManualThroughputSender sends the MigrateTableToManualThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client TableResourcesClient) MigrateTableToManualThroughputSender(req *http.Request) (future TableResourcesMigrateTableToManualThroughputFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// MigrateTableToManualThroughputResponder handles the response to the MigrateTableToManualThroughput request. The method always -// closes the http.Response Body. -func (client TableResourcesClient) MigrateTableToManualThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// UpdateTableThroughput update RUs per second of an Azure Cosmos DB Table -// Parameters: -// resourceGroupName - the name of the resource group. The name is case insensitive. -// accountName - cosmos DB database account name. -// tableName - cosmos DB table name. -// updateThroughputParameters - the parameters to provide for the RUs per second of the current Table. -func (client TableResourcesClient) UpdateTableThroughput(ctx context.Context, resourceGroupName string, accountName string, tableName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (result TableResourcesUpdateTableThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TableResourcesClient.UpdateTableThroughput") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: client.SubscriptionID, - Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: accountName, - Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}, - {Target: "accountName", Name: validation.Pattern, Rule: `^[a-z0-9]+(-[a-z0-9]+)*`, Chain: nil}}}, - {TargetValue: updateThroughputParameters, - Constraints: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputSettingsUpdateProperties.Resource.AutoscaleSettings.MaxThroughput", Name: validation.Null, Rule: true, Chain: nil}}}, - }}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.TableResourcesClient", "UpdateTableThroughput", err.Error()) - } - - req, err := client.UpdateTableThroughputPreparer(ctx, resourceGroupName, accountName, tableName, updateThroughputParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "UpdateTableThroughput", nil, "Failure preparing request") - return - } - - result, err = client.UpdateTableThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.TableResourcesClient", "UpdateTableThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdateTableThroughputPreparer prepares the UpdateTableThroughput request. -func (client TableResourcesClient) UpdateTableThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string, updateThroughputParameters ThroughputSettingsUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "accountName": autorest.Encode("path", accountName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "tableName": autorest.Encode("path", tableName), - } - - const APIVersion = "2021-10-15" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default", pathParameters), - autorest.WithJSON(updateThroughputParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateTableThroughputSender sends the UpdateTableThroughput request. The method will close the -// http.Response Body if it receives an error. -func (client TableResourcesClient) UpdateTableThroughputSender(req *http.Request) (future TableResourcesUpdateTableThroughputFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// UpdateTableThroughputResponder handles the response to the UpdateTableThroughput request. The method always -// closes the http.Response Body. -func (client TableResourcesClient) UpdateTableThroughputResponder(resp *http.Response) (result ThroughputSettingsGetResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/version.go deleted file mode 100644 index 43ef7d8c9442..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb/version.go +++ /dev/null @@ -1,19 +0,0 @@ -package documentdb - -import "github.com/Azure/azure-sdk-for-go/version" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -// UserAgent returns the UserAgent string to use when sending http.Requests. -func UserAgent() string { - return "Azure-SDK-For-Go/" + Version() + " documentdb/2021-10-15" -} - -// Version returns the semantic version (see http://semver.org) of the client. -func Version() string { - return version.Number -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/README.md new file mode 100644 index 000000000000..8af2345f983c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/README.md @@ -0,0 +1,142 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs` Documentation + +The `rbacs` SDK allows for interaction with Azure Resource Manager `cosmosdb` (API Version `2024-08-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-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/client.go new file mode 100644 index 000000000000..9cefbe649f15 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/constants.go new file mode 100644 index 000000000000..cd3d7b42489e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/id_account.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/id_account.go new file mode 100644 index 000000000000..2fd416725b1a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/id_databaseaccount.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/id_databaseaccount.go new file mode 100644 index 000000000000..eea55d3e5179 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/id_sqlroledefinition.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/id_sqlroledefinition.go new file mode 100644 index 000000000000..fb415467ab6a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourcescreateupdatesqlroleassignment.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourcescreateupdatesqlroleassignment.go new file mode 100644 index 000000000000..661fe68a2566 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourcescreateupdatesqlroledefinition.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourcescreateupdatesqlroledefinition.go new file mode 100644 index 000000000000..417071a8e0f2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourcesdeletesqlroleassignment.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourcesdeletesqlroleassignment.go new file mode 100644 index 000000000000..4e82837391d8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourcesdeletesqlroledefinition.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourcesdeletesqlroledefinition.go new file mode 100644 index 000000000000..f20835ad9d15 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourcesgetsqlroleassignment.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourcesgetsqlroleassignment.go new file mode 100644 index 000000000000..1efc15a0de1a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourcesgetsqlroledefinition.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourcesgetsqlroledefinition.go new file mode 100644 index 000000000000..b666f08154dd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourceslistsqlroleassignments.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourceslistsqlroleassignments.go new file mode 100644 index 000000000000..9eb8653b0c69 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourceslistsqlroledefinitions.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/method_sqlresourceslistsqlroledefinitions.go new file mode 100644 index 000000000000..7bb5cae75cda --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_permission.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_permission.go new file mode 100644 index 000000000000..24d9bca3c0a4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroleassignmentcreateupdateparameters.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroleassignmentcreateupdateparameters.go new file mode 100644 index 000000000000..47669dad1e17 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroleassignmentgetresults.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroleassignmentgetresults.go new file mode 100644 index 000000000000..0e5ca69111e7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroleassignmentlistresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroleassignmentlistresult.go new file mode 100644 index 000000000000..2c06d7a8b6b7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroleassignmentresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroleassignmentresource.go new file mode 100644 index 000000000000..d0fd52b9ebab --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroledefinitioncreateupdateparameters.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroledefinitioncreateupdateparameters.go new file mode 100644 index 000000000000..8730b9d84c28 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroledefinitiongetresults.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroledefinitiongetresults.go new file mode 100644 index 000000000000..a4a1075a9d48 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroledefinitionlistresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroledefinitionlistresult.go new file mode 100644 index 000000000000..1ed45a2fbed9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroledefinitionresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/model_sqlroledefinitionresource.go new file mode 100644 index 000000000000..9cb98e76faab --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs/version.go new file mode 100644 index 000000000000..81187e7beea2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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-08-15" + +func userAgent() string { + return "hashicorp/go-azure-sdk/rbacs/2024-08-15" +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/README.md new file mode 100644 index 000000000000..db7c4c0ccc76 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/README.md @@ -0,0 +1,313 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables` Documentation + +The `restorables` SDK allows for interaction with Azure Resource Manager `cosmosdb` (API Version `2024-08-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-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/client.go new file mode 100644 index 000000000000..9192fc9307ee --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/constants.go new file mode 100644 index 000000000000..bbebc3160139 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/constants.go @@ -0,0 +1,468 @@ +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 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 +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/id_container.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/id_container.go new file mode 100644 index 000000000000..cc01b7113aa6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/id_graph.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/id_graph.go new file mode 100644 index 000000000000..b5c11de6742a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/id_location.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/id_location.go new file mode 100644 index 000000000000..c7c3d4a6d23f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/id_mongodbdatabasecollection.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/id_mongodbdatabasecollection.go new file mode 100644 index 000000000000..863a29287de2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/id_restorabledatabaseaccount.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/id_restorabledatabaseaccount.go new file mode 100644 index 000000000000..712ea35cfc01 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/id_table.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/id_table.go new file mode 100644 index 000000000000..6b9e3c73fa67 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_gremlinresourcesretrievecontinuousbackupinformation.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_gremlinresourcesretrievecontinuousbackupinformation.go new file mode 100644 index 000000000000..3b539897d941 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_mongodbresourcesretrievecontinuousbackupinformation.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_mongodbresourcesretrievecontinuousbackupinformation.go new file mode 100644 index 000000000000..dda7adc24cb9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorabledatabaseaccountsgetbylocation.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorabledatabaseaccountsgetbylocation.go new file mode 100644 index 000000000000..536ceceb108b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorabledatabaseaccountslist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorabledatabaseaccountslist.go new file mode 100644 index 000000000000..874c2df23eb6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorabledatabaseaccountslistbylocation.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorabledatabaseaccountslistbylocation.go new file mode 100644 index 000000000000..b3d00c3082df --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablegremlindatabaseslist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablegremlindatabaseslist.go new file mode 100644 index 000000000000..1de1530f1c5d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablegremlingraphslist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablegremlingraphslist.go new file mode 100644 index 000000000000..8c1c9bcc1c86 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablegremlinresourceslist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablegremlinresourceslist.go new file mode 100644 index 000000000000..ed88ce785d04 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablemongodbcollectionslist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablemongodbcollectionslist.go new file mode 100644 index 000000000000..634d30fb9b65 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablemongodbdatabaseslist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablemongodbdatabaseslist.go new file mode 100644 index 000000000000..70bff11cfac5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablemongodbresourceslist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablemongodbresourceslist.go new file mode 100644 index 000000000000..b9c7d94bfd8f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablesqlcontainerslist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablesqlcontainerslist.go new file mode 100644 index 000000000000..c2c8624e6a37 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablesqldatabaseslist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablesqldatabaseslist.go new file mode 100644 index 000000000000..7b15c2d9b251 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablesqlresourceslist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorablesqlresourceslist.go new file mode 100644 index 000000000000..e326137bb937 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorabletableresourceslist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorabletableresourceslist.go new file mode 100644 index 000000000000..9fb261ac67c6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorabletableslist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_restorabletableslist.go new file mode 100644 index 000000000000..fd4c0a4039d4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_sqlresourcesretrievecontinuousbackupinformation.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_sqlresourcesretrievecontinuousbackupinformation.go new file mode 100644 index 000000000000..4cca46834e3a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_tableresourcesretrievecontinuousbackupinformation.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/method_tableresourcesretrievecontinuousbackupinformation.go new file mode 100644 index 000000000000..ef4959d98fce --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_backupinformation.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_backupinformation.go new file mode 100644 index 000000000000..252b355762b6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_clientencryptionincludedpath.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_clientencryptionincludedpath.go new file mode 100644 index 000000000000..fde02d2b667d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_clientencryptionpolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_clientencryptionpolicy.go new file mode 100644 index 000000000000..1abcb79f2f9a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_compositepath.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_compositepath.go new file mode 100644 index 000000000000..1e5f31a060d9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_computedproperty.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_computedproperty.go new file mode 100644 index 000000000000..972c6499d796 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_conflictresolutionpolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_conflictresolutionpolicy.go new file mode 100644 index 000000000000..49e2f60f055f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_containerpartitionkey.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_containerpartitionkey.go new file mode 100644 index 000000000000..40b9f6fa57cc --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_continuousbackupinformation.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_continuousbackupinformation.go new file mode 100644 index 000000000000..08f4cd99cb0b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_continuousbackuprestorelocation.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_continuousbackuprestorelocation.go new file mode 100644 index 000000000000..81af64b38594 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_excludedpath.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_excludedpath.go new file mode 100644 index 000000000000..9a23b9630497 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_includedpath.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_includedpath.go new file mode 100644 index 000000000000..a39913bd1f7c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_indexes.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_indexes.go new file mode 100644 index 000000000000..7e5f75bfb357 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_indexingpolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_indexingpolicy.go new file mode 100644 index 000000000000..8960ee68467b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_indexingpolicy.go @@ -0,0 +1,13 @@ +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"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabledatabaseaccountgetresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabledatabaseaccountgetresult.go new file mode 100644 index 000000000000..d0bc6d5723c0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabledatabaseaccountproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabledatabaseaccountproperties.go new file mode 100644 index 000000000000..84d357fa180f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabledatabaseaccountslistresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabledatabaseaccountslistresult.go new file mode 100644 index 000000000000..011fe15450f7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlindatabasegetresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlindatabasegetresult.go new file mode 100644 index 000000000000..052f580229e5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlindatabaseproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlindatabaseproperties.go new file mode 100644 index 000000000000..7a6154a26a37 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlindatabasepropertiesresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlindatabasepropertiesresource.go new file mode 100644 index 000000000000..997401db6964 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlindatabaseslistresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlindatabaseslistresult.go new file mode 100644 index 000000000000..4f34856779c0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlingraphgetresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlingraphgetresult.go new file mode 100644 index 000000000000..e43546d5cd0e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlingraphproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlingraphproperties.go new file mode 100644 index 000000000000..c1c934d20c74 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlingraphpropertiesresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlingraphpropertiesresource.go new file mode 100644 index 000000000000..ad79d792d5dd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlingraphslistresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlingraphslistresult.go new file mode 100644 index 000000000000..e70760618f37 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlinresourcesgetresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlinresourcesgetresult.go new file mode 100644 index 000000000000..6675d26da5a3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlinresourceslistresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablegremlinresourceslistresult.go new file mode 100644 index 000000000000..8f395217fdd6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablelocationresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablelocationresource.go new file mode 100644 index 000000000000..46fbc7b9554e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbcollectiongetresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbcollectiongetresult.go new file mode 100644 index 000000000000..aa03383b64fd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbcollectionproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbcollectionproperties.go new file mode 100644 index 000000000000..64d6647f7803 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbcollectionpropertiesresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbcollectionpropertiesresource.go new file mode 100644 index 000000000000..456acc7c3a8a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbcollectionslistresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbcollectionslistresult.go new file mode 100644 index 000000000000..960b7afb530e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbdatabasegetresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbdatabasegetresult.go new file mode 100644 index 000000000000..8c46448769f8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbdatabaseproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbdatabaseproperties.go new file mode 100644 index 000000000000..867e6d3526ea --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbdatabasepropertiesresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbdatabasepropertiesresource.go new file mode 100644 index 000000000000..3c020336b2ba --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbdatabaseslistresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbdatabaseslistresult.go new file mode 100644 index 000000000000..70b6395d7864 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbresourcesgetresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbresourcesgetresult.go new file mode 100644 index 000000000000..6c028f2a915b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbresourceslistresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablemongodbresourceslistresult.go new file mode 100644 index 000000000000..aad5dab17f15 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqlcontainergetresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqlcontainergetresult.go new file mode 100644 index 000000000000..a12b19b4d307 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqlcontainerproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqlcontainerproperties.go new file mode 100644 index 000000000000..c8edea828731 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqlcontainerpropertiesresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqlcontainerpropertiesresource.go new file mode 100644 index 000000000000..a21a5337cabc --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqlcontainerpropertiesresourcecontainer.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqlcontainerpropertiesresourcecontainer.go new file mode 100644 index 000000000000..1a7668577396 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqlcontainerpropertiesresourcecontainer.go @@ -0,0 +1,22 @@ +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"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqlcontainerslistresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqlcontainerslistresult.go new file mode 100644 index 000000000000..8c2421f9df26 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqldatabasegetresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqldatabasegetresult.go new file mode 100644 index 000000000000..c3d4c8d28573 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqldatabaseproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqldatabaseproperties.go new file mode 100644 index 000000000000..38b127122167 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqldatabasepropertiesresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqldatabasepropertiesresource.go new file mode 100644 index 000000000000..7ac70fc326e1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqldatabasepropertiesresourcedatabase.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqldatabasepropertiesresourcedatabase.go new file mode 100644 index 000000000000..ff04d5b2e517 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqldatabaseslistresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqldatabaseslistresult.go new file mode 100644 index 000000000000..a536abebab5f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqlresourcesgetresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqlresourcesgetresult.go new file mode 100644 index 000000000000..9b75a0323388 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqlresourceslistresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorablesqlresourceslistresult.go new file mode 100644 index 000000000000..30f82c4ee4b0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabletablegetresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabletablegetresult.go new file mode 100644 index 000000000000..d1ae1330d7f4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabletableproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabletableproperties.go new file mode 100644 index 000000000000..982ec6b4b2a6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabletablepropertiesresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabletablepropertiesresource.go new file mode 100644 index 000000000000..637c198c239a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabletableresourcesgetresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabletableresourcesgetresult.go new file mode 100644 index 000000000000..6d06efbb1ad6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabletableresourceslistresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabletableresourceslistresult.go new file mode 100644 index 000000000000..021455f4326b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabletableslistresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restorabletableslistresult.go new file mode 100644 index 000000000000..640831007a36 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restoreparametersbase.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_restoreparametersbase.go new file mode 100644 index 000000000000..72e50f652e1e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_spatialspec.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_spatialspec.go new file mode 100644 index 000000000000..5aac192f5bf8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_uniquekey.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_uniquekey.go new file mode 100644 index 000000000000..efdebecc55be --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_uniquekeypolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/model_uniquekeypolicy.go new file mode 100644 index 000000000000..d9ddcb04a308 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables/version.go new file mode 100644 index 000000000000..e2f2c8256352 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-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-08-15" + +func userAgent() string { + return "hashicorp/go-azure-sdk/restorables/2024-08-15" +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 87b908200e4f..36e1657647df 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -5,7 +5,6 @@ dario.cat/mergo ## explicit github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2020-09-01/cdn github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2021-06-01/cdn -github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2021-10-15/documentdb github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2021-06-01-preview/policy github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security github.com/Azure/azure-sdk-for-go/services/preview/securityinsight/mgmt/2021-09-01-preview/securityinsight @@ -453,6 +452,8 @@ github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2022-05-15/sqldedica github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2022-11-15/mongorbacs github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2023-04-15/managedcassandras github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/cosmosdb +github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs +github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/restorables github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2023-08-01/exports github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2023-08-01/scheduledactions github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2023-08-01/views From 67f705e1c0b58ba07dc2cdd433f4503cf7521818 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:55:23 -0600 Subject: [PATCH 23/25] make document-fix --- website/docs/d/cosmosdb_mongo_database.html.markdown | 6 ++++++ .../d/cosmosdb_restorable_database_accounts.html.markdown | 6 ++++++ website/docs/d/cosmosdb_sql_database.html.markdown | 6 ++++++ website/docs/d/cosmosdb_sql_role_definition.html.markdown | 6 ++++++ website/docs/r/cosmosdb_cassandra_keyspace.html.markdown | 6 ++++++ website/docs/r/cosmosdb_cassandra_table.html.markdown | 6 ++++++ website/docs/r/cosmosdb_mongo_collection.html.markdown | 6 ++++++ website/docs/r/cosmosdb_mongo_database.html.markdown | 6 ++++++ website/docs/r/cosmosdb_sql_database.html.markdown | 6 ++++++ website/docs/r/cosmosdb_sql_function.html.markdown | 6 ++++++ website/docs/r/cosmosdb_sql_role_assignment.html.markdown | 6 ++++++ website/docs/r/cosmosdb_sql_role_definition.html.markdown | 6 ++++++ website/docs/r/cosmosdb_sql_stored_procedure.html.markdown | 6 ++++++ website/docs/r/cosmosdb_sql_trigger.html.markdown | 6 ++++++ website/docs/r/cosmosdb_table.html.markdown | 6 ++++++ 15 files changed, 90 insertions(+) diff --git a/website/docs/d/cosmosdb_mongo_database.html.markdown b/website/docs/d/cosmosdb_mongo_database.html.markdown index 6712bfe996f9..ab9618bbd951 100644 --- a/website/docs/d/cosmosdb_mongo_database.html.markdown +++ b/website/docs/d/cosmosdb_mongo_database.html.markdown @@ -47,3 +47,9 @@ In addition to the Arguments listed above - the following Attributes are exporte The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/configure#define-operation-timeouts) for certain actions: * `read` - (Defaults to 5 minutes) Used when retrieving the Cosmos Mongo Database. + +## API Providers + +This data source uses the following Azure API Providers: + +* `Microsoft.DocumentDB` - 2024-08-15 diff --git a/website/docs/d/cosmosdb_restorable_database_accounts.html.markdown b/website/docs/d/cosmosdb_restorable_database_accounts.html.markdown index b0b07cad42a0..0bbba86b3c58 100644 --- a/website/docs/d/cosmosdb_restorable_database_accounts.html.markdown +++ b/website/docs/d/cosmosdb_restorable_database_accounts.html.markdown @@ -70,3 +70,9 @@ An `restorable_locations` block exports the following: The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/configure#define-operation-timeouts) for certain actions: * `read` - (Defaults to 5 minutes) Used when retrieving the Cosmos DB Restorable Database Accounts. + +## API Providers + +This data source uses the following Azure API Providers: + +* `Microsoft.DocumentDB` - 2024-08-15 diff --git a/website/docs/d/cosmosdb_sql_database.html.markdown b/website/docs/d/cosmosdb_sql_database.html.markdown index 7f321720daa2..69845cd02563 100644 --- a/website/docs/d/cosmosdb_sql_database.html.markdown +++ b/website/docs/d/cosmosdb_sql_database.html.markdown @@ -52,3 +52,9 @@ An `autoscale_settings` block supports the following: The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/configure#define-operation-timeouts) for certain actions: * `read` - (Defaults to 5 minutes) Used when retrieving the CosmosDB SQL Database. + +## API Providers + +This data source uses the following Azure API Providers: + +* `Microsoft.DocumentDB` - 2024-08-15 diff --git a/website/docs/d/cosmosdb_sql_role_definition.html.markdown b/website/docs/d/cosmosdb_sql_role_definition.html.markdown index 57a3b4649e1b..eccd703e3ebb 100644 --- a/website/docs/d/cosmosdb_sql_role_definition.html.markdown +++ b/website/docs/d/cosmosdb_sql_role_definition.html.markdown @@ -55,3 +55,9 @@ A `permissions` block supports the following: The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/configure#define-operation-timeouts) for certain actions: * `read` - (Defaults to 5 minutes) Used when retrieving the Cosmos DB SQL Role Definition. + +## API Providers + +This data source uses the following Azure API Providers: + +* `Microsoft.DocumentDB` - 2024-08-15 diff --git a/website/docs/r/cosmosdb_cassandra_keyspace.html.markdown b/website/docs/r/cosmosdb_cassandra_keyspace.html.markdown index b253b344b1b5..f04ac791ba85 100644 --- a/website/docs/r/cosmosdb_cassandra_keyspace.html.markdown +++ b/website/docs/r/cosmosdb_cassandra_keyspace.html.markdown @@ -92,3 +92,9 @@ Cosmos Cassandra KeySpace can be imported using the `resource id`, e.g. ```shell terraform import azurerm_cosmosdb_cassandra_keyspace.ks1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/account1/cassandraKeyspaces/ks1 ``` + +## API Providers + +This resource uses the following Azure API Providers: + +* `Microsoft.DocumentDB` - 2024-08-15 diff --git a/website/docs/r/cosmosdb_cassandra_table.html.markdown b/website/docs/r/cosmosdb_cassandra_table.html.markdown index dd93ea473ee0..d720e0fa18fa 100644 --- a/website/docs/r/cosmosdb_cassandra_table.html.markdown +++ b/website/docs/r/cosmosdb_cassandra_table.html.markdown @@ -145,3 +145,9 @@ Cosmos Cassandra Table can be imported using the `resource id`, e.g. ```shell terraform import azurerm_cosmosdb_cassandra_table.ks1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/account1/cassandraKeyspaces/ks1/tables/table1 ``` + +## API Providers + +This resource uses the following Azure API Providers: + +* `Microsoft.DocumentDB` - 2024-08-15 diff --git a/website/docs/r/cosmosdb_mongo_collection.html.markdown b/website/docs/r/cosmosdb_mongo_collection.html.markdown index 38dad63f5955..36cc45f1cfb9 100644 --- a/website/docs/r/cosmosdb_mongo_collection.html.markdown +++ b/website/docs/r/cosmosdb_mongo_collection.html.markdown @@ -106,3 +106,9 @@ CosmosDB Mongo Collection can be imported using the `resource id`, e.g. ```shell terraform import azurerm_cosmosdb_mongo_collection.collection1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/account1/mongodbDatabases/db1/collections/collection1 ``` + +## API Providers + +This resource uses the following Azure API Providers: + +* `Microsoft.DocumentDB` - 2024-08-15 diff --git a/website/docs/r/cosmosdb_mongo_database.html.markdown b/website/docs/r/cosmosdb_mongo_database.html.markdown index ae59a62598f8..4d98402f3adb 100644 --- a/website/docs/r/cosmosdb_mongo_database.html.markdown +++ b/website/docs/r/cosmosdb_mongo_database.html.markdown @@ -72,3 +72,9 @@ Cosmos Mongo Database can be imported using the `resource id`, e.g. ```shell terraform import azurerm_cosmosdb_mongo_database.db1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/account1/mongodbDatabases/db1 ``` + +## API Providers + +This resource uses the following Azure API Providers: + +* `Microsoft.DocumentDB` - 2024-08-15 diff --git a/website/docs/r/cosmosdb_sql_database.html.markdown b/website/docs/r/cosmosdb_sql_database.html.markdown index b10620ab059a..75ff4e71f942 100644 --- a/website/docs/r/cosmosdb_sql_database.html.markdown +++ b/website/docs/r/cosmosdb_sql_database.html.markdown @@ -72,3 +72,9 @@ Cosmos SQL Database can be imported using the `resource id`, e.g. ```shell terraform import azurerm_cosmosdb_sql_database.db1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/db1 ``` + +## API Providers + +This resource uses the following Azure API Providers: + +* `Microsoft.DocumentDB` - 2024-08-15 diff --git a/website/docs/r/cosmosdb_sql_function.html.markdown b/website/docs/r/cosmosdb_sql_function.html.markdown index e6a47c9a495d..7a347eb50b0b 100644 --- a/website/docs/r/cosmosdb_sql_function.html.markdown +++ b/website/docs/r/cosmosdb_sql_function.html.markdown @@ -72,3 +72,9 @@ SQL User Defined Functions can be imported using the `resource id`, e.g. ```shell terraform import azurerm_cosmosdb_sql_function.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1/userDefinedFunctions/userDefinedFunction1 ``` + +## API Providers + +This resource uses the following Azure API Providers: + +* `Microsoft.DocumentDB` - 2024-08-15 diff --git a/website/docs/r/cosmosdb_sql_role_assignment.html.markdown b/website/docs/r/cosmosdb_sql_role_assignment.html.markdown index ff0a0283fb74..7c69bf909f35 100644 --- a/website/docs/r/cosmosdb_sql_role_assignment.html.markdown +++ b/website/docs/r/cosmosdb_sql_role_assignment.html.markdown @@ -97,3 +97,9 @@ Cosmos DB SQL Role Assignments can be imported using the `resource id`, e.g. ```shell terraform import azurerm_cosmosdb_sql_role_assignment.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlRoleAssignments/9e007587-dbcd-4190-84cb-fcab5a09ca39 ``` + +## API Providers + +This resource uses the following Azure API Providers: + +* `Microsoft.DocumentDB` - 2024-08-15 diff --git a/website/docs/r/cosmosdb_sql_role_definition.html.markdown b/website/docs/r/cosmosdb_sql_role_definition.html.markdown index edffc95c1e37..88911cf9c16c 100644 --- a/website/docs/r/cosmosdb_sql_role_definition.html.markdown +++ b/website/docs/r/cosmosdb_sql_role_definition.html.markdown @@ -100,3 +100,9 @@ Cosmos DB SQL Role Definitions can be imported using the `resource id`, e.g. ```shell terraform import azurerm_cosmosdb_sql_role_definition.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlRoleDefinitions/28b3c337-f436-482b-a167-c2618dc52033 ``` + +## API Providers + +This resource uses the following Azure API Providers: + +* `Microsoft.DocumentDB` - 2024-08-15 diff --git a/website/docs/r/cosmosdb_sql_stored_procedure.html.markdown b/website/docs/r/cosmosdb_sql_stored_procedure.html.markdown index 22e1f507ff1e..4a83e1af5118 100644 --- a/website/docs/r/cosmosdb_sql_stored_procedure.html.markdown +++ b/website/docs/r/cosmosdb_sql_stored_procedure.html.markdown @@ -84,3 +84,9 @@ CosmosDB SQL Stored Procedures can be imported using the `resource id`, e.g. ```shell terraform import azurerm_cosmosdb_sql_stored_procedure.db1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/db1/containers/c1/storedProcedures/sp1 ``` + +## API Providers + +This resource uses the following Azure API Providers: + +* `Microsoft.DocumentDB` - 2024-08-15 diff --git a/website/docs/r/cosmosdb_sql_trigger.html.markdown b/website/docs/r/cosmosdb_sql_trigger.html.markdown index de88d8d9afec..954fd0bce0c9 100644 --- a/website/docs/r/cosmosdb_sql_trigger.html.markdown +++ b/website/docs/r/cosmosdb_sql_trigger.html.markdown @@ -78,3 +78,9 @@ SQL Triggers can be imported using the `resource id`, e.g. ```shell terraform import azurerm_cosmosdb_sql_trigger.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1/triggers/trigger1 ``` + +## API Providers + +This resource uses the following Azure API Providers: + +* `Microsoft.DocumentDB` - 2024-08-15 diff --git a/website/docs/r/cosmosdb_table.html.markdown b/website/docs/r/cosmosdb_table.html.markdown index 39499da5f75f..322249c7e882 100644 --- a/website/docs/r/cosmosdb_table.html.markdown +++ b/website/docs/r/cosmosdb_table.html.markdown @@ -72,3 +72,9 @@ CosmosDB Tables can be imported using the `resource id`, e.g. ```shell terraform import azurerm_cosmosdb_table.table1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/account1/tables/table1 ``` + +## API Providers + +This resource uses the following Azure API Providers: + +* `Microsoft.DocumentDB` - 2024-08-15 From 7c283a08efe58a2e5c4f9139044a8d68d78a4f15 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 30 Mar 2026 11:07:42 -0600 Subject: [PATCH 24/25] linting --- .../services/cosmos/cosmosdb_mongo_collection_resource.go | 1 - .../cosmos/cosmosdb_sql_role_definition_data_source.go | 3 ++- .../services/cosmos/cosmosdb_sql_role_definition_resource.go | 2 +- internal/services/cosmos/cosmosdb_sql_trigger_resource.go | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/services/cosmos/cosmosdb_mongo_collection_resource.go b/internal/services/cosmos/cosmosdb_mongo_collection_resource.go index edfab2832114..dc33022dc379 100644 --- a/internal/services/cosmos/cosmosdb_mongo_collection_resource.go +++ b/internal/services/cosmos/cosmosdb_mongo_collection_resource.go @@ -320,7 +320,6 @@ func resourceCosmosDbMongoCollectionRead(d *pluginsdk.ResourceData, meta interfa if resp.Model != nil { if props := resp.Model.Properties; props != nil { if res := props.Resource; res != nil { - // you can only have one if l := len(pointer.From(res.ShardKey)); l > 2 { return fmt.Errorf("unexpected number of shard keys: %d", l) diff --git a/internal/services/cosmos/cosmosdb_sql_role_definition_data_source.go b/internal/services/cosmos/cosmosdb_sql_role_definition_data_source.go index 61d0f5641076..7b743fdc1171 100644 --- a/internal/services/cosmos/cosmosdb_sql_role_definition_data_source.go +++ b/internal/services/cosmos/cosmosdb_sql_role_definition_data_source.go @@ -7,6 +7,7 @@ import ( "fmt" "time" + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-sdk/resource-manager/cosmosdb/2024-08-15/rbacs" @@ -103,7 +104,7 @@ func dataSourceCosmosDbSQLRoleDefinitionRead(d *pluginsdk.ResourceData, meta int if props := resp.Model.Properties; props != nil { d.Set("assignable_scopes", utils.FlattenStringSlice(props.AssignableScopes)) d.Set("name", props.RoleName) - d.Set("type", props.Type) + d.Set("type", pointer.FromEnum(props.Type)) if err := d.Set("permissions", flattenSqlRoleDefinitionPermissions(props.Permissions)); err != nil { return fmt.Errorf("setting `permissions`: %+v", err) diff --git a/internal/services/cosmos/cosmosdb_sql_role_definition_resource.go b/internal/services/cosmos/cosmosdb_sql_role_definition_resource.go index c96a7c012cf7..ee1eed74519a 100644 --- a/internal/services/cosmos/cosmosdb_sql_role_definition_resource.go +++ b/internal/services/cosmos/cosmosdb_sql_role_definition_resource.go @@ -180,7 +180,7 @@ func resourceCosmosDbSQLRoleDefinitionRead(d *pluginsdk.ResourceData, meta inter if props := resp.Model.Properties; props != nil { d.Set("assignable_scopes", utils.FlattenStringSlice(props.AssignableScopes)) d.Set("name", props.RoleName) - d.Set("type", props.Type) + d.Set("type", pointer.FromEnum(props.Type)) if err := d.Set("permissions", flattenSqlRoleDefinitionPermissions(props.Permissions)); err != nil { return fmt.Errorf("setting `permissions`: %+v", err) diff --git a/internal/services/cosmos/cosmosdb_sql_trigger_resource.go b/internal/services/cosmos/cosmosdb_sql_trigger_resource.go index fb18ccbe195e..fb6f09ef7338 100644 --- a/internal/services/cosmos/cosmosdb_sql_trigger_resource.go +++ b/internal/services/cosmos/cosmosdb_sql_trigger_resource.go @@ -152,8 +152,8 @@ func resourceCosmosDbSQLTriggerRead(d *pluginsdk.ResourceData, meta interface{}) if props := resp.Model.Properties; props != nil { if r := props.Resource; r != nil { d.Set("body", r.Body) - d.Set("operation", r.TriggerOperation) - d.Set("type", r.TriggerType) + d.Set("operation", pointer.FromEnum(r.TriggerOperation)) + d.Set("type", pointer.FromEnum(r.TriggerType)) } } } From 692998df65db2b26b312e774647b812bd6f8fb3b Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 6 Apr 2026 09:06:13 -0600 Subject: [PATCH 25/25] fix id references --- internal/services/cosmos/cosmosdb_mongo_collection_resource.go | 2 +- .../services/cosmos/cosmosdb_mongo_role_definition_resource.go | 2 +- .../services/cosmos/cosmosdb_sql_role_assignment_resource.go | 3 ++- .../services/cosmos/cosmosdb_sql_role_definition_resource.go | 2 +- internal/services/cosmos/cosmosdb_sql_trigger_resource.go | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/services/cosmos/cosmosdb_mongo_collection_resource.go b/internal/services/cosmos/cosmosdb_mongo_collection_resource.go index dc33022dc379..434e5eba1893 100644 --- a/internal/services/cosmos/cosmosdb_mongo_collection_resource.go +++ b/internal/services/cosmos/cosmosdb_mongo_collection_resource.go @@ -309,7 +309,7 @@ func resourceCosmosDbMongoCollectionRead(d *pluginsdk.ResourceData, meta interfa d.Set("resource_group_name", id.ResourceGroupName) d.Set("account_name", id.DatabaseAccountName) d.Set("database_name", id.MongodbDatabaseName) - d.Set("name", id.MongodbDatabaseName) + d.Set("name", id.CollectionName) databaseAccountID := cosmosdb.NewDatabaseAccountID(id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName) accResp, err := client.DatabaseAccountsGet(ctx, databaseAccountID) diff --git a/internal/services/cosmos/cosmosdb_mongo_role_definition_resource.go b/internal/services/cosmos/cosmosdb_mongo_role_definition_resource.go index 764c0ff228cf..d87daed245e8 100644 --- a/internal/services/cosmos/cosmosdb_mongo_role_definition_resource.go +++ b/internal/services/cosmos/cosmosdb_mongo_role_definition_resource.go @@ -250,7 +250,7 @@ func (r CosmosDbMongoRoleDefinitionResource) Read() sdk.ResourceFunc { if model := resp.Model; model != nil { if properties := model.Properties; properties != nil { - databaseId := cosmosdb.NewMongodbDatabaseID(id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, *properties.DatabaseName) + databaseId := cosmosdb.NewMongodbDatabaseID(id.SubscriptionId, id.ResourceGroupName, id.DatabaseAccountName, pointer.From(properties.DatabaseName)) state.CosmosMongoDatabaseId = databaseId.ID() state.RoleName = pointer.From(properties.RoleName) diff --git a/internal/services/cosmos/cosmosdb_sql_role_assignment_resource.go b/internal/services/cosmos/cosmosdb_sql_role_assignment_resource.go index c00c28dd2bff..57a64e4ed891 100644 --- a/internal/services/cosmos/cosmosdb_sql_role_assignment_resource.go +++ b/internal/services/cosmos/cosmosdb_sql_role_assignment_resource.go @@ -5,6 +5,7 @@ package cosmos import ( "fmt" + "strings" "time" "github.com/hashicorp/go-azure-helpers/lang/pointer" @@ -147,7 +148,7 @@ func resourceCosmosDbSQLRoleAssignmentRead(d *pluginsdk.ResourceData, meta inter return fmt.Errorf("retrieving %s: %+v", id, err) } - d.Set("name", id.DatabaseAccountName) + d.Set("name", strings.TrimPrefix(id.RoleAssignmentId, "/")) d.Set("resource_group_name", id.ResourceGroupName) d.Set("account_name", id.DatabaseAccountName) diff --git a/internal/services/cosmos/cosmosdb_sql_role_definition_resource.go b/internal/services/cosmos/cosmosdb_sql_role_definition_resource.go index ee1eed74519a..2ca1fcdcf350 100644 --- a/internal/services/cosmos/cosmosdb_sql_role_definition_resource.go +++ b/internal/services/cosmos/cosmosdb_sql_role_definition_resource.go @@ -230,7 +230,7 @@ func resourceCosmosDbSQLRoleDefinitionUpdate(d *pluginsdk.ResourceData, meta int parameters.Properties.RoleName = pointer.To(d.Get("name").(string)) } - if d.HasChange("permission") { + if d.HasChange("permissions") { parameters.Properties.Permissions = expandSqlRoleDefinitionPermissions(d.Get("permissions").(*pluginsdk.Set).List()) } diff --git a/internal/services/cosmos/cosmosdb_sql_trigger_resource.go b/internal/services/cosmos/cosmosdb_sql_trigger_resource.go index fb6f09ef7338..88c886096b9c 100644 --- a/internal/services/cosmos/cosmosdb_sql_trigger_resource.go +++ b/internal/services/cosmos/cosmosdb_sql_trigger_resource.go @@ -108,7 +108,7 @@ func resourceCosmosDbSQLTriggerCreateUpdate(d *pluginsdk.ResourceData, meta inte createUpdateSqlTriggerParameters := cosmosdb.SqlTriggerCreateUpdateParameters{ Properties: cosmosdb.SqlTriggerCreateUpdateProperties{ Resource: cosmosdb.SqlTriggerResource{ - Id: id.SqlDatabaseName, + Id: id.TriggerName, Body: pointer.To(d.Get("body").(string)), TriggerType: pointer.ToEnum[cosmosdb.TriggerType](d.Get("type").(string)), TriggerOperation: pointer.ToEnum[cosmosdb.TriggerOperation](d.Get("operation").(string)),