diff --git a/azurerm/helpers/azure/cosmos.go b/azurerm/helpers/azure/cosmos.go deleted file mode 100644 index 14c2e8c54cbf..000000000000 --- a/azurerm/helpers/azure/cosmos.go +++ /dev/null @@ -1,179 +0,0 @@ -package azure - -import ( - "fmt" - - "github.com/Azure/go-autorest/autorest" -) - -// it seems the cosmos API is not returning any sort of valid ID in the main response body -// so lets grab it from the response.request.url.path -func CosmosGetIDFromResponse(resp autorest.Response) (string, error) { - if resp.Response == nil { - return "", fmt.Errorf("Error: Unable to get Cosmos ID from Response: http response is nil") - } - - if resp.Response.Request == nil { - return "", fmt.Errorf("Error: Unable to get Cosmos ID from Response: Request is nil") - } - - if resp.Response.Request.URL == nil { - return "", fmt.Errorf("Error: Unable to get Cosmos ID from Response: URL is nil") - } - - return resp.Response.Request.URL.Path, nil -} - -type CosmosAccountID struct { - ResourceID - Account string -} - -func ParseCosmosAccountID(id string) (*CosmosAccountID, error) { - subid, err := ParseAzureResourceID(id) - if err != nil { - return nil, err - } - - account, ok := subid.Path["databaseAccounts"] - if !ok { - return nil, fmt.Errorf("Error: Unable to parse Cosmos Database Resource ID: databaseAccounts is missing from: %s", id) - } - - return &CosmosAccountID{ - ResourceID: *subid, - Account: account, - }, nil -} - -type CosmosDatabaseID struct { - CosmosAccountID - Database string -} - -func ParseCosmosDatabaseID(id string) (*CosmosDatabaseID, error) { - subid, err := ParseCosmosAccountID(id) - if err != nil { - return nil, err - } - - db, ok := subid.Path["databases"] - if !ok { - return nil, fmt.Errorf("Error: Unable to parse Cosmos Database Resource ID: databases is missing from: %s", id) - } - - return &CosmosDatabaseID{ - CosmosAccountID: *subid, - Database: db, - }, nil -} - -type CosmosDatabaseCollectionID struct { - CosmosDatabaseID - Collection string -} - -func ParseCosmosDatabaseCollectionID(id string) (*CosmosDatabaseCollectionID, error) { - subid, err := ParseCosmosDatabaseID(id) - if err != nil { - return nil, err - } - - collection, ok := subid.Path["collections"] - if !ok { - return nil, fmt.Errorf("Error: Unable to parse Cosmos Database Resource ID: collections is missing from: %s", id) - } - - return &CosmosDatabaseCollectionID{ - CosmosDatabaseID: *subid, - Collection: collection, - }, nil -} - -type CosmosDatabaseContainerID struct { - CosmosDatabaseID - Container string -} - -func ParseCosmosDatabaseContainerID(id string) (*CosmosDatabaseContainerID, error) { - subid, err := ParseCosmosDatabaseID(id) - if err != nil { - return nil, err - } - - container, ok := subid.Path["containers"] - if !ok { - return nil, fmt.Errorf("Error: Unable to parse Cosmos Database Container Resource ID: containers is missing from: %s", id) - } - - return &CosmosDatabaseContainerID{ - CosmosDatabaseID: *subid, - Container: container, - }, nil -} - -type CosmosKeyspaceID struct { - CosmosAccountID - Keyspace string -} - -func ParseCosmosKeyspaceID(id string) (*CosmosKeyspaceID, error) { - subid, err := ParseCosmosAccountID(id) - if err != nil { - return nil, err - } - - ks, ok := subid.Path["keyspaces"] - if !ok { - return nil, fmt.Errorf("Error: Unable to parse Cosmos Keyspace Resource ID: keyspaces is missing from: %s", id) - } - - return &CosmosKeyspaceID{ - CosmosAccountID: *subid, - Keyspace: ks, - }, nil -} - -type CosmosTableID struct { - CosmosAccountID - Table string -} - -func ParseCosmosTableID(id string) (*CosmosTableID, error) { - subid, err := ParseCosmosAccountID(id) - if err != nil { - return nil, err - } - - table, ok := subid.Path["tables"] - if !ok { - return nil, fmt.Errorf("Error: Unable to parse Cosmos Table Resource ID: tables is missing from: %s", id) - } - - return &CosmosTableID{ - CosmosAccountID: *subid, - Table: table, - }, nil -} - -type CosmosGremlinGraphID struct { - CosmosDatabaseID - Graph string -} - -func ParseCosmosGramlinGraphID(id string) (*CosmosGremlinGraphID, error) { - subid, err := ParseCosmosDatabaseID(id) - if err != nil { - return nil, err - } - - graph, ok := subid.Path["graphs"] - if !ok { - return nil, fmt.Errorf("Error: Unable to parse Cosmos Gremlin Graph Resource ID: Graph is missing from: %s", id) - } - - return &CosmosGremlinGraphID{ - CosmosDatabaseID: *subid, - Graph: graph, - }, nil -} diff --git a/azurerm/internal/services/cosmos/client/client.go b/azurerm/internal/services/cosmos/client/client.go index 4fb57470fe9f..9dd30bd85fcf 100644 --- a/azurerm/internal/services/cosmos/client/client.go +++ b/azurerm/internal/services/cosmos/client/client.go @@ -1,19 +1,44 @@ package client import ( - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb" + "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common" ) type Client struct { - DatabaseClient *documentdb.DatabaseAccountsClient + CassandraClient *documentdb.CassandraResourcesClient + DatabaseClient *documentdb.DatabaseAccountsClient + GremlinClient *documentdb.GremlinResourcesClient + MongoDbClient *documentdb.MongoDBResourcesClient + SqlClient *documentdb.SQLResourcesClient + TableClient *documentdb.TableResourcesClient } func NewClient(o *common.ClientOptions) *Client { + 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) + + sqlClient := documentdb.NewSQLResourcesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + o.ConfigureClient(&sqlClient.Client, o.ResourceManagerAuthorizer) + + tableClient := documentdb.NewTableResourcesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + o.ConfigureClient(&tableClient.Client, o.ResourceManagerAuthorizer) + return &Client{ - DatabaseClient: &databaseClient, + CassandraClient: &cassandraClient, + DatabaseClient: &databaseClient, + GremlinClient: &gremlinClient, + MongoDbClient: &mongoDbClient, + SqlClient: &sqlClient, + TableClient: &tableClient, } } diff --git a/azurerm/internal/services/cosmos/common/ip_rules.go b/azurerm/internal/services/cosmos/common/ip_rules.go new file mode 100644 index 000000000000..d084d9318557 --- /dev/null +++ b/azurerm/internal/services/cosmos/common/ip_rules.go @@ -0,0 +1,32 @@ +package common + +import ( + "strings" + + "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func CosmosDBIpRulesToIpRangeFilter(ipRules *[]documentdb.IPAddressOrRange) string { + ipRangeFilter := make([]string, 0) + if ipRules != nil { + for _, ipRule := range *ipRules { + ipRangeFilter = append(ipRangeFilter, *ipRule.IPAddressOrRange) + } + } + + return strings.Join(ipRangeFilter, ",") +} + +func CosmosDBIpRangeFilterToIpRules(ipRangeFilter string) *[]documentdb.IPAddressOrRange { + ipRules := make([]documentdb.IPAddressOrRange, 0) + if len(ipRangeFilter) > 0 { + for _, ipRange := range strings.Split(ipRangeFilter, ",") { + ipRules = append(ipRules, documentdb.IPAddressOrRange{ + IPAddressOrRange: utils.String(ipRange), + }) + } + } + + return &ipRules +} diff --git a/azurerm/internal/services/cosmos/common/ip_rules_test.go b/azurerm/internal/services/cosmos/common/ip_rules_test.go new file mode 100644 index 000000000000..cf99b3021781 --- /dev/null +++ b/azurerm/internal/services/cosmos/common/ip_rules_test.go @@ -0,0 +1,91 @@ +package common + +import ( + "reflect" + "testing" + + "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb" +) + +var ( + ipAddressOne = "127.0.0.1/32" + ipAddressTwo = "168.63.129.16/32" +) + +func TestCosmosDBIpRulesToIpRangeFilter(t *testing.T) { + testData := []struct { + Name string + Input *[]documentdb.IPAddressOrRange + Expected string + }{ + { + Name: "Nil", + Input: nil, + Expected: "", + }, + { + Name: "One element", + Input: &[]documentdb.IPAddressOrRange{ + {IPAddressOrRange: &ipAddressOne}, + }, + Expected: "127.0.0.1/32", + }, + { + Name: "Multiple elements", + Input: &[]documentdb.IPAddressOrRange{ + {IPAddressOrRange: &ipAddressOne}, + {IPAddressOrRange: &ipAddressTwo}, + }, + Expected: "127.0.0.1/32,168.63.129.16/32", + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Name) + + actual := CosmosDBIpRulesToIpRangeFilter(v.Input) + + if actual != v.Expected { + t.Fatalf("Expected %q but got %q", v.Expected, actual) + } + } +} + +func TestCosmosDBIpRangeFilterToIpRules(t *testing.T) { + testData := []struct { + Name string + Input string + Expected *[]documentdb.IPAddressOrRange + }{ + { + Name: "Empty", + Input: "", + Expected: &[]documentdb.IPAddressOrRange{}, + }, + { + Name: "One element", + Input: ipAddressOne, + Expected: &[]documentdb.IPAddressOrRange{ + {IPAddressOrRange: &ipAddressOne}, + }, + }, + { + Name: "Multiple elements", + Input: "127.0.0.1/32,168.63.129.16/32", + Expected: &[]documentdb.IPAddressOrRange{ + {IPAddressOrRange: &ipAddressOne}, + {IPAddressOrRange: &ipAddressTwo}, + }, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Name) + + actual := CosmosDBIpRangeFilterToIpRules(v.Input) + + if !reflect.DeepEqual(actual, v.Expected) { + t.Fatalf("Expected %+v but got %+v", v.Expected, actual) + } + } +} diff --git a/azurerm/internal/services/cosmos/common/throughput.go b/azurerm/internal/services/cosmos/common/throughput.go new file mode 100644 index 000000000000..29f8e8588177 --- /dev/null +++ b/azurerm/internal/services/cosmos/common/throughput.go @@ -0,0 +1,24 @@ +package common + +import ( + "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func GetThroughputFromResult(throughputResponse documentdb.ThroughputSettingsGetResults) *int32 { + props := throughputResponse.ThroughputSettingsGetProperties + if props == nil { + return nil + } + + res := props.Resource + if res == nil { + return nil + } + + return res.Throughput +} + +func ConvertThroughputFromResourceData(throughput interface{}) *int32 { + return utils.Int32(int32(throughput.(int))) +} diff --git a/azurerm/internal/services/cosmos/cosmos_db_account_data_source.go b/azurerm/internal/services/cosmos/cosmos_db_account_data_source.go index 15f202d0b011..03bb584ac13b 100644 --- a/azurerm/internal/services/cosmos/cosmos_db_account_data_source.go +++ b/azurerm/internal/services/cosmos/cosmos_db_account_data_source.go @@ -5,8 +5,9 @@ import ( "log" "time" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb" + "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/common" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" @@ -211,9 +212,9 @@ func dataSourceArmCosmosDbAccountRead(d *schema.ResourceData, meta interface{}) } d.Set("kind", string(resp.Kind)) - if props := resp.DatabaseAccountProperties; props != nil { + if props := resp.DatabaseAccountGetProperties; props != nil { d.Set("offer_type", string(props.DatabaseAccountOfferType)) - d.Set("ip_range_filter", props.IPRangeFilter) + d.Set("ip_range_filter", common.CosmosDBIpRulesToIpRangeFilter(props.IPRules)) d.Set("endpoint", props.DocumentEndpoint) d.Set("is_virtual_network_filter_enabled", resp.IsVirtualNetworkFilterEnabled) d.Set("enable_automatic_failover", resp.EnableAutomaticFailover) diff --git a/azurerm/internal/services/cosmos/cosmosdb_account_resource.go b/azurerm/internal/services/cosmos/cosmosdb_account_resource.go index 21c7dcb8282a..a02d884c032f 100644 --- a/azurerm/internal/services/cosmos/cosmosdb_account_resource.go +++ b/azurerm/internal/services/cosmos/cosmosdb_account_resource.go @@ -10,8 +10,9 @@ import ( "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb" - "github.com/hashicorp/go-azure-helpers/response" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/common" + + "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb" "github.com/hashicorp/terraform-plugin-sdk/helper/hashcode" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -25,6 +26,19 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) +// If the consistency policy of the Cosmos DB Database Account is not bounded staleness, +// any changes to the configuration for bounded staleness should be suppressed. +func suppressConsistencyPolicyStalenessConfiguration(_, _, _ string, d *schema.ResourceData) bool { + consistencyPolicyList := d.Get("consistency_policy").([]interface{}) + if len(consistencyPolicyList) == 0 || consistencyPolicyList[0] == nil { + return false + } + + consistencyPolicy := consistencyPolicyList[0].(map[string]interface{}) + + return consistencyPolicy["consistency_level"].(string) != string(documentdb.BoundedStaleness) +} + func resourceArmCosmosDbAccount() *schema.Resource { return &schema.Resource{ Create: resourceArmCosmosDbAccountCreate, @@ -115,17 +129,19 @@ func resourceArmCosmosDbAccount() *schema.Resource { }, "max_interval_in_seconds": { - Type: schema.TypeInt, - Optional: true, - Default: 5, // 2.0 change to computed? - ValidateFunc: validation.IntBetween(5, 86400), // single region values + Type: schema.TypeInt, + Optional: true, + Computed: true, + DiffSuppressFunc: suppressConsistencyPolicyStalenessConfiguration, + ValidateFunc: validation.IntBetween(5, 86400), // single region values }, "max_staleness_prefix": { - Type: schema.TypeInt, - Optional: true, - Default: 100, // 2.0 change to computed - ValidateFunc: validation.IntBetween(10, 1000000), // single region values + Type: schema.TypeInt, + Optional: true, + Computed: true, + DiffSuppressFunc: suppressConsistencyPolicyStalenessConfiguration, + ValidateFunc: validation.IntBetween(10, 1000000), // single region values }, }, }, @@ -144,6 +160,7 @@ func resourceArmCosmosDbAccount() *schema.Resource { regexp.MustCompile("^[-a-z0-9]{3,50}$"), "Cosmos DB location prefix (ID) must be 3 - 50 characters long, contain only lowercase letters, numbers and hyphens.", ), + Deprecated: "This is deprecated because the service no longer accepts this as an input since Apr 25, 2019", }, "id": { @@ -322,7 +339,7 @@ func resourceArmCosmosDbAccountCreate(d *schema.ResourceData, meta interface{}) return fmt.Errorf("CosmosDB Account %s already exists, please import the resource via terraform import", name) } } - geoLocations, err := expandAzureRmCosmosDBAccountGeoLocations(name, d) + geoLocations, err := expandAzureRmCosmosDBAccountGeoLocations(d) if err != nil { return fmt.Errorf("Error expanding CosmosDB Account %q (Resource Group %q) geo locations: %+v", name, resourceGroup, err) } @@ -332,7 +349,7 @@ func resourceArmCosmosDbAccountCreate(d *schema.ResourceData, meta interface{}) Kind: documentdb.DatabaseAccountKind(kind), DatabaseAccountCreateUpdateProperties: &documentdb.DatabaseAccountCreateUpdateProperties{ DatabaseAccountOfferType: utils.String(offerType), - IPRangeFilter: utils.String(ipRangeFilter), + IPRules: common.CosmosDBIpRangeFilterToIpRules(ipRangeFilter), IsVirtualNetworkFilterEnabled: utils.Bool(isVirtualNetworkFilterEnabled), EnableAutomaticFailover: utils.Bool(enableAutomaticFailover), ConsistencyPolicy: expandAzureRmCosmosDBAccountConsistencyPolicy(d), @@ -345,13 +362,12 @@ func resourceArmCosmosDbAccountCreate(d *schema.ResourceData, meta interface{}) } // additional validation on MaxStalenessPrefix as it varies depending on if the DB is multi region or not - - cp := account.DatabaseAccountCreateUpdateProperties.ConsistencyPolicy - if len(geoLocations) > 1 && cp != nil && cp.DefaultConsistencyLevel == documentdb.BoundedStaleness { - if msp := cp.MaxStalenessPrefix; msp != nil && *msp < 100000 { + consistencyPolicy := account.DatabaseAccountCreateUpdateProperties.ConsistencyPolicy + if len(geoLocations) > 1 && consistencyPolicy != nil && consistencyPolicy.DefaultConsistencyLevel == documentdb.BoundedStaleness { + if msp := consistencyPolicy.MaxStalenessPrefix; msp != nil && *msp < 100000 { return fmt.Errorf("Error max_staleness_prefix (%d) must be greater then 100000 when more then one geo_location is used", *msp) } - if mis := cp.MaxIntervalInSeconds; mis != nil && *mis < 300 { + if mis := consistencyPolicy.MaxIntervalInSeconds; mis != nil && *mis < 300 { return fmt.Errorf("Error max_interval_in_seconds (%d) must be greater then 300 (5min) when more then one geo_location is used", *mis) } } @@ -390,7 +406,7 @@ func resourceArmCosmosDbAccountUpdate(d *schema.ResourceData, meta interface{}) enableAutomaticFailover := d.Get("enable_automatic_failover").(bool) enableMultipleWriteLocations := d.Get("enable_multiple_write_locations").(bool) - newLocations, err := expandAzureRmCosmosDBAccountGeoLocations(name, d) + newLocations, err := expandAzureRmCosmosDBAccountGeoLocations(d) if err != nil { return fmt.Errorf("Error expanding CosmosDB Account %q (Resource Group %q) geo locations: %+v", name, resourceGroup, err) } @@ -414,21 +430,21 @@ func resourceArmCosmosDbAccountUpdate(d *schema.ResourceData, meta interface{}) oldLocationsMap[azure.NormalizeLocation(*location.LocationName)] = location } - // cannot update properties and add/remove replication locations at the same time - // so first just update any changed properties + // cannot update properties and add/remove replication locations or updating enabling of multiple + // write locations at the same time. so first just update any changed properties account := documentdb.DatabaseAccountCreateUpdateParameters{ Location: utils.String(location), Kind: documentdb.DatabaseAccountKind(kind), DatabaseAccountCreateUpdateProperties: &documentdb.DatabaseAccountCreateUpdateProperties{ DatabaseAccountOfferType: utils.String(offerType), - IPRangeFilter: utils.String(ipRangeFilter), + IPRules: common.CosmosDBIpRangeFilterToIpRules(ipRangeFilter), IsVirtualNetworkFilterEnabled: utils.Bool(isVirtualNetworkFilterEnabled), EnableAutomaticFailover: utils.Bool(enableAutomaticFailover), Capabilities: expandAzureRmCosmosDBAccountCapabilities(d), ConsistencyPolicy: expandAzureRmCosmosDBAccountConsistencyPolicy(d), Locations: &oldLocations, VirtualNetworkRules: expandAzureRmCosmosDBAccountVirtualNetworkRules(d), - EnableMultipleWriteLocations: utils.Bool(enableMultipleWriteLocations), + EnableMultipleWriteLocations: resp.EnableMultipleWriteLocations, }, Tags: tags.Expand(t), } @@ -437,6 +453,14 @@ func resourceArmCosmosDbAccountUpdate(d *schema.ResourceData, meta interface{}) return fmt.Errorf("Error updating CosmosDB Account %q properties (Resource Group %q): %+v", name, resourceGroup, err) } + // Update the property independently after the initial upsert as no other properties may change at the same time. + account.DatabaseAccountCreateUpdateProperties.EnableMultipleWriteLocations = utils.Bool(enableMultipleWriteLocations) + if *resp.EnableMultipleWriteLocations != enableMultipleWriteLocations { + if _, err = resourceArmCosmosDbAccountApiUpsert(client, ctx, resourceGroup, name, account, d); err != nil { + return fmt.Errorf("Error updating CosmosDB Account %q EnableMultipleWriteLocations (Resource Group %q): %+v", name, resourceGroup, err) + } + } + // determine if any locations have been renamed/priority reordered and remove them removedOne := false for _, l := range newLocations { @@ -449,16 +473,6 @@ func resourceArmCosmosDbAccountUpdate(d *schema.ResourceData, meta interface{}) removedOne = true continue } - if *l.ID == "" && *ol.ID == resourceArmCosmosDbAccountGenerateDefaultId(name, *l.LocationName) { - continue - } - if *l.ID != *ol.ID { - if *l.FailoverPriority == 0 { - return fmt.Errorf("Cannot change the prefix/ID of the primary Cosmos DB account %q location %s (Resource Group %q)", name, *l.LocationName, resourceGroup) - } - delete(oldLocationsMap, *l.LocationName) - removedOne = true - } } } @@ -521,7 +535,7 @@ func resourceArmCosmosDbAccountRead(d *schema.ResourceData, meta interface{}) er d.Set("kind", string(resp.Kind)) d.Set("offer_type", string(resp.DatabaseAccountOfferType)) - d.Set("ip_range_filter", resp.IPRangeFilter) + d.Set("ip_range_filter", common.CosmosDBIpRulesToIpRangeFilter(resp.IPRules)) d.Set("endpoint", resp.DocumentEndpoint) if v := resp.IsVirtualNetworkFilterEnabled; v != nil { @@ -540,7 +554,7 @@ func resourceArmCosmosDbAccountRead(d *schema.ResourceData, meta interface{}) er return fmt.Errorf("Error setting CosmosDB Account %q `consistency_policy` (Resource Group %q): %+v", name, resourceGroup, err) } - if err = d.Set("geo_location", flattenAzureRmCosmosDBAccountGeoLocations(d, resp)); err != nil { + if err = d.Set("geo_location", flattenAzureRmCosmosDBAccountGeoLocations(resp)); err != nil { return fmt.Errorf("Error setting `geo_location`: %+v", err) } @@ -646,7 +660,7 @@ func resourceArmCosmosDbAccountDelete(d *schema.ResourceData, meta interface{}) future, err := client.Delete(ctx, resourceGroup, name) if err != nil { - if response.WasNotFound(future.Response()) { + if future.Response().StatusCode == http.StatusNoContent { return nil } return fmt.Errorf("Error issuing AzureRM delete request for CosmosDB Account '%s': %+v", name, err) @@ -672,13 +686,13 @@ func resourceArmCosmosDbAccountDelete(d *schema.ResourceData, meta interface{}) } if _, err = stateConf.WaitForState(); err != nil { - return fmt.Errorf("Waiting forCosmosDB Account %q to delete (Resource Group %q): %+v", name, resourceGroup, err) + return fmt.Errorf("Waiting for CosmosDB Account %q to delete (Resource Group %q): %+v", name, resourceGroup, err) } return nil } -func resourceArmCosmosDbAccountApiUpsert(client *documentdb.DatabaseAccountsClient, ctx context.Context, resourceGroup string, name string, account documentdb.DatabaseAccountCreateUpdateParameters, d *schema.ResourceData) (*documentdb.DatabaseAccount, error) { +func resourceArmCosmosDbAccountApiUpsert(client *documentdb.DatabaseAccountsClient, ctx context.Context, resourceGroup string, name string, account documentdb.DatabaseAccountCreateUpdateParameters, d *schema.ResourceData) (*documentdb.DatabaseAccountGetResults, error) { future, err := client.CreateOrUpdate(ctx, resourceGroup, name, account) if err != nil { return nil, fmt.Errorf("Error creating/updating CosmosDB Account %q (Resource Group %q): %+v", name, resourceGroup, err) @@ -696,17 +710,29 @@ func resourceArmCosmosDbAccountApiUpsert(client *documentdb.DatabaseAccountsClie Delay: 30 * time.Second, // required because it takes some time before the 'creating' location shows up Refresh: func() (interface{}, string, error) { resp, err2 := client.Get(ctx, resourceGroup, name) - if err2 != nil { + if err2 != nil || resp.StatusCode == http.StatusNotFound { return nil, "", fmt.Errorf("Error reading CosmosDB Account %q after create/update (Resource Group %q): %+v", name, resourceGroup, err2) } - status := "Succeeded" - for _, l := range append(*resp.ReadLocations, *resp.WriteLocations...) { + locations := append(*resp.ReadLocations, *resp.WriteLocations...) + for _, l := range locations { if status = *l.ProvisioningState; status == "Creating" || status == "Updating" || status == "Deleting" { break // return the first non successful status. } } + for _, desiredLocation := range *account.Locations { + for index, l := range locations { + if azure.NormalizeLocation(*desiredLocation.LocationName) == azure.NormalizeLocation(*l.LocationName) { + break + } + + if (index + 1) == len(locations) { + return resp, "Updating", nil + } + } + } + return resp, status, nil }, } @@ -722,7 +748,7 @@ func resourceArmCosmosDbAccountApiUpsert(client *documentdb.DatabaseAccountsClie return nil, fmt.Errorf("Error waiting for the CosmosDB Account %q (Resource Group %q) to provision: %+v", name, resourceGroup, err) } - r := resp.(documentdb.DatabaseAccount) + r := resp.(documentdb.DatabaseAccountGetResults) return &r, nil } @@ -739,20 +765,22 @@ func expandAzureRmCosmosDBAccountConsistencyPolicy(d *schema.ResourceData) *docu } if stalenessPrefix, ok := input["max_staleness_prefix"].(int); ok { + if stalenessPrefix == 0 { + stalenessPrefix = 100 + } policy.MaxStalenessPrefix = utils.Int64(int64(stalenessPrefix)) } if maxInterval, ok := input["max_interval_in_seconds"].(int); ok { + if maxInterval == 0 { + maxInterval = 5 + } policy.MaxIntervalInSeconds = utils.Int32(int32(maxInterval)) } return &policy } -func resourceArmCosmosDbAccountGenerateDefaultId(databaseName string, location string) string { - return fmt.Sprintf("%s-%s", databaseName, location) -} - -func expandAzureRmCosmosDBAccountGeoLocations(databaseName string, d *schema.ResourceData) ([]documentdb.Location, error) { +func expandAzureRmCosmosDBAccountGeoLocations(d *schema.ResourceData) ([]documentdb.Location, error) { locations := make([]documentdb.Location, 0) for _, l := range d.Get("geo_location").(*schema.Set).List() { data := l.(map[string]interface{}) @@ -762,13 +790,6 @@ func expandAzureRmCosmosDBAccountGeoLocations(databaseName string, d *schema.Res FailoverPriority: utils.Int32(int32(data["failover_priority"].(int))), } - if v, ok := data["prefix"].(string); ok { - data["id"] = v - } else { - data["id"] = utils.String(resourceArmCosmosDbAccountGenerateDefaultId(databaseName, *location.LocationName)) - } - location.ID = utils.String(data["id"].(string)) - locations = append(locations, location) } @@ -839,20 +860,11 @@ func flattenAzureRmCosmosDBAccountConsistencyPolicy(policy *documentdb.Consisten return []interface{}{result} } -func flattenAzureRmCosmosDBAccountGeoLocations(d *schema.ResourceData, account documentdb.DatabaseAccount) *schema.Set { +func flattenAzureRmCosmosDBAccountGeoLocations(account documentdb.DatabaseAccountGetResults) *schema.Set { locationSet := schema.Set{ F: resourceAzureRMCosmosDBAccountGeoLocationHash, } - // we need to propagate the `prefix` field so fetch existing - prefixMap := map[string]string{} - if locations, ok := d.GetOk("geo_location"); ok { - for _, lRaw := range locations.(*schema.Set).List() { - lb := lRaw.(map[string]interface{}) - prefixMap[lb["location"].(string)] = lb["prefix"].(string) - } - } - for _, l := range *account.FailoverPolicies { id := *l.ID lb := map[string]interface{}{ @@ -861,11 +873,6 @@ func flattenAzureRmCosmosDBAccountGeoLocations(d *schema.ResourceData, account d "failover_priority": int(*l.FailoverPriority), } - // if id is not the default then it must be set via prefix - if id != resourceArmCosmosDbAccountGenerateDefaultId(d.Get("name").(string), lb["location"].(string)) { - lb["prefix"] = id - } - locationSet.Add(lb) } @@ -911,14 +918,10 @@ func resourceAzureRMCosmosDBAccountGeoLocationHash(v interface{}) int { var buf bytes.Buffer if m, ok := v.(map[string]interface{}); ok { - prefix := "" - if v, ok := m["prefix"].(string); ok { - prefix = v - } location := azure.NormalizeLocation(m["location"].(string)) priority := int32(m["failover_priority"].(int)) - buf.WriteString(fmt.Sprintf("%s-%s-%d", prefix, location, priority)) + buf.WriteString(fmt.Sprintf("%s-%d", location, priority)) } return hashcode.String(buf.String()) diff --git a/azurerm/internal/services/cosmos/cosmosdb_cassandra_keyspace_resource.go b/azurerm/internal/services/cosmos/cosmosdb_cassandra_keyspace_resource.go index d9c9e6afaa29..01bbf58fc4ee 100644 --- a/azurerm/internal/services/cosmos/cosmosdb_cassandra_keyspace_resource.go +++ b/azurerm/internal/services/cosmos/cosmosdb_cassandra_keyspace_resource.go @@ -3,10 +3,9 @@ package cosmos import ( "fmt" "log" - "strconv" "time" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb" + "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb" "github.com/hashicorp/go-azure-helpers/response" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" @@ -14,6 +13,9 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/common" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/migration" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/parse" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) @@ -29,6 +31,15 @@ func resourceArmCosmosDbCassandraKeyspace() *schema.Resource { State: schema.ImportStatePassthrough, }, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: migration.ResourceCassandraKeyspaceUpgradeV0Schema().CoreConfigSchema().ImpliedType(), + Upgrade: migration.ResourceCassandraKeyspaceStateUpgradeV0ToV1, + Version: 0, + }, + }, + Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(30 * time.Minute), Read: schema.DefaultTimeout(5 * time.Minute), @@ -64,7 +75,7 @@ func resourceArmCosmosDbCassandraKeyspace() *schema.Resource { } func resourceArmCosmosDbCassandraKeyspaceCreate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.CassandraClient ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -76,15 +87,14 @@ func resourceArmCosmosDbCassandraKeyspaceCreate(d *schema.ResourceData, meta int existing, err := client.GetCassandraKeyspace(ctx, resourceGroup, account, name) if err != nil { if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("Error checking for presence of creating Cosmos Cassandra Keyspace %s (Account %s): %+v", name, account, err) + return fmt.Errorf("Error checking for presence of creating Cosmos Cassandra Keyspace %q (Account: %q): %+v", name, account, err) } } else { - id, err := azure.CosmosGetIDFromResponse(existing.Response) - if err != nil { - return fmt.Errorf("Error generating import ID for Cosmos Cassandra Keyspace '%s' (Account %s)", name, account) + if existing.ID == nil && *existing.ID == "" { + return fmt.Errorf("Error generating import ID for Cosmos Cassandra Keyspace %q (Account: %q)", name, account) } - return tf.ImportAsExistsError("azurerm_cosmosdb_cassandra_keyspace", id) + return tf.ImportAsExistsError("azurerm_cosmosdb_cassandra_keyspace", *existing.ID) } } @@ -93,45 +103,43 @@ func resourceArmCosmosDbCassandraKeyspaceCreate(d *schema.ResourceData, meta int Resource: &documentdb.CassandraKeyspaceResource{ ID: &name, }, - Options: map[string]*string{}, + Options: &documentdb.CreateUpdateOptions{}, }, } if throughput, hasThroughput := d.GetOk("throughput"); hasThroughput { - db.CassandraKeyspaceCreateUpdateProperties.Options = map[string]*string{ - "throughput": utils.String(strconv.Itoa(throughput.(int))), - } + db.CassandraKeyspaceCreateUpdateProperties.Options.Throughput = common.ConvertThroughputFromResourceData(throughput) } future, err := client.CreateUpdateCassandraKeyspace(ctx, resourceGroup, account, name, db) if err != nil { - return fmt.Errorf("Error issuing create/update request for Cosmos Cassandra Keyspace %s (Account %s): %+v", name, account, err) + return fmt.Errorf("Error issuing create/update request for Cosmos Cassandra Keyspace %q (Account: %q): %+v", name, account, err) } if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on create/update future for Cosmos Cassandra Keyspace %s (Account %s): %+v", name, account, err) + return fmt.Errorf("Error waiting on create/update future for Cosmos Cassandra Keyspace %q (Account: %q): %+v", name, account, err) } resp, err := client.GetCassandraKeyspace(ctx, resourceGroup, account, name) if err != nil { - return fmt.Errorf("Error making get request for Cosmos Cassandra Keyspace %s (Account %s): %+v", name, account, err) + return fmt.Errorf("Error making get request for Cosmos Cassandra Keyspace %q (Account: %q): %+v", name, account, err) } - id, err := azure.CosmosGetIDFromResponse(resp.Response) - if err != nil { - return fmt.Errorf("Error retrieving the ID for Cosmos Cassandra Keyspace '%s' (Account %s) ID: %v", name, account, err) + if resp.ID == nil { + return fmt.Errorf("Error getting ID from Cosmos Cassandra Keyspace %q (Account: %q)", name, account) } - d.SetId(id) + + d.SetId(*resp.ID) return resourceArmCosmosDbCassandraKeyspaceRead(d, meta) } func resourceArmCosmosDbCassandraKeyspaceUpdate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.CassandraClient ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosKeyspaceID(d.Id()) + id, err := parse.CassandraKeyspaceID(d.Id()) if err != nil { return err } @@ -139,40 +147,40 @@ func resourceArmCosmosDbCassandraKeyspaceUpdate(d *schema.ResourceData, meta int db := documentdb.CassandraKeyspaceCreateUpdateParameters{ CassandraKeyspaceCreateUpdateProperties: &documentdb.CassandraKeyspaceCreateUpdateProperties{ Resource: &documentdb.CassandraKeyspaceResource{ - ID: &id.Keyspace, + ID: &id.Name, }, - Options: map[string]*string{}, + Options: &documentdb.CreateUpdateOptions{}, }, } - future, err := client.CreateUpdateCassandraKeyspace(ctx, id.ResourceGroup, id.Account, id.Keyspace, db) + future, err := client.CreateUpdateCassandraKeyspace(ctx, id.ResourceGroup, id.Account, id.Name, db) if err != nil { - return fmt.Errorf("Error issuing create/update request for Cosmos Cassandra Keyspace %s (Account %s): %+v", id.ResourceGroup, id.Account, err) + return fmt.Errorf("Error issuing create/update request for Cosmos Cassandra Keyspace %q (Account: %q): %+v", id.ResourceGroup, id.Account, err) } if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on create/update future for Cosmos Cassandra Keyspace %s (Account %s): %+v", id.ResourceGroup, id.Account, err) + return fmt.Errorf("Error waiting on create/update future for Cosmos Cassandra Keyspace %q (Account: %q): %+v", id.ResourceGroup, id.Account, err) } if d.HasChange("throughput") { - throughputParameters := documentdb.ThroughputUpdateParameters{ - ThroughputUpdateProperties: &documentdb.ThroughputUpdateProperties{ - Resource: &documentdb.ThroughputResource{ - Throughput: utils.Int32(int32(d.Get("throughput").(int))), + throughputParameters := documentdb.ThroughputSettingsUpdateParameters{ + ThroughputSettingsUpdateProperties: &documentdb.ThroughputSettingsUpdateProperties{ + Resource: &documentdb.ThroughputSettingsResource{ + Throughput: common.ConvertThroughputFromResourceData(d.Get("throughput")), }, }, } - throughputFuture, err := client.UpdateCassandraKeyspaceThroughput(ctx, id.ResourceGroup, id.Account, id.Keyspace, throughputParameters) + throughputFuture, err := client.UpdateCassandraKeyspaceThroughput(ctx, id.ResourceGroup, id.Account, id.Name, throughputParameters) if err != nil { if response.WasNotFound(throughputFuture.Response()) { - return fmt.Errorf("Error setting Throughput for Cosmos Cassandra Keyspace %s (Account %s): %+v - "+ - "If the collection has not been created with an initial throughput, you cannot configure it later.", id.Keyspace, id.Account, err) + return fmt.Errorf("Error 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.Account, err) } } if err = throughputFuture.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on ThroughputUpdate future for Cosmos Cassandra Keyspace %s (Account %s): %+v", id.Keyspace, id.Account, err) + return fmt.Errorf("Error waiting on ThroughputUpdate future for Cosmos Cassandra Keyspace %q (Account: %q): %+v", id.Name, id.Account, err) } } @@ -180,66 +188,68 @@ func resourceArmCosmosDbCassandraKeyspaceUpdate(d *schema.ResourceData, meta int } func resourceArmCosmosDbCassandraKeyspaceRead(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.CassandraClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosKeyspaceID(d.Id()) + id, err := parse.CassandraKeyspaceID(d.Id()) if err != nil { return err } - resp, err := client.GetCassandraKeyspace(ctx, id.ResourceGroup, id.Account, id.Keyspace) + resp, err := client.GetCassandraKeyspace(ctx, id.ResourceGroup, id.Account, id.Name) if err != nil { if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[INFO] Error reading Cosmos Cassandra Keyspace %s (Account %s) - removing from state", id.Keyspace, id.Account) + log.Printf("[INFO] Error reading Cosmos Cassandra Keyspace %q (Account: %q) - removing from state", id.Name, id.Account) d.SetId("") return nil } - return fmt.Errorf("Error reading Cosmos Cassandra Keyspace %s (Account %s): %+v", id.Keyspace, id.Account, err) + return fmt.Errorf("Error reading Cosmos Cassandra Keyspace %q (Account: %q): %+v", id.Name, id.Account, err) } d.Set("resource_group_name", id.ResourceGroup) d.Set("account_name", id.Account) - if props := resp.CassandraKeyspaceProperties; props != nil { - d.Set("name", props.ID) + if props := resp.CassandraKeyspaceGetProperties; props != nil { + if res := props.Resource; res != nil { + d.Set("name", res.ID) + } } - throughputResp, err := client.GetCassandraKeyspaceThroughput(ctx, id.ResourceGroup, id.Account, id.Keyspace) + throughputResp, err := client.GetCassandraKeyspaceThroughput(ctx, id.ResourceGroup, id.Account, id.Name) if err != nil { if !utils.ResponseWasNotFound(throughputResp.Response) { - return fmt.Errorf("Error reading Throughput on Cosmos Cassandra Keyspace %s (Account %s): %+v", id.Keyspace, id.Account, err) + return fmt.Errorf("Error reading Throughput on Cosmos Cassandra Keyspace %q (Account: %q): %+v", id.Name, id.Account, err) } else { d.Set("throughput", nil) } } else { - d.Set("throughput", throughputResp.Throughput) + d.Set("throughput", common.GetThroughputFromResult(throughputResp)) } return nil } func resourceArmCosmosDbCassandraKeyspaceDelete(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.CassandraClient ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosKeyspaceID(d.Id()) + id, err := parse.CassandraKeyspaceID(d.Id()) if err != nil { return err } - future, err := client.DeleteCassandraKeyspace(ctx, id.ResourceGroup, id.Account, id.Keyspace) + future, err := client.DeleteCassandraKeyspace(ctx, id.ResourceGroup, id.Account, id.Name) if err != nil { if !response.WasNotFound(future.Response()) { - return fmt.Errorf("Error deleting Cosmos Cassandra Keyspace %s (Account %s): %+v", id.Keyspace, id.Account, err) + return fmt.Errorf("Error deleting Cosmos Cassandra Keyspace %q (Account: %q): %+v", id.Name, id.Account, err) } } err = future.WaitForCompletionRef(ctx, client.Client) if err != nil { - return fmt.Errorf("Error waiting on delete future for Cosmos Cassandra Keyspace %s (Account %s): %+v", id.Keyspace, id.Account, err) + return fmt.Errorf("Error waiting on delete future for Cosmos Cassandra Keyspace %q (Account: %q): %+v", id.Name, id.Account, err) } return nil diff --git a/azurerm/internal/services/cosmos/cosmosdb_gremlin_database_resource.go b/azurerm/internal/services/cosmos/cosmosdb_gremlin_database_resource.go index bdabcaf2bb14..ff7c915b763d 100644 --- a/azurerm/internal/services/cosmos/cosmosdb_gremlin_database_resource.go +++ b/azurerm/internal/services/cosmos/cosmosdb_gremlin_database_resource.go @@ -3,10 +3,9 @@ package cosmos import ( "fmt" "log" - "strconv" "time" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb" + "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb" "github.com/hashicorp/go-azure-helpers/response" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" @@ -14,6 +13,9 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/common" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/migration" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/parse" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) @@ -29,6 +31,15 @@ func resourceArmCosmosGremlinDatabase() *schema.Resource { State: schema.ImportStatePassthrough, }, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: migration.ResourceGremlinDatabaseUpgradeV0Schema().CoreConfigSchema().ImpliedType(), + Upgrade: migration.ResourceGremlinDatabaseStateUpgradeV0ToV1, + Version: 0, + }, + }, + Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(30 * time.Minute), Read: schema.DefaultTimeout(5 * time.Minute), @@ -64,7 +75,7 @@ func resourceArmCosmosGremlinDatabase() *schema.Resource { } func resourceArmCosmosGremlinDatabaseCreate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.GremlinClient ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -76,15 +87,14 @@ func resourceArmCosmosGremlinDatabaseCreate(d *schema.ResourceData, meta interfa existing, err := client.GetGremlinDatabase(ctx, resourceGroup, account, name) if err != nil { if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("Error checking for presence of creating Gremlin Database %s (Account %s): %+v", name, account, err) + return fmt.Errorf("Error checking for presence of creating Gremlin Database %q (Account: %q): %+v", name, account, err) } } else { - id, err := azure.CosmosGetIDFromResponse(existing.Response) - if err != nil { - return fmt.Errorf("Error generating import ID for Cosmos Gremlin Database '%s' (Account %s)", name, account) + if existing.ID == nil && *existing.ID == "" { + return fmt.Errorf("Error generating import ID for Cosmos Gremlin Database %q (Account: %q)", name, account) } - return tf.ImportAsExistsError("azurerm_cosmosdb_gremlin_database", id) + return tf.ImportAsExistsError("azurerm_cosmosdb_gremlin_database", *existing.ID) } } @@ -93,45 +103,43 @@ func resourceArmCosmosGremlinDatabaseCreate(d *schema.ResourceData, meta interfa Resource: &documentdb.GremlinDatabaseResource{ ID: &name, }, - Options: map[string]*string{}, + Options: &documentdb.CreateUpdateOptions{}, }, } if throughput, hasThroughput := d.GetOk("throughput"); hasThroughput { - db.GremlinDatabaseCreateUpdateProperties.Options = map[string]*string{ - "throughput": utils.String(strconv.Itoa(throughput.(int))), - } + db.GremlinDatabaseCreateUpdateProperties.Options.Throughput = common.ConvertThroughputFromResourceData(throughput) } future, err := client.CreateUpdateGremlinDatabase(ctx, resourceGroup, account, name, db) if err != nil { - return fmt.Errorf("Error issuing create/update request for Gremlin Database %s (Account %s): %+v", name, account, err) + return fmt.Errorf("Error issuing create/update request for Gremlin Database %q (Account: %q): %+v", name, account, err) } if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on create/update future for Cosmos Gremlin Database %s (Account %s): %+v", name, account, err) + return fmt.Errorf("Error waiting on create/update future for Cosmos Gremlin Database %q (Account: %q): %+v", name, account, err) } resp, err := client.GetGremlinDatabase(ctx, resourceGroup, account, name) if err != nil { - return fmt.Errorf("Error making get request for Cosmos Gremlin Database %s (Account %s) ID: %v", name, account, err) + return fmt.Errorf("Error making get request for Cosmos Gremlin Database %q (Account: %q) ID: %v", name, account, err) } - id, err := azure.CosmosGetIDFromResponse(resp.Response) - if err != nil { - return fmt.Errorf("Error retrieving the ID for Cosmos Gremlin Database '%s' (Account %s) ID: %v", name, account, err) + if resp.ID == nil { + return fmt.Errorf("Error getting ID from Cosmos Gremlin Database %q (Account: %q)", name, account) } - d.SetId(id) + + d.SetId(*resp.ID) return resourceArmCosmosGremlinDatabaseRead(d, meta) } func resourceArmCosmosGremlinDatabaseUpdate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.GremlinClient ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosDatabaseID(d.Id()) + id, err := parse.GremlinDatabaseID(d.Id()) if err != nil { return err } @@ -139,110 +147,112 @@ func resourceArmCosmosGremlinDatabaseUpdate(d *schema.ResourceData, meta interfa db := documentdb.GremlinDatabaseCreateUpdateParameters{ GremlinDatabaseCreateUpdateProperties: &documentdb.GremlinDatabaseCreateUpdateProperties{ Resource: &documentdb.GremlinDatabaseResource{ - ID: &id.Database, + ID: &id.Name, }, - Options: map[string]*string{}, + Options: &documentdb.CreateUpdateOptions{}, }, } - future, err := client.CreateUpdateGremlinDatabase(ctx, id.ResourceGroup, id.Account, id.Database, db) + future, err := client.CreateUpdateGremlinDatabase(ctx, id.ResourceGroup, id.Account, id.Name, db) if err != nil { - return fmt.Errorf("Error issuing create/update request for Cosmos Gremlin Database %s (Account %s): %+v", id.Database, id.Account, err) + return fmt.Errorf("Error issuing create/update request for Cosmos Gremlin Database %q (Account: %q): %+v", id.Name, id.Account, err) } if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on create/update future for Cosmos Gremlin Database %s (Account %s): %+v", id.Database, id.Account, err) + return fmt.Errorf("Error waiting on create/update future for Cosmos Gremlin Database %q (Account: %q): %+v", id.Name, id.Account, err) } if d.HasChange("throughput") { - throughputParameters := documentdb.ThroughputUpdateParameters{ - ThroughputUpdateProperties: &documentdb.ThroughputUpdateProperties{ - Resource: &documentdb.ThroughputResource{ - Throughput: utils.Int32(int32(d.Get("throughput").(int))), + throughputParameters := documentdb.ThroughputSettingsUpdateParameters{ + ThroughputSettingsUpdateProperties: &documentdb.ThroughputSettingsUpdateProperties{ + Resource: &documentdb.ThroughputSettingsResource{ + Throughput: common.ConvertThroughputFromResourceData(d.Get("throughput")), }, }, } - throughputFuture, err := client.UpdateGremlinDatabaseThroughput(ctx, id.ResourceGroup, id.Account, id.Database, throughputParameters) + throughputFuture, err := client.UpdateGremlinDatabaseThroughput(ctx, id.ResourceGroup, id.Account, id.Name, throughputParameters) if err != nil { if response.WasNotFound(throughputFuture.Response()) { - return fmt.Errorf("Error setting Throughput for Cosmos Gremlin Database %s (Account %s): %+v - "+ - "If the collection has not been created with and initial throughput, you cannot configure it later.", id.Database, id.Account, err) + return fmt.Errorf("Error 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.Name, id.Account, err) } } if err = throughputFuture.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on ThroughputUpdate future for Cosmos Gremlin Database %s (Account %s, Database %s): %+v", id.Database, id.Account, id.Database, err) + return fmt.Errorf("Error waiting on ThroughputUpdate future for Cosmos Gremlin Database %q (Account: %q, Database %q): %+v", id.Name, id.Account, id.Name, err) } } - if _, err = client.GetGremlinDatabase(ctx, id.ResourceGroup, id.Account, id.Database); err != nil { - return fmt.Errorf("Error making get request for Cosmos Gremlin Database %s (Account %s): %+v", id.Database, id.Account, err) + if _, err = client.GetGremlinDatabase(ctx, id.ResourceGroup, id.Account, id.Name); err != nil { + return fmt.Errorf("Error making get request for Cosmos Gremlin Database %q (Account: %q): %+v", id.Name, id.Account, err) } return resourceArmCosmosGremlinDatabaseRead(d, meta) } func resourceArmCosmosGremlinDatabaseRead(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.GremlinClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosDatabaseID(d.Id()) + id, err := parse.GremlinDatabaseID(d.Id()) if err != nil { return err } - resp, err := client.GetGremlinDatabase(ctx, id.ResourceGroup, id.Account, id.Database) + resp, err := client.GetGremlinDatabase(ctx, id.ResourceGroup, id.Account, id.Name) if err != nil { if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[INFO] Error reading Cosmos Gremlin Database %s (Account %s) - removing from state", id.Database, id.Account) + log.Printf("[INFO] Error reading Cosmos Gremlin Database %q (Account: %q) - removing from state", id.Name, id.Account) d.SetId("") return nil } - return fmt.Errorf("Error reading Cosmos Gremlin Database %s (Account %s): %+v", id.Database, id.Account, err) + return fmt.Errorf("Error reading Cosmos Gremlin Database %q (Account: %q): %+v", id.Name, id.Account, err) } d.Set("resource_group_name", id.ResourceGroup) d.Set("account_name", id.Account) - if props := resp.GremlinDatabaseProperties; props != nil { - d.Set("name", props.ID) + if props := resp.GremlinDatabaseGetProperties; props != nil { + if res := props.Resource; res != nil { + d.Set("name", res.ID) + } } - throughputResp, err := client.GetGremlinDatabaseThroughput(ctx, id.ResourceGroup, id.Account, id.Database) + throughputResp, err := client.GetGremlinDatabaseThroughput(ctx, id.ResourceGroup, id.Account, id.Name) if err != nil { if !utils.ResponseWasNotFound(throughputResp.Response) { - return fmt.Errorf("Error reading Throughput on Cosmos Gremlin Database %s (Account %s): %+v", id.Database, id.Account, err) + return fmt.Errorf("Error reading Throughput on Cosmos Gremlin Database %q (Account: %q): %+v", id.Name, id.Account, err) } else { d.Set("throughput", nil) } } else { - d.Set("throughput", throughputResp.Throughput) + d.Set("throughput", common.GetThroughputFromResult(throughputResp)) } return nil } func resourceArmCosmosGremlinDatabaseDelete(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.GremlinClient ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosDatabaseID(d.Id()) + id, err := parse.GremlinDatabaseID(d.Id()) if err != nil { return err } - future, err := client.DeleteGremlinDatabase(ctx, id.ResourceGroup, id.Account, id.Database) + future, err := client.DeleteGremlinDatabase(ctx, id.ResourceGroup, id.Account, id.Name) if err != nil { if !response.WasNotFound(future.Response()) { - return fmt.Errorf("Error deleting Cosmos Gremlin Database %s (Account %s): %+v", id.Database, id.Account, err) + return fmt.Errorf("Error deleting Cosmos Gremlin Database %q (Account: %q): %+v", id.Name, id.Account, err) } } if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on delete future for Cosmos Gremlin Database %s (Account %s): %+v", id.Database, id.Account, err) + return fmt.Errorf("Error waiting on delete future for Cosmos Gremlin Database %q (Account: %q): %+v", id.Name, id.Account, err) } return nil diff --git a/azurerm/internal/services/cosmos/cosmosdb_gremlin_graph_resource.go b/azurerm/internal/services/cosmos/cosmosdb_gremlin_graph_resource.go index 3ea131c6c68f..b68afb18f435 100644 --- a/azurerm/internal/services/cosmos/cosmosdb_gremlin_graph_resource.go +++ b/azurerm/internal/services/cosmos/cosmosdb_gremlin_graph_resource.go @@ -3,10 +3,9 @@ package cosmos import ( "fmt" "log" - "strconv" "time" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb" + "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb" "github.com/hashicorp/go-azure-helpers/response" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" @@ -16,6 +15,9 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/common" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/migration" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/parse" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) @@ -31,6 +33,15 @@ func resourceArmCosmosDbGremlinGraph() *schema.Resource { State: schema.ImportStatePassthrough, }, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: migration.ResourceGremlinGraphUpgradeV0Schema().CoreConfigSchema().ImpliedType(), + Upgrade: migration.ResourceGremlinGraphStateUpgradeV0ToV1, + Version: 0, + }, + }, + Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(30 * time.Minute), Read: schema.DefaultTimeout(5 * time.Minute), @@ -175,7 +186,7 @@ func resourceArmCosmosDbGremlinGraph() *schema.Resource { } func resourceArmCosmosDbGremlinGraphCreate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.GremlinClient ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -189,15 +200,14 @@ func resourceArmCosmosDbGremlinGraphCreate(d *schema.ResourceData, meta interfac existing, err := client.GetGremlinGraph(ctx, resourceGroup, account, database, name) if err != nil { if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("Error checking for presence of creating Cosmos Gremlin Graph %s (Account: %s, Database: %s): %+v", name, account, database, err) + return fmt.Errorf("Error checking for presence of creating Cosmos Gremlin Graph %q (Account: %q, Database: %q): %+v", name, account, database, err) } } else { - id, err := azure.CosmosGetIDFromResponse(existing.Response) - if err != nil { - return fmt.Errorf("Error getting import ID for Cosmos Gremlin Graph '%s' (Account: %s, Database: %s)", name, account, database) + if existing.ID == nil && *existing.ID == "" { + return fmt.Errorf("Error generating import ID for Cosmos Gremlin Graph %q (Account: %q, Database: %q)", name, account, database) } - return tf.ImportAsExistsError("azurerm_cosmosdb_gremlin_graph", id) + return tf.ImportAsExistsError("azurerm_cosmosdb_gremlin_graph", *existing.ID) } } @@ -208,7 +218,7 @@ func resourceArmCosmosDbGremlinGraphCreate(d *schema.ResourceData, meta interfac IndexingPolicy: expandAzureRmCosmosDbGrelinGraphIndexingPolicy(d), ConflictResolutionPolicy: expandAzureRmCosmosDbGremlinGraphConflicResolutionPolicy(d), }, - Options: map[string]*string{}, + Options: &documentdb.CreateUpdateOptions{}, }, } @@ -225,40 +235,38 @@ func resourceArmCosmosDbGremlinGraphCreate(d *schema.ResourceData, meta interfac } if throughput, hasThroughput := d.GetOk("throughput"); hasThroughput { - db.GremlinGraphCreateUpdateProperties.Options = map[string]*string{ - "throughput": utils.String(strconv.Itoa(throughput.(int))), - } + db.GremlinGraphCreateUpdateProperties.Options.Throughput = common.ConvertThroughputFromResourceData(throughput) } future, err := client.CreateUpdateGremlinGraph(ctx, resourceGroup, account, database, name, db) if err != nil { - return fmt.Errorf("Error issuing create/update request for Cosmos Gremlin Graph %s (Account: %s, Database: %s): %+v", name, account, database, err) + return fmt.Errorf("Error issuing create/update request for Cosmos Gremlin Graph %q (Account: %q, Database: %q): %+v", name, account, database, err) } if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on create/update future for Cosmos Gremlin Graph%s (Account: %s, Database:%s): %+v", name, account, database, err) + return fmt.Errorf("Error waiting on create/update future for Cosmos Gremlin Graph%q (Account: %q, Database: %q): %+v", name, account, database, err) } resp, err := client.GetGremlinGraph(ctx, resourceGroup, account, database, name) if err != nil { - return fmt.Errorf("Error making get request for Cosmos Gremlin Graph %s (Account: %s, Database:%s): %+v", name, account, database, err) + return fmt.Errorf("Error making get request for Cosmos Gremlin Graph %q (Account: %q, Database: %q): %+v", name, account, database, err) } - id, err := azure.CosmosGetIDFromResponse(resp.Response) - if err != nil { - return fmt.Errorf("Error retrieving the ID for Cosmos Gramlin Graph '%s' (Account: %s, Database:%s) ID: %v", name, account, database, err) + if resp.ID == nil { + return fmt.Errorf("Error getting ID from Cosmos Gremlin Graph %q (Account: %q, Database: %q)", name, account, database) } - d.SetId(id) + + d.SetId(*resp.ID) return resourceArmCosmosDbGremlinGraphRead(d, meta) } func resourceArmCosmosDbGremlinGraphUpdate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.GremlinClient ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosGramlinGraphID(d.Id()) + id, err := parse.GremlinGraphID(d.Id()) if err != nil { return err } @@ -268,11 +276,11 @@ func resourceArmCosmosDbGremlinGraphUpdate(d *schema.ResourceData, meta interfac db := documentdb.GremlinGraphCreateUpdateParameters{ GremlinGraphCreateUpdateProperties: &documentdb.GremlinGraphCreateUpdateProperties{ Resource: &documentdb.GremlinGraphResource{ - ID: &id.Graph, + ID: &id.Name, IndexingPolicy: expandAzureRmCosmosDbGrelinGraphIndexingPolicy(d), ConflictResolutionPolicy: expandAzureRmCosmosDbGremlinGraphConflicResolutionPolicy(d), }, - Options: map[string]*string{}, + Options: &documentdb.CreateUpdateOptions{}, }, } @@ -288,34 +296,34 @@ func resourceArmCosmosDbGremlinGraphUpdate(d *schema.ResourceData, meta interfac } } - future, err := client.CreateUpdateGremlinGraph(ctx, id.ResourceGroup, id.Account, id.Database, id.Graph, db) + future, err := client.CreateUpdateGremlinGraph(ctx, id.ResourceGroup, id.Account, id.Database, id.Name, db) if err != nil { - return fmt.Errorf("Error issuing create/update request for Cosmos Gremlin Graph %s (Account: %s, Database:%s): %+v", id.Graph, id.Account, id.Database, err) + return fmt.Errorf("Error issuing create/update request for Cosmos Gremlin Graph %q (Account: %q, Database: %q): %+v", id.Name, id.Account, id.Database, err) } if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on create/update future for Cosmos Gremlin Graph %s (Account: %s, Database:%s): %+v", id.Graph, id.Account, id.Database, err) + return fmt.Errorf("Error waiting on create/update future for Cosmos Gremlin Graph %q (Account: %q, Database: %q): %+v", id.Name, id.Account, id.Database, err) } if d.HasChange("throughput") { - throughputParameters := documentdb.ThroughputUpdateParameters{ - ThroughputUpdateProperties: &documentdb.ThroughputUpdateProperties{ - Resource: &documentdb.ThroughputResource{ - Throughput: utils.Int32(int32(d.Get("throughput").(int))), + throughputParameters := documentdb.ThroughputSettingsUpdateParameters{ + ThroughputSettingsUpdateProperties: &documentdb.ThroughputSettingsUpdateProperties{ + Resource: &documentdb.ThroughputSettingsResource{ + Throughput: common.ConvertThroughputFromResourceData(d.Get("throughput")), }, }, } - throughputFuture, err := client.UpdateGremlinGraphThroughput(ctx, id.ResourceGroup, id.Account, id.Database, id.Graph, throughputParameters) + throughputFuture, err := client.UpdateGremlinGraphThroughput(ctx, id.ResourceGroup, id.Account, id.Database, id.Name, throughputParameters) if err != nil { if response.WasNotFound(throughputFuture.Response()) { - return fmt.Errorf("Error setting Throughput for Cosmos Gremlin Graph %s (Account: %s, Database:%s): %+v - "+ - "If the graph has not been created with an initial throughput, you cannot configure it later.", id.Graph, id.Account, id.Database, err) + return fmt.Errorf("Error 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.Name, id.Account, id.Database, err) } } if err = throughputFuture.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on ThroughputUpdate future for Cosmos Gremlin Graph %s (Account: %s, Database:%s): %+v", id.Graph, id.Account, id.Database, err) + return fmt.Errorf("Error waiting on ThroughputUpdate future for Cosmos Gremlin Graph %q (Account: %q, Database: %q): %+v", id.Name, id.Account, id.Database, err) } } @@ -323,94 +331,96 @@ func resourceArmCosmosDbGremlinGraphUpdate(d *schema.ResourceData, meta interfac } func resourceArmCosmosDbGremlinGraphRead(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.GremlinClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosGramlinGraphID(d.Id()) + id, err := parse.GremlinGraphID(d.Id()) if err != nil { return err } - resp, err := client.GetGremlinGraph(ctx, id.ResourceGroup, id.Account, id.Database, id.Graph) + resp, err := client.GetGremlinGraph(ctx, id.ResourceGroup, id.Account, id.Database, id.Name) if err != nil { if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[INFO] Error reading Cosmos Gremlin Graph %s (Account %s) - removing from state", id.Graph, id.Account) + log.Printf("[INFO] Error reading Cosmos Gremlin Graph %q (Account: %q) - removing from state", id.Name, id.Account) d.SetId("") return nil } - return fmt.Errorf("Error reading Cosmos Gremlin Graph %s (Account %s): %+v", id.Graph, id.Account, err) + return fmt.Errorf("Error reading Cosmos Gremlin Graph %q (Account: %q): %+v", id.Name, id.Account, err) } - d.Set("name", id.Graph) + d.Set("name", id.Name) d.Set("resource_group_name", id.ResourceGroup) d.Set("account_name", id.Account) d.Set("database_name", id.Database) - if props := resp.GremlinGraphProperties; props != nil { - if pk := props.PartitionKey; pk != nil { - if paths := pk.Paths; paths != nil { - if len(*paths) > 1 { - return fmt.Errorf("Error reading PartitionKey Paths, more than 1 returned") - } else if len(*paths) == 1 { - d.Set("partition_key_path", (*paths)[0]) + if graphProperties := resp.GremlinGraphGetProperties; graphProperties != nil { + 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("Error reading PartitionKey Paths, more than 1 returned") + } else if len(*paths) == 1 { + d.Set("partition_key_path", (*paths)[0]) + } } } - } - if ip := props.IndexingPolicy; ip != nil { - if err := d.Set("index_policy", flattenAzureRmCosmosDBGremlinGraphIndexingPolicy(props.IndexingPolicy)); err != nil { - return fmt.Errorf("Error setting `index_policy`: %+v", err) + if ip := props.IndexingPolicy; ip != nil { + if err := d.Set("index_policy", flattenAzureRmCosmosDBGremlinGraphIndexingPolicy(props.IndexingPolicy)); err != nil { + return fmt.Errorf("Error setting `index_policy`: %+v", err) + } } - } - if crp := props.ConflictResolutionPolicy; crp != nil { - if err := d.Set("conflict_resolution_policy", flattenAzureRmCosmosDbGremlinGraphConflictResolutionPolicy(props.ConflictResolutionPolicy)); err != nil { - return fmt.Errorf("Error setting `conflict_resolution_policy`: %+v", err) + if crp := props.ConflictResolutionPolicy; crp != nil { + if err := d.Set("conflict_resolution_policy", flattenAzureRmCosmosDbGremlinGraphConflictResolutionPolicy(props.ConflictResolutionPolicy)); err != nil { + return fmt.Errorf("Error setting `conflict_resolution_policy`: %+v", err) + } } - } - if ukp := props.UniqueKeyPolicy; ukp != nil { - if err := d.Set("unique_key", flattenCosmosGremlinGraphUniqueKeys(ukp.UniqueKeys)); err != nil { - return fmt.Errorf("Error setting `unique_key`: %+v", err) + if ukp := props.UniqueKeyPolicy; ukp != nil { + if err := d.Set("unique_key", flattenCosmosGremlinGraphUniqueKeys(ukp.UniqueKeys)); err != nil { + return fmt.Errorf("Error setting `unique_key`: %+v", err) + } } } } - throughputResp, err := client.GetGremlinGraphThroughput(ctx, id.ResourceGroup, id.Account, id.Database, id.Graph) + throughputResp, err := client.GetGremlinGraphThroughput(ctx, id.ResourceGroup, id.Account, id.Database, id.Name) if err != nil { if !utils.ResponseWasNotFound(throughputResp.Response) { - return fmt.Errorf("Error reading Throughput on Gremlin Graph '%s' (Account: %s, Database:%s) ID: %v", id.Graph, id.Account, id.Database, err) + return fmt.Errorf("Error reading Throughput on Gremlin Graph %q (Account: %q, Database: %q) ID: %v", id.Name, id.Account, id.Database, err) } else { d.Set("throughput", nil) } } else { - d.Set("throughput", throughputResp.Throughput) + d.Set("throughput", common.GetThroughputFromResult(throughputResp)) } return nil } func resourceArmCosmosDbGremlinGraphDelete(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.GremlinClient ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosGramlinGraphID(d.Id()) + id, err := parse.GremlinGraphID(d.Id()) if err != nil { return err } - future, err := client.DeleteGremlinGraph(ctx, id.ResourceGroup, id.Account, id.Database, id.Graph) + future, err := client.DeleteGremlinGraph(ctx, id.ResourceGroup, id.Account, id.Database, id.Name) if err != nil { if !response.WasNotFound(future.Response()) { - return fmt.Errorf("Error deleting Cosmos Gremlin Graph %s (Account %s): %+v", id.Database, id.Graph, err) + return fmt.Errorf("Error deleting Cosmos Gremlin Graph %q (Account: %q): %+v", id.Database, id.Name, err) } } if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on delete future for Comos Gremlin Graph %s (Account %s): %+v", id.Database, id.Account, err) + return fmt.Errorf("Error waiting on delete future for Comos Gremlin Graph %q (Account: %q): %+v", id.Database, id.Account, err) } return nil diff --git a/azurerm/internal/services/cosmos/cosmosdb_mongo_collection_resource.go b/azurerm/internal/services/cosmos/cosmosdb_mongo_collection_resource.go index cd0bd4c4b2b0..71068358395d 100644 --- a/azurerm/internal/services/cosmos/cosmosdb_mongo_collection_resource.go +++ b/azurerm/internal/services/cosmos/cosmosdb_mongo_collection_resource.go @@ -3,10 +3,9 @@ package cosmos import ( "fmt" "log" - "strconv" "time" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb" + "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb" "github.com/hashicorp/go-azure-helpers/response" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" @@ -15,6 +14,9 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/common" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/migration" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/parse" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) @@ -30,6 +32,15 @@ func resourceArmCosmosDbMongoCollection() *schema.Resource { State: schema.ImportStatePassthrough, }, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: migration.ResourceMongoDbCollectionUpgradeV0Schema().CoreConfigSchema().ImpliedType(), + Upgrade: migration.ResourceMongoDbCollectionStateUpgradeV0ToV1, + Version: 0, + }, + }, + Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(30 * time.Minute), Read: schema.DefaultTimeout(5 * time.Minute), @@ -82,7 +93,6 @@ func resourceArmCosmosDbMongoCollection() *schema.Resource { Computed: true, ValidateFunc: validate.CosmosThroughput, }, - "index": { Type: schema.TypeSet, Optional: true, @@ -126,7 +136,7 @@ func resourceArmCosmosDbMongoCollection() *schema.Resource { } func resourceArmCosmosDbMongoCollectionCreate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.MongoDbClient ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -139,15 +149,14 @@ func resourceArmCosmosDbMongoCollectionCreate(d *schema.ResourceData, meta inter existing, err := client.GetMongoDBCollection(ctx, resourceGroup, account, database, name) if err != nil { if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("Error checking for presence of creating Cosmos Mongo Collection %s (Account %s, Database %s): %+v", name, account, database, err) + return fmt.Errorf("Error checking for presence of creating Cosmos Mongo Collection %q (Account: %q, Database: %q): %+v", name, account, database, err) } } else { - id, err := azure.CosmosGetIDFromResponse(existing.Response) - if err != nil { - return fmt.Errorf("Error generating import ID for Cosmos Mongo Collection %s (Account %s, Database %s)", name, account, database) + if existing.ID == nil && *existing.ID == "" { + return fmt.Errorf("Error generating import ID for Cosmos Mongo Collection %q (Account: %q, Database: %q)", name, account, database) } - return tf.ImportAsExistsError("azurerm_cosmosdb_mongo_collection", id) + return tf.ImportAsExistsError("azurerm_cosmosdb_mongo_collection", *existing.ID) } } @@ -162,14 +171,12 @@ func resourceArmCosmosDbMongoCollectionCreate(d *schema.ResourceData, meta inter ID: &name, Indexes: expandCosmosMongoCollectionIndex(d.Get("index").(*schema.Set).List(), ttl), }, - Options: map[string]*string{}, + Options: &documentdb.CreateUpdateOptions{}, }, } if throughput, hasThroughput := d.GetOk("throughput"); hasThroughput { - db.MongoDBCollectionCreateUpdateProperties.Options = map[string]*string{ - "throughput": utils.String(strconv.Itoa(throughput.(int))), - } + db.MongoDBCollectionCreateUpdateProperties.Options.Throughput = common.ConvertThroughputFromResourceData(throughput) } if shardKey := d.Get("shard_key").(string); shardKey != "" { @@ -180,33 +187,33 @@ func resourceArmCosmosDbMongoCollectionCreate(d *schema.ResourceData, meta inter future, err := client.CreateUpdateMongoDBCollection(ctx, resourceGroup, account, database, name, db) if err != nil { - return fmt.Errorf("Error issuing create/update request for Cosmos Mongo Collection %s (Account %s, Database %s): %+v", name, account, database, err) + return fmt.Errorf("Error issuing create/update request for Cosmos Mongo Collection %q (Account: %q, Database: %q): %+v", name, account, database, err) } if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on create/update future for Cosmos Mongo Collection %s (Account %s, Database %s): %+v", name, account, database, err) + return fmt.Errorf("Error waiting on create/update future for Cosmos Mongo Collection %q (Account: %q, Database: %q): %+v", name, account, database, err) } resp, err := client.GetMongoDBCollection(ctx, resourceGroup, account, database, name) if err != nil { - return fmt.Errorf("Error making get request for Cosmos Mongo Collection %s (Account %s, Database %s): %+v", name, account, database, err) + return fmt.Errorf("Error making get request for Cosmos Mongo Collection %q (Account: %q, Database: %q): %+v", name, account, database, err) } - id, err := azure.CosmosGetIDFromResponse(resp.Response) - if err != nil { - return fmt.Errorf("Error getting ID for Cosmos Mongo Collection %s (Account %s, Database %s) ID: %v", name, account, database, err) + if resp.ID == nil { + return fmt.Errorf("Error getting ID from Cosmos Mongo Collection %q (Account: %q, Database: %q)", name, account, database) } - d.SetId(id) + + d.SetId(*resp.ID) return resourceArmCosmosDbMongoCollectionRead(d, meta) } func resourceArmCosmosDbMongoCollectionUpdate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.MongoDbClient ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosDatabaseCollectionID(d.Id()) + id, err := parse.MongoDbCollectionID(d.Id()) if err != nil { return err } @@ -219,10 +226,10 @@ func resourceArmCosmosDbMongoCollectionUpdate(d *schema.ResourceData, meta inter db := documentdb.MongoDBCollectionCreateUpdateParameters{ MongoDBCollectionCreateUpdateProperties: &documentdb.MongoDBCollectionCreateUpdateProperties{ Resource: &documentdb.MongoDBCollectionResource{ - ID: &id.Collection, + ID: &id.Name, Indexes: expandCosmosMongoCollectionIndex(d.Get("index").(*schema.Set).List(), ttl), }, - Options: map[string]*string{}, + Options: &documentdb.CreateUpdateOptions{}, }, } @@ -232,34 +239,34 @@ func resourceArmCosmosDbMongoCollectionUpdate(d *schema.ResourceData, meta inter } } - future, err := client.CreateUpdateMongoDBCollection(ctx, id.ResourceGroup, id.Account, id.Database, id.Collection, db) + future, err := client.CreateUpdateMongoDBCollection(ctx, id.ResourceGroup, id.Account, id.Database, id.Name, db) if err != nil { - return fmt.Errorf("Error issuing create/update request for Cosmos Mongo Collection %s (Account %s, Database %s): %+v", id.Collection, id.Account, id.Database, err) + return fmt.Errorf("Error issuing create/update request for Cosmos Mongo Collection %q (Account: %q, Database: %q): %+v", id.Name, id.Account, id.Database, err) } if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on create/update future for Cosmos Mongo Collection %s (Account %s, Database %s): %+v", id.Collection, id.Account, id.Database, err) + return fmt.Errorf("Error waiting on create/update future for Cosmos Mongo Collection %q (Account: %q, Database: %q): %+v", id.Name, id.Account, id.Database, err) } if d.HasChange("throughput") { - throughputParameters := documentdb.ThroughputUpdateParameters{ - ThroughputUpdateProperties: &documentdb.ThroughputUpdateProperties{ - Resource: &documentdb.ThroughputResource{ - Throughput: utils.Int32(int32(d.Get("throughput").(int))), + throughputParameters := documentdb.ThroughputSettingsUpdateParameters{ + ThroughputSettingsUpdateProperties: &documentdb.ThroughputSettingsUpdateProperties{ + Resource: &documentdb.ThroughputSettingsResource{ + Throughput: common.ConvertThroughputFromResourceData(d.Get("throughput")), }, }, } - throughputFuture, err := client.UpdateMongoDBCollectionThroughput(ctx, id.ResourceGroup, id.Account, id.Database, id.Collection, throughputParameters) + throughputFuture, err := client.UpdateMongoDBCollectionThroughput(ctx, id.ResourceGroup, id.Account, id.Database, id.Name, throughputParameters) if err != nil { if response.WasNotFound(throughputFuture.Response()) { - return fmt.Errorf("Error setting Throughput for Cosmos MongoDB Collection %s (Account %s, Database %s): %+v - "+ - "If the collection has not been created with an initial throughput, you cannot configure it later.", id.Collection, id.Account, id.Database, err) + return fmt.Errorf("Error 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.Name, id.Account, id.Database, err) } } if err = throughputFuture.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on ThroughputUpdate future for Cosmos Mongo Collection %s (Account %s, Database %s): %+v", id.Collection, id.Account, id.Database, err) + return fmt.Errorf("Error waiting on ThroughputUpdate future for Cosmos Mongo Collection %q (Account: %q, Database: %q): %+v", id.Name, id.Account, id.Database, err) } } @@ -267,87 +274,89 @@ func resourceArmCosmosDbMongoCollectionUpdate(d *schema.ResourceData, meta inter } func resourceArmCosmosDbMongoCollectionRead(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.MongoDbClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosDatabaseCollectionID(d.Id()) + id, err := parse.MongoDbCollectionID(d.Id()) if err != nil { return err } - resp, err := client.GetMongoDBCollection(ctx, id.ResourceGroup, id.Account, id.Database, id.Collection) + resp, err := client.GetMongoDBCollection(ctx, id.ResourceGroup, id.Account, id.Database, id.Name) if err != nil { if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[INFO] Error reading Cosmos Mongo Collection %s (Account %s, Database %s)", id.Collection, id.Account, id.Database) + log.Printf("[INFO] Error reading Cosmos Mongo Collection %q (Account: %q, Database: %q)", id.Name, id.Account, id.Database) d.SetId("") return nil } - return fmt.Errorf("Error reading Cosmos Mongo Collection %s (Account %s, Database %s): %+v", id.Collection, id.Account, id.Database, err) + return fmt.Errorf("Error reading Cosmos Mongo Collection %q (Account: %q, Database: %q): %+v", id.Name, id.Account, id.Database, err) } d.Set("resource_group_name", id.ResourceGroup) d.Set("account_name", id.Account) d.Set("database_name", id.Database) - if props := resp.MongoDBCollectionProperties; props != nil { - d.Set("name", props.ID) + if props := resp.MongoDBCollectionGetProperties; props != nil { + if res := props.Resource; res != nil { + d.Set("name", res.ID) - // you can only have one - if len(props.ShardKey) > 2 { - return fmt.Errorf("unexpected number of shard keys: %d", len(props.ShardKey)) - } + // you can only have one + if len(res.ShardKey) > 2 { + return fmt.Errorf("unexpected number of shard keys: %d", len(res.ShardKey)) + } - for k := range props.ShardKey { - d.Set("shard_key", k) - } + for k := range res.ShardKey { + d.Set("shard_key", k) + } - indexes, systemIndexes, ttl := flattenCosmosMongoCollectionIndex(props.Indexes) - if err := d.Set("default_ttl_seconds", ttl); err != nil { - return fmt.Errorf("failed to set `default_ttl_seconds`: %+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) + indexes, systemIndexes, ttl := flattenCosmosMongoCollectionIndex(res.Indexes) + if err := d.Set("default_ttl_seconds", ttl); err != nil { + return fmt.Errorf("failed to set `default_ttl_seconds`: %+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) + } } } - throughputResp, err := client.GetMongoDBCollectionThroughput(ctx, id.ResourceGroup, id.Account, id.Database, id.Collection) + throughputResp, err := client.GetMongoDBCollectionThroughput(ctx, id.ResourceGroup, id.Account, id.Database, id.Name) if err != nil { if !utils.ResponseWasNotFound(throughputResp.Response) { - return fmt.Errorf("Error reading Throughput on Cosmos Mongo Collection %s (Account %s, Database %s): %+v", id.Collection, id.Account, id.Database, err) + return fmt.Errorf("Error reading Throughput on Cosmos Mongo Collection %q (Account: %q, Database: %q): %+v", id.Name, id.Account, id.Database, err) } else { d.Set("throughput", nil) } } else { - d.Set("throughput", throughputResp.Throughput) + d.Set("throughput", common.GetThroughputFromResult(throughputResp)) } return nil } func resourceArmCosmosDbMongoCollectionDelete(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.MongoDbClient ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosDatabaseCollectionID(d.Id()) + id, err := parse.MongoDbCollectionID(d.Id()) if err != nil { return err } - future, err := client.DeleteMongoDBCollection(ctx, id.ResourceGroup, id.Account, id.Database, id.Collection) + future, err := client.DeleteMongoDBCollection(ctx, id.ResourceGroup, id.Account, id.Database, id.Name) if err != nil { if !response.WasNotFound(future.Response()) { - return fmt.Errorf("Error deleting Cosmos Mongo Collection %s (Account %s, Database %s): %+v", id.Collection, id.Account, id.Database, err) + return fmt.Errorf("Error deleting Cosmos Mongo Collection %q (Account: %q, Database: %q): %+v", id.Name, id.Account, id.Database, err) } } err = future.WaitForCompletionRef(ctx, client.Client) if err != nil { - return fmt.Errorf("Error waiting on delete future for Cosmos Mongo Collection %s (Account %s, Database %s): %+v", id.Collection, id.Account, id.Database, err) + return fmt.Errorf("Error waiting on delete future for Cosmos Mongo Collection %q (Account: %q, Database: %q): %+v", id.Name, id.Account, id.Database, err) } return nil diff --git a/azurerm/internal/services/cosmos/cosmosdb_mongo_database_resource.go b/azurerm/internal/services/cosmos/cosmosdb_mongo_database_resource.go index e2a91af46967..e251fb9ba174 100644 --- a/azurerm/internal/services/cosmos/cosmosdb_mongo_database_resource.go +++ b/azurerm/internal/services/cosmos/cosmosdb_mongo_database_resource.go @@ -3,10 +3,9 @@ package cosmos import ( "fmt" "log" - "strconv" "time" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb" + "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb" "github.com/hashicorp/go-azure-helpers/response" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" @@ -14,6 +13,9 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/common" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/migration" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/parse" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) @@ -29,6 +31,15 @@ func resourceArmCosmosDbMongoDatabase() *schema.Resource { State: schema.ImportStatePassthrough, }, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: migration.ResourceMongoDbDatabaseUpgradeV0Schema().CoreConfigSchema().ImpliedType(), + Upgrade: migration.ResourceMongoDbDatabaseStateUpgradeV0ToV1, + Version: 0, + }, + }, + Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(30 * time.Minute), Read: schema.DefaultTimeout(5 * time.Minute), @@ -64,7 +75,7 @@ func resourceArmCosmosDbMongoDatabase() *schema.Resource { } func resourceArmCosmosDbMongoDatabaseCreate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.MongoDbClient ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -76,15 +87,14 @@ func resourceArmCosmosDbMongoDatabaseCreate(d *schema.ResourceData, meta interfa existing, err := client.GetMongoDBDatabase(ctx, resourceGroup, account, name) if err != nil { if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("Error checking for presence of creating Cosmos Mongo Database %s (Account %s): %+v", name, account, err) + return fmt.Errorf("Error checking for presence of creating Cosmos Mongo Database %q (Account: %q): %+v", name, account, err) } } else { - id, err := azure.CosmosGetIDFromResponse(existing.Response) - if err != nil { - return fmt.Errorf("Error generating import ID for Cosmos Mongo Database '%s' (Account %s)", name, account) + if existing.ID == nil && *existing.ID == "" { + return fmt.Errorf("Error generating import ID for Cosmos Mongo Database %q (Account: %q)", name, account) } - return tf.ImportAsExistsError("azurerm_cosmosdb_mongo_database", id) + return tf.ImportAsExistsError("azurerm_cosmosdb_mongo_database", *existing.ID) } } @@ -93,45 +103,43 @@ func resourceArmCosmosDbMongoDatabaseCreate(d *schema.ResourceData, meta interfa Resource: &documentdb.MongoDBDatabaseResource{ ID: &name, }, - Options: map[string]*string{}, + Options: &documentdb.CreateUpdateOptions{}, }, } if throughput, hasThroughput := d.GetOk("throughput"); hasThroughput { - db.MongoDBDatabaseCreateUpdateProperties.Options = map[string]*string{ - "throughput": utils.String(strconv.Itoa(throughput.(int))), - } + db.MongoDBDatabaseCreateUpdateProperties.Options.Throughput = common.ConvertThroughputFromResourceData(throughput) } future, err := client.CreateUpdateMongoDBDatabase(ctx, resourceGroup, account, name, db) if err != nil { - return fmt.Errorf("Error issuing create/update request for Cosmos Mongo Database %s (Account %s): %+v", name, account, err) + return fmt.Errorf("Error issuing create/update request for Cosmos Mongo Database %q (Account: %q): %+v", name, account, err) } if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on create/update future for Cosmos Mongo Database %s (Account %s): %+v", name, account, err) + return fmt.Errorf("Error waiting on create/update future for Cosmos Mongo Database %q (Account: %q): %+v", name, account, err) } resp, err := client.GetMongoDBDatabase(ctx, resourceGroup, account, name) if err != nil { - return fmt.Errorf("Error making get request for Cosmos Mongo Database %s (Account %s): %+v", name, account, err) + return fmt.Errorf("Error making get request for Cosmos Mongo Database %q (Account: %q): %+v", name, account, err) } - id, err := azure.CosmosGetIDFromResponse(resp.Response) - if err != nil { - return fmt.Errorf("Error retrieving the ID for Cosmos Mongo Database '%s' (Account %s) ID: %v", name, account, err) + if resp.ID == nil { + return fmt.Errorf("Error getting ID from Cosmos Mongo Database %q (Account: %q)", name, account) } - d.SetId(id) + + d.SetId(*resp.ID) return resourceArmCosmosDbMongoDatabaseRead(d, meta) } func resourceArmCosmosDbMongoDatabaseUpdate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.MongoDbClient ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosDatabaseID(d.Id()) + id, err := parse.MongoDbDatabaseID(d.Id()) if err != nil { return err } @@ -139,112 +147,114 @@ func resourceArmCosmosDbMongoDatabaseUpdate(d *schema.ResourceData, meta interfa db := documentdb.MongoDBDatabaseCreateUpdateParameters{ MongoDBDatabaseCreateUpdateProperties: &documentdb.MongoDBDatabaseCreateUpdateProperties{ Resource: &documentdb.MongoDBDatabaseResource{ - ID: &id.Database, + ID: &id.Name, }, - Options: map[string]*string{}, + Options: &documentdb.CreateUpdateOptions{}, }, } - future, err := client.CreateUpdateMongoDBDatabase(ctx, id.ResourceGroup, id.Account, id.Database, db) + future, err := client.CreateUpdateMongoDBDatabase(ctx, id.ResourceGroup, id.Account, id.Name, db) if err != nil { - return fmt.Errorf("Error issuing create/update request for Cosmos Mongo Database %s (Account %s): %+v", id.Database, id.Account, err) + return fmt.Errorf("Error issuing create/update request for Cosmos Mongo Database %q (Account: %q): %+v", id.Name, id.Account, err) } if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on create/update future for Cosmos Mongo Database %s (Account %s): %+v", id.Database, id.Account, err) + return fmt.Errorf("Error waiting on create/update future for Cosmos Mongo Database %q (Account: %q): %+v", id.Name, id.Account, err) } if d.HasChange("throughput") { - throughputParameters := documentdb.ThroughputUpdateParameters{ - ThroughputUpdateProperties: &documentdb.ThroughputUpdateProperties{ - Resource: &documentdb.ThroughputResource{ - Throughput: utils.Int32(int32(d.Get("throughput").(int))), + throughputParameters := documentdb.ThroughputSettingsUpdateParameters{ + ThroughputSettingsUpdateProperties: &documentdb.ThroughputSettingsUpdateProperties{ + Resource: &documentdb.ThroughputSettingsResource{ + Throughput: common.ConvertThroughputFromResourceData(d.Get("throughput")), }, }, } - throughputFuture, err := client.UpdateMongoDBDatabaseThroughput(ctx, id.ResourceGroup, id.Account, id.Database, throughputParameters) + throughputFuture, err := client.UpdateMongoDBDatabaseThroughput(ctx, id.ResourceGroup, id.Account, id.Name, throughputParameters) if err != nil { if response.WasNotFound(throughputFuture.Response()) { - return fmt.Errorf("Error setting Throughput for Cosmos MongoDB Database %s (Account %s): %+v - "+ - "If the collection has not been created with an initial throughput, you cannot configure it later.", id.Database, id.Account, err) + return fmt.Errorf("Error 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.Account, err) } } if err = throughputFuture.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on ThroughputUpdate future for Cosmos Mongo Database %s (Account %s, Database %s): %+v", id.Database, id.Account, id.Database, err) + return fmt.Errorf("Error waiting on ThroughputUpdate future for Cosmos Mongo Database %q (Account: %q, Database %q): %+v", id.Name, id.Account, id.Name, err) } } - _, err = client.GetMongoDBDatabase(ctx, id.ResourceGroup, id.Account, id.Database) + _, err = client.GetMongoDBDatabase(ctx, id.ResourceGroup, id.Account, id.Name) if err != nil { - return fmt.Errorf("Error making get request for Cosmos Mongo Database %s (Account %s): %+v", id.Database, id.Account, err) + return fmt.Errorf("Error making get request for Cosmos Mongo Database %q (Account: %q): %+v", id.Name, id.Account, err) } return resourceArmCosmosDbMongoDatabaseRead(d, meta) } func resourceArmCosmosDbMongoDatabaseRead(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.MongoDbClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosDatabaseID(d.Id()) + id, err := parse.MongoDbDatabaseID(d.Id()) if err != nil { return err } - resp, err := client.GetMongoDBDatabase(ctx, id.ResourceGroup, id.Account, id.Database) + resp, err := client.GetMongoDBDatabase(ctx, id.ResourceGroup, id.Account, id.Name) if err != nil { if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[INFO] Error reading Cosmos Mongo Database %s (Account %s) - removing from state", id.Database, id.Account) + log.Printf("[INFO] Error reading Cosmos Mongo Database %q (Account: %q) - removing from state", id.Name, id.Account) d.SetId("") return nil } - return fmt.Errorf("Error reading Cosmos Mongo Database %s (Account %s): %+v", id.Database, id.Account, err) + return fmt.Errorf("Error reading Cosmos Mongo Database %q (Account: %q): %+v", id.Name, id.Account, err) } d.Set("resource_group_name", id.ResourceGroup) d.Set("account_name", id.Account) - if props := resp.MongoDBDatabaseProperties; props != nil { - d.Set("name", props.ID) + if props := resp.MongoDBDatabaseGetProperties; props != nil { + if res := props.Resource; res != nil { + d.Set("name", res.ID) + } } - throughputResp, err := client.GetMongoDBDatabaseThroughput(ctx, id.ResourceGroup, id.Account, id.Database) + throughputResp, err := client.GetMongoDBDatabaseThroughput(ctx, id.ResourceGroup, id.Account, id.Name) if err != nil { if !utils.ResponseWasNotFound(throughputResp.Response) { - return fmt.Errorf("Error reading Throughput on Cosmos Mongo Database %s (Account %s): %+v", id.Database, id.Account, err) + return fmt.Errorf("Error reading Throughput on Cosmos Mongo Database %q (Account: %q): %+v", id.Name, id.Account, err) } else { d.Set("throughput", nil) } } else { - d.Set("throughput", throughputResp.Throughput) + d.Set("throughput", common.GetThroughputFromResult(throughputResp)) } return nil } func resourceArmCosmosDbMongoDatabaseDelete(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.MongoDbClient ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosDatabaseID(d.Id()) + id, err := parse.MongoDbDatabaseID(d.Id()) if err != nil { return err } - future, err := client.DeleteMongoDBDatabase(ctx, id.ResourceGroup, id.Account, id.Database) + future, err := client.DeleteMongoDBDatabase(ctx, id.ResourceGroup, id.Account, id.Name) if err != nil { if !response.WasNotFound(future.Response()) { - return fmt.Errorf("Error deleting Cosmos Mongo Database %s (Account %s): %+v", id.Database, id.Account, err) + return fmt.Errorf("Error deleting Cosmos Mongo Database %q (Account: %q): %+v", id.Name, id.Account, err) } } err = future.WaitForCompletionRef(ctx, client.Client) if err != nil { - return fmt.Errorf("Error waiting on delete future for Cosmos Mongo Database %s (Account %s): %+v", id.Database, id.Account, err) + return fmt.Errorf("Error waiting on delete future for Cosmos Mongo Database %q (Account: %q): %+v", id.Name, id.Account, err) } return nil diff --git a/azurerm/internal/services/cosmos/cosmosdb_sql_container_resource.go b/azurerm/internal/services/cosmos/cosmosdb_sql_container_resource.go index d8647a717948..792e22efbe27 100644 --- a/azurerm/internal/services/cosmos/cosmosdb_sql_container_resource.go +++ b/azurerm/internal/services/cosmos/cosmosdb_sql_container_resource.go @@ -3,10 +3,9 @@ package cosmos import ( "fmt" "log" - "strconv" "time" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb" + "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb" "github.com/hashicorp/go-azure-helpers/response" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" @@ -15,6 +14,9 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/common" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/migration" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/parse" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) @@ -30,6 +32,15 @@ func resourceArmCosmosDbSQLContainer() *schema.Resource { State: schema.ImportStatePassthrough, }, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: migration.ResourceSqlContainerUpgradeV0Schema().CoreConfigSchema().ImpliedType(), + Upgrade: migration.ResourceSqlContainerStateUpgradeV0ToV1, + Version: 0, + }, + }, + Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(30 * time.Minute), Read: schema.DefaultTimeout(5 * time.Minute), @@ -105,7 +116,7 @@ func resourceArmCosmosDbSQLContainer() *schema.Resource { } func resourceArmCosmosDbSQLContainerCreate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.SqlClient ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -119,15 +130,14 @@ func resourceArmCosmosDbSQLContainerCreate(d *schema.ResourceData, meta interfac existing, err := client.GetSQLContainer(ctx, resourceGroup, account, database, name) if err != nil { if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("Error checking for presence of creating Cosmos SQL Container %s (Account: %s, Database:%s): %+v", name, account, database, err) + return fmt.Errorf("Error checking for presence of creating Cosmos SQL Container %q (Account: %q, Database: %q): %+v", name, account, database, err) } } else { - id, err := azure.CosmosGetIDFromResponse(existing.Response) - if err != nil { - return fmt.Errorf("Error generating import ID for Cosmos SQL Container '%s' (Account: %s, Database:%s)", name, account, database) + if existing.ID == nil && *existing.ID == "" { + return fmt.Errorf("Error generating import ID for Cosmos SQL Container %q (Account: %q, Database: %q)", name, account, database) } - return tf.ImportAsExistsError("azurerm_cosmosdb_sql_container", id) + return tf.ImportAsExistsError("azurerm_cosmosdb_sql_container", *existing.ID) } } @@ -136,7 +146,7 @@ func resourceArmCosmosDbSQLContainerCreate(d *schema.ResourceData, meta interfac Resource: &documentdb.SQLContainerResource{ ID: &name, }, - Options: map[string]*string{}, + Options: &documentdb.CreateUpdateOptions{}, }, } @@ -158,40 +168,38 @@ func resourceArmCosmosDbSQLContainerCreate(d *schema.ResourceData, meta interfac } if throughput, hasThroughput := d.GetOk("throughput"); hasThroughput { - db.SQLContainerCreateUpdateProperties.Options = map[string]*string{ - "throughput": utils.String(strconv.Itoa(throughput.(int))), - } + db.SQLContainerCreateUpdateProperties.Options.Throughput = common.ConvertThroughputFromResourceData(throughput) } future, err := client.CreateUpdateSQLContainer(ctx, resourceGroup, account, database, name, db) if err != nil { - return fmt.Errorf("Error issuing create/update request for Cosmos SQL Container %s (Account: %s, Database:%s): %+v", name, account, database, err) + return fmt.Errorf("Error issuing create/update request for Cosmos SQL Container %q (Account: %q, Database: %q): %+v", name, account, database, err) } if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on create/update future for Cosmos SQL Container %s (Account: %s, Database:%s): %+v", name, account, database, err) + return fmt.Errorf("Error waiting on create/update future for Cosmos SQL Container %q (Account: %q, Database: %q): %+v", name, account, database, err) } resp, err := client.GetSQLContainer(ctx, resourceGroup, account, database, name) if err != nil { - return fmt.Errorf("Error making get request for Cosmos SQL Container %s (Account: %s, Database:%s): %+v", name, account, database, err) + return fmt.Errorf("Error making get request for Cosmos SQL Container %q (Account: %q, Database: %q): %+v", name, account, database, err) } - id, err := azure.CosmosGetIDFromResponse(resp.Response) - if err != nil { - return fmt.Errorf("Error retrieving the ID for Cosmos SQL Container '%s' (Account: %s, Database:%s) ID: %v", name, account, database, err) + if resp.ID == nil { + return fmt.Errorf("Error getting ID from Cosmos SQL Container %q (Account: %q, Database: %q)", name, account, database) } - d.SetId(id) + + d.SetId(*resp.ID) return resourceArmCosmosDbSQLContainerRead(d, meta) } func resourceArmCosmosDbSQLContainerUpdate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.SqlClient ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosDatabaseContainerID(d.Id()) + id, err := parse.SqlContainerID(d.Id()) if err != nil { return err } @@ -201,9 +209,9 @@ func resourceArmCosmosDbSQLContainerUpdate(d *schema.ResourceData, meta interfac db := documentdb.SQLContainerCreateUpdateParameters{ SQLContainerCreateUpdateProperties: &documentdb.SQLContainerCreateUpdateProperties{ Resource: &documentdb.SQLContainerResource{ - ID: &id.Container, + ID: &id.Name, }, - Options: map[string]*string{}, + Options: &documentdb.CreateUpdateOptions{}, }, } @@ -224,34 +232,34 @@ func resourceArmCosmosDbSQLContainerUpdate(d *schema.ResourceData, meta interfac db.SQLContainerCreateUpdateProperties.Resource.DefaultTTL = utils.Int32(int32(defaultTTL.(int))) } - future, err := client.CreateUpdateSQLContainer(ctx, id.ResourceGroup, id.Account, id.Database, id.Container, db) + future, err := client.CreateUpdateSQLContainer(ctx, id.ResourceGroup, id.Account, id.Database, id.Name, db) if err != nil { - return fmt.Errorf("Error issuing create/update request for Cosmos SQL Container %s (Account: %s, Database:%s): %+v", id.Container, id.Account, id.Database, err) + return fmt.Errorf("Error issuing create/update request for Cosmos SQL Container %q (Account: %q, Database: %q): %+v", id.Name, id.Account, id.Database, err) } if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on create/update future for Cosmos SQL Container %s (Account: %s, Database:%s): %+v", id.Container, id.Account, id.Database, err) + return fmt.Errorf("Error waiting on create/update future for Cosmos SQL Container %q (Account: %q, Database: %q): %+v", id.Name, id.Account, id.Database, err) } if d.HasChange("throughput") { - throughputParameters := documentdb.ThroughputUpdateParameters{ - ThroughputUpdateProperties: &documentdb.ThroughputUpdateProperties{ - Resource: &documentdb.ThroughputResource{ - Throughput: utils.Int32(int32(d.Get("throughput").(int))), + throughputParameters := documentdb.ThroughputSettingsUpdateParameters{ + ThroughputSettingsUpdateProperties: &documentdb.ThroughputSettingsUpdateProperties{ + Resource: &documentdb.ThroughputSettingsResource{ + Throughput: common.ConvertThroughputFromResourceData(d.Get("throughput")), }, }, } - throughputFuture, err := client.UpdateSQLContainerThroughput(ctx, id.ResourceGroup, id.Account, id.Database, id.Container, throughputParameters) + throughputFuture, err := client.UpdateSQLContainerThroughput(ctx, id.ResourceGroup, id.Account, id.Database, id.Name, throughputParameters) if err != nil { if response.WasNotFound(throughputFuture.Response()) { - return fmt.Errorf("Error setting Throughput for Cosmos SQL Container %s (Account: %s, Database:%s): %+v - "+ - "If the collection has not been created with an initial throughput, you cannot configure it later.", id.Container, id.Account, id.Database, err) + return fmt.Errorf("Error 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.Name, id.Account, id.Database, err) } } if err = throughputFuture.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on ThroughputUpdate future for Cosmos Container %s (Account: %s, Database:%s): %+v", id.Container, id.Account, id.Database, err) + return fmt.Errorf("Error waiting on ThroughputUpdate future for Cosmos Container %q (Account: %q, Database: %q): %+v", id.Name, id.Account, id.Database, err) } } @@ -259,87 +267,89 @@ func resourceArmCosmosDbSQLContainerUpdate(d *schema.ResourceData, meta interfac } func resourceArmCosmosDbSQLContainerRead(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.SqlClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosDatabaseContainerID(d.Id()) + id, err := parse.SqlContainerID(d.Id()) if err != nil { return err } - resp, err := client.GetSQLContainer(ctx, id.ResourceGroup, id.Account, id.Database, id.Container) + resp, err := client.GetSQLContainer(ctx, id.ResourceGroup, id.Account, id.Database, id.Name) if err != nil { if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[INFO] Error reading Cosmos SQL Container %s (Account %s) - removing from state", id.Database, id.Container) + log.Printf("[INFO] Error reading Cosmos SQL Container %q (Account: %q) - removing from state", id.Database, id.Name) d.SetId("") return nil } - return fmt.Errorf("Error reading Cosmos SQL Container %s (Account %s): %+v", id.Database, id.Container, err) + return fmt.Errorf("Error reading Cosmos SQL Container %q (Account: %q): %+v", id.Database, id.Name, err) } - d.Set("name", id.Container) + d.Set("name", id.Name) d.Set("resource_group_name", id.ResourceGroup) d.Set("account_name", id.Account) d.Set("database_name", id.Database) - if props := resp.SQLContainerProperties; props != nil { - if pk := props.PartitionKey; pk != nil { - if paths := pk.Paths; paths != nil { - if len(*paths) > 1 { - return fmt.Errorf("Error reading PartitionKey Paths, more then 1 returned") - } else if len(*paths) == 1 { - d.Set("partition_key_path", (*paths)[0]) + if props := resp.SQLContainerGetProperties; props != nil { + if res := props.Resource; res != nil { + if pk := res.PartitionKey; pk != nil { + if paths := pk.Paths; paths != nil { + if len(*paths) > 1 { + return fmt.Errorf("Error reading PartitionKey Paths, more then 1 returned") + } else if len(*paths) == 1 { + d.Set("partition_key_path", (*paths)[0]) + } } } - } - if ukp := props.UniqueKeyPolicy; ukp != nil { - if err := d.Set("unique_key", flattenCosmosSQLContainerUniqueKeys(ukp.UniqueKeys)); err != nil { - return fmt.Errorf("Error setting `unique_key`: %+v", err) + if ukp := res.UniqueKeyPolicy; ukp != nil { + if err := d.Set("unique_key", flattenCosmosSQLContainerUniqueKeys(ukp.UniqueKeys)); err != nil { + return fmt.Errorf("Error setting `unique_key`: %+v", err) + } } - } - if defaultTTL := props.DefaultTTL; defaultTTL != nil { - d.Set("default_ttl", defaultTTL) + if defaultTTL := res.DefaultTTL; defaultTTL != nil { + d.Set("default_ttl", defaultTTL) + } } } - throughputResp, err := client.GetSQLContainerThroughput(ctx, id.ResourceGroup, id.Account, id.Database, id.Container) + throughputResp, err := client.GetSQLContainerThroughput(ctx, id.ResourceGroup, id.Account, id.Database, id.Name) if err != nil { if !utils.ResponseWasNotFound(throughputResp.Response) { - return fmt.Errorf("Error reading Throughput on Cosmos SQL Container '%s' (Account: %s, Database:%s) ID: %v", id.Container, id.Account, id.Database, err) + return fmt.Errorf("Error reading Throughput on Cosmos SQL Container %s (Account: %q, Database: %q) ID: %v", id.Name, id.Account, id.Database, err) } else { d.Set("throughput", nil) } } else { - d.Set("throughput", throughputResp.Throughput) + d.Set("throughput", common.GetThroughputFromResult(throughputResp)) } return nil } func resourceArmCosmosDbSQLContainerDelete(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.SqlClient ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosDatabaseContainerID(d.Id()) + id, err := parse.SqlContainerID(d.Id()) if err != nil { return err } - future, err := client.DeleteSQLContainer(ctx, id.ResourceGroup, id.Account, id.Database, id.Container) + future, err := client.DeleteSQLContainer(ctx, id.ResourceGroup, id.Account, id.Database, id.Name) if err != nil { if !response.WasNotFound(future.Response()) { - return fmt.Errorf("Error deleting Cosmos SQL Container %s (Account %s): %+v", id.Database, id.Container, err) + return fmt.Errorf("Error deleting Cosmos SQL Container %q (Account: %q): %+v", id.Database, id.Name, err) } } err = future.WaitForCompletionRef(ctx, client.Client) if err != nil { - return fmt.Errorf("Error waiting on delete future for Cosmos SQL Container %s (Account %s): %+v", id.Database, id.Account, err) + return fmt.Errorf("Error waiting on delete future for Cosmos SQL Container %q (Account: %q): %+v", id.Database, id.Account, err) } return nil diff --git a/azurerm/internal/services/cosmos/cosmosdb_sql_database_resource.go b/azurerm/internal/services/cosmos/cosmosdb_sql_database_resource.go index cc2809e9ce50..c16270dc7bdf 100644 --- a/azurerm/internal/services/cosmos/cosmosdb_sql_database_resource.go +++ b/azurerm/internal/services/cosmos/cosmosdb_sql_database_resource.go @@ -3,10 +3,9 @@ package cosmos import ( "fmt" "log" - "strconv" "time" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb" + "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb" "github.com/hashicorp/go-azure-helpers/response" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" @@ -14,6 +13,9 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/common" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/migration" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/parse" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) @@ -29,6 +31,15 @@ func resourceArmCosmosDbSQLDatabase() *schema.Resource { State: schema.ImportStatePassthrough, }, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: migration.ResourceSqlDatabaseUpgradeV0Schema().CoreConfigSchema().ImpliedType(), + Upgrade: migration.ResourceSqlDatabaseStateUpgradeV0ToV1, + Version: 0, + }, + }, + Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(30 * time.Minute), Read: schema.DefaultTimeout(5 * time.Minute), @@ -64,7 +75,7 @@ func resourceArmCosmosDbSQLDatabase() *schema.Resource { } func resourceArmCosmosDbSQLDatabaseCreate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.SqlClient ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -76,15 +87,14 @@ func resourceArmCosmosDbSQLDatabaseCreate(d *schema.ResourceData, meta interface existing, err := client.GetSQLDatabase(ctx, resourceGroup, account, name) if err != nil { if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("Error checking for presence of creating Cosmos SQL Database %s (Account %s): %+v", name, account, err) + return fmt.Errorf("Error checking for presence of creating Cosmos SQL Database %q (Account: %q): %+v", name, account, err) } } else { - id, err := azure.CosmosGetIDFromResponse(existing.Response) - if err != nil { - return fmt.Errorf("Error generating import ID for Cosmos SQL Database '%s' (Account %s)", name, account) + if existing.ID == nil && *existing.ID == "" { + return fmt.Errorf("Error generating import ID for Cosmos SQL Database %q (Account: %q)", name, account) } - return tf.ImportAsExistsError("azurerm_cosmosdb_sql_database", id) + return tf.ImportAsExistsError("azurerm_cosmosdb_sql_database", *existing.ID) } } @@ -93,45 +103,43 @@ func resourceArmCosmosDbSQLDatabaseCreate(d *schema.ResourceData, meta interface Resource: &documentdb.SQLDatabaseResource{ ID: &name, }, - Options: map[string]*string{}, + Options: &documentdb.CreateUpdateOptions{}, }, } if throughput, hasThroughput := d.GetOk("throughput"); hasThroughput { - db.SQLDatabaseCreateUpdateProperties.Options = map[string]*string{ - "throughput": utils.String(strconv.Itoa(throughput.(int))), - } + db.SQLDatabaseCreateUpdateProperties.Options.Throughput = common.ConvertThroughputFromResourceData(throughput) } future, err := client.CreateUpdateSQLDatabase(ctx, resourceGroup, account, name, db) if err != nil { - return fmt.Errorf("Error issuing create/update request for Cosmos SQL Database %s (Account %s): %+v", name, account, err) + return fmt.Errorf("Error issuing create/update request for Cosmos SQL Database %q (Account: %q): %+v", name, account, err) } if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on create/update future for Cosmos SQL Database %s (Account %s): %+v", name, account, err) + return fmt.Errorf("Error waiting on create/update future for Cosmos SQL Database %q (Account: %q): %+v", name, account, err) } resp, err := client.GetSQLDatabase(ctx, resourceGroup, account, name) if err != nil { - return fmt.Errorf("Error making get request for Cosmos SQL Database %s (Account %s): %+v", name, account, err) + return fmt.Errorf("Error making get request for Cosmos SQL Database %q (Account: %q): %+v", name, account, err) } - id, err := azure.CosmosGetIDFromResponse(resp.Response) - if err != nil { - return fmt.Errorf("Error retrieving the ID for Cosmos SQL Database '%s' (Account %s) ID: %v", name, account, err) + if resp.ID == nil { + return fmt.Errorf("Error getting ID from Cosmos SQL Database %q (Account: %q)", name, account) } - d.SetId(id) + + d.SetId(*resp.ID) return resourceArmCosmosDbSQLDatabaseRead(d, meta) } func resourceArmCosmosDbSQLDatabaseUpdate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.SqlClient ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosDatabaseID(d.Id()) + id, err := parse.SqlDatabaseID(d.Id()) if err != nil { return err } @@ -139,40 +147,40 @@ func resourceArmCosmosDbSQLDatabaseUpdate(d *schema.ResourceData, meta interface db := documentdb.SQLDatabaseCreateUpdateParameters{ SQLDatabaseCreateUpdateProperties: &documentdb.SQLDatabaseCreateUpdateProperties{ Resource: &documentdb.SQLDatabaseResource{ - ID: &id.Database, + ID: &id.Name, }, - Options: map[string]*string{}, + Options: &documentdb.CreateUpdateOptions{}, }, } - future, err := client.CreateUpdateSQLDatabase(ctx, id.ResourceGroup, id.Account, id.Database, db) + future, err := client.CreateUpdateSQLDatabase(ctx, id.ResourceGroup, id.Account, id.Name, db) if err != nil { - return fmt.Errorf("Error issuing create/update request for Cosmos SQL Database %s (Account %s): %+v", id.Database, id.Account, err) + return fmt.Errorf("Error issuing create/update request for Cosmos SQL Database %q (Account: %q): %+v", id.Name, id.Account, err) } if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on create/update future for Cosmos SQL Database %s (Account %s): %+v", id.Database, id.Account, err) + return fmt.Errorf("Error waiting on create/update future for Cosmos SQL Database %q (Account: %q): %+v", id.Name, id.Account, err) } if d.HasChange("throughput") { - throughputParameters := documentdb.ThroughputUpdateParameters{ - ThroughputUpdateProperties: &documentdb.ThroughputUpdateProperties{ - Resource: &documentdb.ThroughputResource{ - Throughput: utils.Int32(int32(d.Get("throughput").(int))), + throughputParameters := documentdb.ThroughputSettingsUpdateParameters{ + ThroughputSettingsUpdateProperties: &documentdb.ThroughputSettingsUpdateProperties{ + Resource: &documentdb.ThroughputSettingsResource{ + Throughput: common.ConvertThroughputFromResourceData(d.Get("throughput")), }, }, } - throughputFuture, err := client.UpdateSQLDatabaseThroughput(ctx, id.ResourceGroup, id.Account, id.Database, throughputParameters) + throughputFuture, err := client.UpdateSQLDatabaseThroughput(ctx, id.ResourceGroup, id.Account, id.Name, throughputParameters) if err != nil { if response.WasNotFound(throughputFuture.Response()) { - return fmt.Errorf("Error setting Throughput for Cosmos SQL Database %s (Account %s) %+v - "+ - "If the collection has not been created with an initial throughput, you cannot configure it later.", id.Database, id.Account, err) + return fmt.Errorf("Error 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.Account, err) } } if err = throughputFuture.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on ThroughputUpdate future for Cosmos SQL Database %s (Account %s): %+v", id.Database, id.Account, err) + return fmt.Errorf("Error waiting on ThroughputUpdate future for Cosmos SQL Database %q (Account: %q): %+v", id.Name, id.Account, err) } } @@ -180,66 +188,68 @@ func resourceArmCosmosDbSQLDatabaseUpdate(d *schema.ResourceData, meta interface } func resourceArmCosmosDbSQLDatabaseRead(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.SqlClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosDatabaseID(d.Id()) + id, err := parse.SqlDatabaseID(d.Id()) if err != nil { return err } - resp, err := client.GetSQLDatabase(ctx, id.ResourceGroup, id.Account, id.Database) + resp, err := client.GetSQLDatabase(ctx, id.ResourceGroup, id.Account, id.Name) if err != nil { if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[INFO] Error reading Cosmos SQL Database %s (Account %s) - removing from state", id.Database, id.Account) + log.Printf("[INFO] Error reading Cosmos SQL Database %q (Account: %q) - removing from state", id.Name, id.Account) d.SetId("") return nil } - return fmt.Errorf("Error reading Cosmos SQL Database %s (Account %s): %+v", id.Database, id.Account, err) + return fmt.Errorf("Error reading Cosmos SQL Database %q (Account: %q): %+v", id.Name, id.Account, err) } d.Set("resource_group_name", id.ResourceGroup) d.Set("account_name", id.Account) - if props := resp.SQLDatabaseProperties; props != nil { - d.Set("name", props.ID) + if props := resp.SQLDatabaseGetProperties; props != nil { + if res := props.Resource; res != nil { + d.Set("name", res.ID) + } } - throughputResp, err := client.GetSQLDatabaseThroughput(ctx, id.ResourceGroup, id.Account, id.Database) + throughputResp, err := client.GetSQLDatabaseThroughput(ctx, id.ResourceGroup, id.Account, id.Name) if err != nil { if !utils.ResponseWasNotFound(throughputResp.Response) { - return fmt.Errorf("Error reading Throughput on Cosmos SQL Database '%s' (Account %s) ID: %v", id.Database, id.Account, err) + return fmt.Errorf("Error reading Throughput on Cosmos SQL Database %q (Account: %q) ID: %v", id.Name, id.Account, err) } else { d.Set("throughput", nil) } } else { - d.Set("throughput", throughputResp.Throughput) + d.Set("throughput", common.GetThroughputFromResult(throughputResp)) } return nil } func resourceArmCosmosDbSQLDatabaseDelete(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.SqlClient ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosDatabaseID(d.Id()) + id, err := parse.SqlDatabaseID(d.Id()) if err != nil { return err } - future, err := client.DeleteSQLDatabase(ctx, id.ResourceGroup, id.Account, id.Database) + future, err := client.DeleteSQLDatabase(ctx, id.ResourceGroup, id.Account, id.Name) if err != nil { if !response.WasNotFound(future.Response()) { - return fmt.Errorf("Error deleting Cosmos SQL Database %s (Account %s): %+v", id.Database, id.Account, err) + return fmt.Errorf("Error deleting Cosmos SQL Database %q (Account: %q): %+v", id.Name, id.Account, err) } } err = future.WaitForCompletionRef(ctx, client.Client) if err != nil { - return fmt.Errorf("Error waiting on delete future for Cosmos SQL Database %s (Account %s): %+v", id.Database, id.Account, err) + return fmt.Errorf("Error waiting on delete future for Cosmos SQL Database %q (Account: %q): %+v", id.Name, id.Account, err) } return nil diff --git a/azurerm/internal/services/cosmos/cosmosdb_table_resource.go b/azurerm/internal/services/cosmos/cosmosdb_table_resource.go index 19b5d6f1783a..322a6185400c 100644 --- a/azurerm/internal/services/cosmos/cosmosdb_table_resource.go +++ b/azurerm/internal/services/cosmos/cosmosdb_table_resource.go @@ -3,10 +3,9 @@ package cosmos import ( "fmt" "log" - "strconv" "time" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb" + "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb" "github.com/hashicorp/go-azure-helpers/response" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" @@ -14,6 +13,9 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/common" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/migration" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cosmos/parse" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) @@ -29,6 +31,15 @@ func resourceArmCosmosDbTable() *schema.Resource { State: schema.ImportStatePassthrough, }, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: migration.ResourceTableUpgradeV0Schema().CoreConfigSchema().ImpliedType(), + Upgrade: migration.ResourceTableStateUpgradeV0ToV1, + Version: 0, + }, + }, + Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(30 * time.Minute), Read: schema.DefaultTimeout(5 * time.Minute), @@ -64,7 +75,7 @@ func resourceArmCosmosDbTable() *schema.Resource { } func resourceArmCosmosDbTableCreate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.TableClient ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -76,15 +87,14 @@ func resourceArmCosmosDbTableCreate(d *schema.ResourceData, meta interface{}) er existing, err := client.GetTable(ctx, resourceGroup, account, name) if err != nil { if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("Error checking for presence of creating Cosmos Table %s (Account %s): %+v", name, account, err) + return fmt.Errorf("Error checking for presence of creating Cosmos Table %q (Account: %q): %+v", name, account, err) } } else { - id, err := azure.CosmosGetIDFromResponse(existing.Response) - if err != nil { - return fmt.Errorf("Error generating import ID for Cosmos Table '%s' (Account %s)", name, account) + if existing.ID == nil && *existing.ID == "" { + return fmt.Errorf("Error generating import ID for Cosmos %q (Account: %q)", name, account) } - return tf.ImportAsExistsError("azurerm_cosmosdb_mongo_database", id) + return tf.ImportAsExistsError("azurerm_cosmosdb_mongo_database", *existing.ID) } } @@ -93,45 +103,43 @@ func resourceArmCosmosDbTableCreate(d *schema.ResourceData, meta interface{}) er Resource: &documentdb.TableResource{ ID: &name, }, - Options: map[string]*string{}, + Options: &documentdb.CreateUpdateOptions{}, }, } if throughput, hasThroughput := d.GetOk("throughput"); hasThroughput { - db.TableCreateUpdateProperties.Options = map[string]*string{ - "throughput": utils.String(strconv.Itoa(throughput.(int))), - } + db.TableCreateUpdateProperties.Options.Throughput = common.ConvertThroughputFromResourceData(throughput) } future, err := client.CreateUpdateTable(ctx, resourceGroup, account, name, db) if err != nil { - return fmt.Errorf("Error issuing create/update request for Cosmos Table %s (Account %s): %+v", name, account, err) + return fmt.Errorf("Error issuing create/update request for Cosmos Table %q (Account: %q): %+v", name, account, err) } if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on create/update future for Cosmos Table %s (Account %s): %+v", name, account, err) + return fmt.Errorf("Error waiting on create/update future for Cosmos Table %q (Account: %q): %+v", name, account, err) } resp, err := client.GetTable(ctx, resourceGroup, account, name) if err != nil { - return fmt.Errorf("Error making get request for Cosmos Table %s (Account %s): %+v", name, account, err) + return fmt.Errorf("Error making get request for Cosmos Table %q (Account: %q): %+v", name, account, err) } - id, err := azure.CosmosGetIDFromResponse(resp.Response) - if err != nil { - return fmt.Errorf("Error retrieving the ID for Cosmos Table '%s' (Account %s) ID: %v", name, account, err) + if resp.ID == nil { + return fmt.Errorf("Error getting ID from Cosmos Table %q (Account: %q)", name, account) } - d.SetId(id) + + d.SetId(*resp.ID) return resourceArmCosmosDbTableRead(d, meta) } func resourceArmCosmosDbTableUpdate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.TableClient ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosTableID(d.Id()) + id, err := parse.TableID(d.Id()) if err != nil { return err } @@ -139,40 +147,40 @@ func resourceArmCosmosDbTableUpdate(d *schema.ResourceData, meta interface{}) er db := documentdb.TableCreateUpdateParameters{ TableCreateUpdateProperties: &documentdb.TableCreateUpdateProperties{ Resource: &documentdb.TableResource{ - ID: &id.Table, + ID: &id.Name, }, - Options: map[string]*string{}, + Options: &documentdb.CreateUpdateOptions{}, }, } - future, err := client.CreateUpdateTable(ctx, id.ResourceGroup, id.Account, id.Table, db) + future, err := client.CreateUpdateTable(ctx, id.ResourceGroup, id.Account, id.Name, db) if err != nil { - return fmt.Errorf("Error issuing create/update request for Cosmos Table %s (Account %s): %+v", id.Table, id.Account, err) + return fmt.Errorf("Error issuing create/update request for Cosmos Table %q (Account: %q): %+v", id.Name, id.Account, err) } if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on create/update future for Cosmos Table %s (Account %s): %+v", id.Table, id.Account, err) + return fmt.Errorf("Error waiting on create/update future for Cosmos Table %q (Account: %q): %+v", id.Name, id.Account, err) } if d.HasChange("throughput") { - throughputParameters := documentdb.ThroughputUpdateParameters{ - ThroughputUpdateProperties: &documentdb.ThroughputUpdateProperties{ - Resource: &documentdb.ThroughputResource{ - Throughput: utils.Int32(int32(d.Get("throughput").(int))), + throughputParameters := documentdb.ThroughputSettingsUpdateParameters{ + ThroughputSettingsUpdateProperties: &documentdb.ThroughputSettingsUpdateProperties{ + Resource: &documentdb.ThroughputSettingsResource{ + Throughput: common.ConvertThroughputFromResourceData(d.Get("throughput")), }, }, } - throughputFuture, err := client.UpdateTableThroughput(ctx, id.ResourceGroup, id.Account, id.Table, throughputParameters) + throughputFuture, err := client.UpdateTableThroughput(ctx, id.ResourceGroup, id.Account, id.Name, throughputParameters) if err != nil { if response.WasNotFound(throughputFuture.Response()) { - return fmt.Errorf("Error setting Throughput for Cosmos Table %s (Account %s): %+v - "+ - "If the collection has not been created with an initial throughput, you cannot configure it later.", id.Table, id.Account, err) + return fmt.Errorf("Error 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.Account, err) } } if err = throughputFuture.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting on ThroughputUpdate future for Cosmos Table %s (Account %s): %+v", id.Table, id.Account, err) + return fmt.Errorf("Error waiting on ThroughputUpdate future for Cosmos Table %q (Account: %q): %+v", id.Name, id.Account, err) } } @@ -180,66 +188,68 @@ func resourceArmCosmosDbTableUpdate(d *schema.ResourceData, meta interface{}) er } func resourceArmCosmosDbTableRead(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.TableClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosTableID(d.Id()) + id, err := parse.TableID(d.Id()) if err != nil { return err } - resp, err := client.GetTable(ctx, id.ResourceGroup, id.Account, id.Table) + resp, err := client.GetTable(ctx, id.ResourceGroup, id.Account, id.Name) if err != nil { if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[INFO] Error reading Cosmos Table %s (Account %s) - removing from state", id.Table, id.Account) + log.Printf("[INFO] Error reading Cosmos Table %q (Account: %q) - removing from state", id.Name, id.Account) d.SetId("") return nil } - return fmt.Errorf("Error reading Cosmos Table %s (Account %s): %+v", id.Table, id.Account, err) + return fmt.Errorf("Error reading Cosmos Table %q (Account: %q): %+v", id.Name, id.Account, err) } d.Set("resource_group_name", id.ResourceGroup) d.Set("account_name", id.Account) - if props := resp.TableProperties; props != nil { - d.Set("name", props.ID) + if props := resp.TableGetProperties; props != nil { + if res := props.Resource; res != nil { + d.Set("name", res.ID) + } } - throughputResp, err := client.GetTableThroughput(ctx, id.ResourceGroup, id.Account, id.Table) + throughputResp, err := client.GetTableThroughput(ctx, id.ResourceGroup, id.Account, id.Name) if err != nil { if !utils.ResponseWasNotFound(throughputResp.Response) { - return fmt.Errorf("Error reading Throughput on Cosmos Table %s (Account %s) ID: %v", id.Table, id.Account, err) + return fmt.Errorf("Error reading Throughput on Cosmos Table %q (Account: %q) ID: %v", id.Name, id.Account, err) } else { d.Set("throughput", nil) } } else { - d.Set("throughput", throughputResp.Throughput) + d.Set("throughput", common.GetThroughputFromResult(throughputResp)) } return nil } func resourceArmCosmosDbTableDelete(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cosmos.DatabaseClient + client := meta.(*clients.Client).Cosmos.TableClient ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseCosmosTableID(d.Id()) + id, err := parse.TableID(d.Id()) if err != nil { return err } - future, err := client.DeleteTable(ctx, id.ResourceGroup, id.Account, id.Table) + future, err := client.DeleteTable(ctx, id.ResourceGroup, id.Account, id.Name) if err != nil { if !response.WasNotFound(future.Response()) { - return fmt.Errorf("Error deleting Cosmos Table %s (Account %s): %+v", id.Table, id.Account, err) + return fmt.Errorf("Error deleting Cosmos Table %q (Account: %q): %+v", id.Name, id.Account, err) } } err = future.WaitForCompletionRef(ctx, client.Client) if err != nil { - return fmt.Errorf("Error waiting on delete future for Cosmos Table %s (Account %s): %+v", id.Table, id.Account, err) + return fmt.Errorf("Error waiting on delete future for Cosmos Table %q (Account: %q): %+v", id.Name, id.Account, err) } return nil diff --git a/azurerm/internal/services/cosmos/migration/cassandra_keyspace.go b/azurerm/internal/services/cosmos/migration/cassandra_keyspace.go new file mode 100644 index 000000000000..468e67077564 --- /dev/null +++ b/azurerm/internal/services/cosmos/migration/cassandra_keyspace.go @@ -0,0 +1,50 @@ +package migration + +import ( + "log" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" +) + +func ResourceCassandraKeyspaceUpgradeV0Schema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.CosmosEntityName, + }, + + "resource_group_name": azure.SchemaResourceGroupName(), + + "account_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.CosmosAccountName, + }, + + "throughput": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + ValidateFunc: validate.CosmosThroughput, + }, + }, + } +} + +func ResourceCassandraKeyspaceStateUpgradeV0ToV1(rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + oldId := rawState["id"].(string) + newId := strings.Replace(rawState["id"].(string), "apis/cassandra/keyspaces", "cassandraKeyspaces", 1) + + log.Printf("[DEBUG] Updating ID from %q to %q", oldId, newId) + + rawState["id"] = newId + + return rawState, nil +} diff --git a/azurerm/internal/services/cosmos/migration/gremlin_database.go b/azurerm/internal/services/cosmos/migration/gremlin_database.go new file mode 100644 index 000000000000..24f2767c7268 --- /dev/null +++ b/azurerm/internal/services/cosmos/migration/gremlin_database.go @@ -0,0 +1,50 @@ +package migration + +import ( + "log" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" +) + +func ResourceGremlinDatabaseUpgradeV0Schema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.CosmosEntityName, + }, + + "resource_group_name": azure.SchemaResourceGroupName(), + + "account_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.CosmosAccountName, + }, + + "throughput": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + ValidateFunc: validate.CosmosThroughput, + }, + }, + } +} + +func ResourceGremlinDatabaseStateUpgradeV0ToV1(rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + oldId := rawState["id"].(string) + newId := strings.Replace(rawState["id"].(string), "apis/gremlin/databases", "gremlinDatabases", 1) + + log.Printf("[DEBUG] Updating ID from %q to %q", oldId, newId) + + rawState["id"] = newId + + return rawState, nil +} diff --git a/azurerm/internal/services/cosmos/migration/gremlin_graph.go b/azurerm/internal/services/cosmos/migration/gremlin_graph.go new file mode 100644 index 000000000000..9998abcdeab9 --- /dev/null +++ b/azurerm/internal/services/cosmos/migration/gremlin_graph.go @@ -0,0 +1,162 @@ +package migration + +import ( + "log" + "strings" + + "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/suppress" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" +) + +func ResourceGremlinGraphUpgradeV0Schema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.CosmosEntityName, + }, + + "resource_group_name": azure.SchemaResourceGroupName(), + + "account_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.CosmosAccountName, + }, + + "database_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.CosmosEntityName, + }, + + "throughput": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + ValidateFunc: validate.CosmosThroughput, + }, + + "partition_key_path": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "index_policy": { + Type: schema.TypeList, + Required: true, + ForceNew: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "automatic": { + Type: schema.TypeBool, + Optional: true, + Default: true, + }, + + "indexing_mode": { + Type: schema.TypeString, + Required: true, + DiffSuppressFunc: suppress.CaseDifference, + ValidateFunc: validation.StringInSlice([]string{ + string(documentdb.Consistent), + string(documentdb.Lazy), + string(documentdb.None), + }, false), + }, + + "included_paths": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringIsNotEmpty, + }, + Set: schema.HashString, + }, + + "excluded_paths": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringIsNotEmpty, + }, + Set: schema.HashString, + }, + }, + }, + }, + + "conflict_resolution_policy": { + Type: schema.TypeList, + Required: true, + ForceNew: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "mode": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(documentdb.LastWriterWins), + string(documentdb.Custom), + }, false), + }, + + "conflict_resolution_path": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "conflict_resolution_procedure": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + }, + }, + }, + + "unique_key": { + Type: schema.TypeSet, + Optional: true, + ForceNew: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "paths": { + Type: schema.TypeSet, + Required: true, + ForceNew: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringIsNotEmpty, + }, + }, + }, + }, + }, + }, + } +} + +func ResourceGremlinGraphStateUpgradeV0ToV1(rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + oldId := rawState["id"].(string) + newId := strings.Replace(rawState["id"].(string), "apis/gremlin/databases", "gremlinDatabases", 1) + + log.Printf("[DEBUG] Updating ID from %q to %q", oldId, newId) + + rawState["id"] = newId + + return rawState, nil +} diff --git a/azurerm/internal/services/cosmos/migration/mongo_collection.go b/azurerm/internal/services/cosmos/migration/mongo_collection.go new file mode 100644 index 000000000000..e2e381a3b881 --- /dev/null +++ b/azurerm/internal/services/cosmos/migration/mongo_collection.go @@ -0,0 +1,71 @@ +package migration + +import ( + "log" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" +) + +func ResourceMongoDbCollectionUpgradeV0Schema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.CosmosEntityName, + }, + + "resource_group_name": azure.SchemaResourceGroupName(), + + "account_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.CosmosAccountName, + }, + + "database_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.CosmosEntityName, + }, + + "shard_key": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "default_ttl_seconds": { + Type: schema.TypeInt, + Optional: true, + ValidateFunc: validation.IntAtLeast(-1), + }, + + "throughput": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + ValidateFunc: validate.CosmosThroughput, + }, + }, + } +} + +func ResourceMongoDbCollectionStateUpgradeV0ToV1(rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + oldId := rawState["id"].(string) + newId := strings.Replace(rawState["id"].(string), "apis/mongodb/databases", "mongodbDatabases", 1) + + log.Printf("[DEBUG] Updating ID from %q to %q", oldId, newId) + + rawState["id"] = newId + + return rawState, nil +} diff --git a/azurerm/internal/services/cosmos/migration/mongo_database.go b/azurerm/internal/services/cosmos/migration/mongo_database.go new file mode 100644 index 000000000000..8ec3f61bbb00 --- /dev/null +++ b/azurerm/internal/services/cosmos/migration/mongo_database.go @@ -0,0 +1,50 @@ +package migration + +import ( + "log" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" +) + +func ResourceMongoDbDatabaseUpgradeV0Schema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.CosmosEntityName, + }, + + "resource_group_name": azure.SchemaResourceGroupName(), + + "account_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.CosmosAccountName, + }, + + "throughput": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + ValidateFunc: validate.CosmosThroughput, + }, + }, + } +} + +func ResourceMongoDbDatabaseStateUpgradeV0ToV1(rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + oldId := rawState["id"].(string) + newId := strings.Replace(rawState["id"].(string), "apis/mongodb/databases", "mongodbDatabases", 1) + + log.Printf("[DEBUG] Updating ID from %q to %q", oldId, newId) + + rawState["id"] = newId + + return rawState, nil +} diff --git a/azurerm/internal/services/cosmos/migration/sql_container.go b/azurerm/internal/services/cosmos/migration/sql_container.go new file mode 100644 index 000000000000..88ec9605a05b --- /dev/null +++ b/azurerm/internal/services/cosmos/migration/sql_container.go @@ -0,0 +1,91 @@ +package migration + +import ( + "log" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" +) + +func ResourceSqlContainerUpgradeV0Schema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.CosmosEntityName, + }, + + "resource_group_name": azure.SchemaResourceGroupName(), + + "account_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.CosmosAccountName, + }, + + "database_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.CosmosEntityName, + }, + + "partition_key_path": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "throughput": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + ValidateFunc: validate.CosmosThroughput, + }, + + "default_ttl": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + ValidateFunc: validation.IntAtLeast(-1), + }, + + "unique_key": { + Type: schema.TypeSet, + Optional: true, + ForceNew: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "paths": { + Type: schema.TypeSet, + Required: true, + ForceNew: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringIsNotEmpty, + }, + }, + }, + }, + }, + }, + } +} + +func ResourceSqlContainerStateUpgradeV0ToV1(rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + oldId := rawState["id"].(string) + newId := strings.Replace(rawState["id"].(string), "apis/sql/databases", "sqlDatabases", 1) + + log.Printf("[DEBUG] Updating ID from %q to %q", oldId, newId) + + rawState["id"] = newId + + return rawState, nil +} diff --git a/azurerm/internal/services/cosmos/migration/sql_database.go b/azurerm/internal/services/cosmos/migration/sql_database.go new file mode 100644 index 000000000000..a7bd14dd502e --- /dev/null +++ b/azurerm/internal/services/cosmos/migration/sql_database.go @@ -0,0 +1,50 @@ +package migration + +import ( + "log" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" +) + +func ResourceSqlDatabaseUpgradeV0Schema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.CosmosEntityName, + }, + + "resource_group_name": azure.SchemaResourceGroupName(), + + "account_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.CosmosAccountName, + }, + + "throughput": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + ValidateFunc: validate.CosmosThroughput, + }, + }, + } +} + +func ResourceSqlDatabaseStateUpgradeV0ToV1(rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + oldId := rawState["id"].(string) + newId := strings.Replace(rawState["id"].(string), "apis/sql/databases", "sqlDatabases", 1) + + log.Printf("[DEBUG] Updating ID from %q to %q", oldId, newId) + + rawState["id"] = newId + + return rawState, nil +} diff --git a/azurerm/internal/services/cosmos/migration/table.go b/azurerm/internal/services/cosmos/migration/table.go new file mode 100644 index 000000000000..45f19f2efa8f --- /dev/null +++ b/azurerm/internal/services/cosmos/migration/table.go @@ -0,0 +1,50 @@ +package migration + +import ( + "log" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" +) + +func ResourceTableUpgradeV0Schema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.CosmosEntityName, + }, + + "resource_group_name": azure.SchemaResourceGroupName(), + + "account_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.CosmosAccountName, + }, + + "throughput": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + ValidateFunc: validate.CosmosThroughput, + }, + }, + } +} + +func ResourceTableStateUpgradeV0ToV1(rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + oldId := rawState["id"].(string) + newId := strings.Replace(rawState["id"].(string), "apis/table/tables", "tables", 1) + + log.Printf("[DEBUG] Updating ID from %q to %q", oldId, newId) + + rawState["id"] = newId + + return rawState, nil +} diff --git a/azurerm/internal/services/cosmos/parse/account.go b/azurerm/internal/services/cosmos/parse/account.go new file mode 100644 index 000000000000..24ac8a59a284 --- /dev/null +++ b/azurerm/internal/services/cosmos/parse/account.go @@ -0,0 +1,29 @@ +package parse + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" +) + +type DatabaseAccountId struct { + ResourceGroup string + Name string +} + +func DatabaseAccountID(input string) (*DatabaseAccountId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, fmt.Errorf("[ERROR] Unable to parse Account ID %q: %+v", input, err) + } + + databaseAccount := DatabaseAccountId{ + ResourceGroup: id.ResourceGroup, + } + + if databaseAccount.Name, err = id.PopSegment("databaseAccounts"); err != nil { + return nil, err + } + + return &databaseAccount, nil +} diff --git a/azurerm/internal/services/cosmos/parse/account_test.go b/azurerm/internal/services/cosmos/parse/account_test.go new file mode 100644 index 000000000000..ed97a554849a --- /dev/null +++ b/azurerm/internal/services/cosmos/parse/account_test.go @@ -0,0 +1,75 @@ +package parse + +import ( + "testing" +) + +func TestDatabaseAccountID(t *testing.T) { + testData := []struct { + Name string + Input string + Error bool + Expect *DatabaseAccountId + }{ + { + Name: "Empty", + Input: "", + Error: true, + }, + { + Name: "No Resource Groups Segment", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000", + Error: true, + }, + { + Name: "No Resource Groups Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", + Error: true, + }, + { + Name: "Resource Group ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", + Error: true, + }, + { + Name: "Missing Database Account Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", + Error: true, + }, + { + Name: "Account ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1", + Error: false, + Expect: &DatabaseAccountId{ + ResourceGroup: "resGroup1", + Name: "acc1", + }, + }, + { + Name: "Wrong Casing", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/DatabaseAccounts/acc1/", + Error: true, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Name) + + actual, err := DatabaseAccountID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expected a value but got an error: %s", err) + } + + if actual.Name != v.Expect.Name { + t.Fatalf("Expected %q but got %q for Name", v.Expect.Name, actual.Name) + } + + if actual.ResourceGroup != v.Expect.ResourceGroup { + t.Fatalf("Expected %q but got %q for Resource Group", v.Expect.ResourceGroup, actual.ResourceGroup) + } + } +} diff --git a/azurerm/internal/services/cosmos/parse/cassandra_keyspace.go b/azurerm/internal/services/cosmos/parse/cassandra_keyspace.go new file mode 100644 index 000000000000..5c11689bd712 --- /dev/null +++ b/azurerm/internal/services/cosmos/parse/cassandra_keyspace.go @@ -0,0 +1,34 @@ +package parse + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" +) + +type CassandraKeyspaceId struct { + ResourceGroup string + Account string + Name string +} + +func CassandraKeyspaceID(input string) (*CassandraKeyspaceId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, fmt.Errorf("[ERROR] Unable to parse Cassandra Keyspace ID %q: %+v", input, err) + } + + cassandraKeyspace := CassandraKeyspaceId{ + ResourceGroup: id.ResourceGroup, + } + + if cassandraKeyspace.Account, err = id.PopSegment("databaseAccounts"); err != nil { + return nil, err + } + + if cassandraKeyspace.Name, err = id.PopSegment("cassandraKeyspaces"); err != nil { + return nil, err + } + + return &cassandraKeyspace, nil +} diff --git a/azurerm/internal/services/cosmos/parse/cassandra_keyspace_test.go b/azurerm/internal/services/cosmos/parse/cassandra_keyspace_test.go new file mode 100644 index 000000000000..36f1dba8a5f2 --- /dev/null +++ b/azurerm/internal/services/cosmos/parse/cassandra_keyspace_test.go @@ -0,0 +1,85 @@ +package parse + +import ( + "testing" +) + +func TestCassandraKeyspaceID(t *testing.T) { + testData := []struct { + Name string + Input string + Error bool + Expect *CassandraKeyspaceId + }{ + { + Name: "Empty", + Input: "", + Error: true, + }, + { + Name: "No Resource Groups Segment", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000", + Error: true, + }, + { + Name: "No Resource Groups Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", + Error: true, + }, + { + Name: "Resource Group ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", + Error: true, + }, + { + Name: "Missing Database Account Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", + Error: true, + }, + { + Name: "Missing Keyspace Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/cassandraKeyspaces/", + Error: true, + }, + { + Name: "Keyspace ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/cassandraKeyspaces/keyspace1", + Error: false, + Expect: &CassandraKeyspaceId{ + ResourceGroup: "resGroup1", + Account: "acc1", + Name: "keyspace1", + }, + }, + { + Name: "Wrong Casing", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/CassandraKeyspaces/keyspace1", + Error: true, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Name) + + actual, err := CassandraKeyspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expected a value but got an error: %s", err) + } + + if actual.Name != v.Expect.Name { + t.Fatalf("Expected %q but got %q for Name", v.Expect.Name, actual.Name) + } + + if actual.Account != v.Expect.Account { + t.Fatalf("Expected %q but got %q for Account", v.Expect.Account, actual.Account) + } + + if actual.ResourceGroup != v.Expect.ResourceGroup { + t.Fatalf("Expected %q but got %q for Resource Group", v.Expect.ResourceGroup, actual.ResourceGroup) + } + } +} diff --git a/azurerm/internal/services/cosmos/parse/gremlin_database.go b/azurerm/internal/services/cosmos/parse/gremlin_database.go new file mode 100644 index 000000000000..843510a7c7bd --- /dev/null +++ b/azurerm/internal/services/cosmos/parse/gremlin_database.go @@ -0,0 +1,34 @@ +package parse + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" +) + +type GremlinDatabaseId struct { + ResourceGroup string + Account string + Name string +} + +func GremlinDatabaseID(input string) (*GremlinDatabaseId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, fmt.Errorf("[ERROR] Unable to parse Gremlin Database ID %q: %+v", input, err) + } + + gremlinDatabase := GremlinDatabaseId{ + ResourceGroup: id.ResourceGroup, + } + + if gremlinDatabase.Account, err = id.PopSegment("databaseAccounts"); err != nil { + return nil, err + } + + if gremlinDatabase.Name, err = id.PopSegment("gremlinDatabases"); err != nil { + return nil, err + } + + return &gremlinDatabase, nil +} diff --git a/azurerm/internal/services/cosmos/parse/gremlin_database_test.go b/azurerm/internal/services/cosmos/parse/gremlin_database_test.go new file mode 100644 index 000000000000..779ee7945b22 --- /dev/null +++ b/azurerm/internal/services/cosmos/parse/gremlin_database_test.go @@ -0,0 +1,85 @@ +package parse + +import ( + "testing" +) + +func TestGremlinDatabaseID(t *testing.T) { + testData := []struct { + Name string + Input string + Error bool + Expect *GremlinDatabaseId + }{ + { + Name: "Empty", + Input: "", + Error: true, + }, + { + Name: "No Resource Groups Segment", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000", + Error: true, + }, + { + Name: "No Resource Groups Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", + Error: true, + }, + { + Name: "Resource Group ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", + Error: true, + }, + { + Name: "Missing Database Account Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", + Error: true, + }, + { + Name: "Missing Gremlin Database Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/gremlinDatabases/", + Error: true, + }, + { + Name: "Gremlin Database ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/gremlinDatabases/database1", + Error: false, + Expect: &GremlinDatabaseId{ + ResourceGroup: "resGroup1", + Account: "acc1", + Name: "database1", + }, + }, + { + Name: "Wrong Casing", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/GremlinDatabases/database1", + Error: true, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Name) + + actual, err := GremlinDatabaseID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expected a value but got an error: %s", err) + } + + if actual.Name != v.Expect.Name { + t.Fatalf("Expected %q but got %q for Name", v.Expect.Name, actual.Name) + } + + if actual.Account != v.Expect.Account { + t.Fatalf("Expected %q but got %q for Account", v.Expect.Account, actual.Account) + } + + if actual.ResourceGroup != v.Expect.ResourceGroup { + t.Fatalf("Expected %q but got %q for Resource Group", v.Expect.ResourceGroup, actual.ResourceGroup) + } + } +} diff --git a/azurerm/internal/services/cosmos/parse/gremlin_graph.go b/azurerm/internal/services/cosmos/parse/gremlin_graph.go new file mode 100644 index 000000000000..88c78982634e --- /dev/null +++ b/azurerm/internal/services/cosmos/parse/gremlin_graph.go @@ -0,0 +1,39 @@ +package parse + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" +) + +type GremlinGraphId struct { + ResourceGroup string + Account string + Database string + Name string +} + +func GremlinGraphID(input string) (*GremlinGraphId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, fmt.Errorf("[ERROR] Unable to parse Gremlin Graph ID %q: %+v", input, err) + } + + gremlinGraph := GremlinGraphId{ + ResourceGroup: id.ResourceGroup, + } + + if gremlinGraph.Account, err = id.PopSegment("databaseAccounts"); err != nil { + return nil, err + } + + if gremlinGraph.Database, err = id.PopSegment("gremlinDatabases"); err != nil { + return nil, err + } + + if gremlinGraph.Name, err = id.PopSegment("graphs"); err != nil { + return nil, err + } + + return &gremlinGraph, nil +} diff --git a/azurerm/internal/services/cosmos/parse/gremlin_graph_test.go b/azurerm/internal/services/cosmos/parse/gremlin_graph_test.go new file mode 100644 index 000000000000..24fb3fc360fe --- /dev/null +++ b/azurerm/internal/services/cosmos/parse/gremlin_graph_test.go @@ -0,0 +1,95 @@ +package parse + +import ( + "testing" +) + +func TestGremlinGraphID(t *testing.T) { + testData := []struct { + Name string + Input string + Error bool + Expect *GremlinGraphId + }{ + { + Name: "Empty", + Input: "", + Error: true, + }, + { + Name: "No Resource Groups Segment", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000", + Error: true, + }, + { + Name: "No Resource Groups Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", + Error: true, + }, + { + Name: "Resource Group ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", + Error: true, + }, + { + Name: "Missing Database Account Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", + Error: true, + }, + { + Name: "Missing Gremlin Database Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/gremlinDatabases/", + Error: true, + }, + { + Name: "Missing Gremlin Graph Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/gremlinDatabases/graphs", + Error: true, + }, + { + Name: "Gremlin Graph ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/gremlinDatabases/database1/graphs/graph1", + Error: false, + Expect: &GremlinGraphId{ + ResourceGroup: "resGroup1", + Account: "acc1", + Database: "database1", + Name: "graph1", + }, + }, + { + Name: "Wrong Casing", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/gremlinDatabases/database1/Graphs/graph1", + Error: true, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Name) + + actual, err := GremlinGraphID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expected a value but got an error: %s", err) + } + + if actual.Name != v.Expect.Name { + t.Fatalf("Expected %q but got %q for Name", v.Expect.Name, actual.Name) + } + + if actual.Database != v.Expect.Database { + t.Fatalf("Expected %q but got %q for Database", v.Expect.Database, actual.Database) + } + + if actual.Account != v.Expect.Account { + t.Fatalf("Expected %q but got %q for Account", v.Expect.Account, actual.Account) + } + + if actual.ResourceGroup != v.Expect.ResourceGroup { + t.Fatalf("Expected %q but got %q for Resource Group", v.Expect.ResourceGroup, actual.ResourceGroup) + } + } +} diff --git a/azurerm/internal/services/cosmos/parse/mongo_collection.go b/azurerm/internal/services/cosmos/parse/mongo_collection.go new file mode 100644 index 000000000000..03e5b5b8c403 --- /dev/null +++ b/azurerm/internal/services/cosmos/parse/mongo_collection.go @@ -0,0 +1,39 @@ +package parse + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" +) + +type MongoDbCollectionId struct { + ResourceGroup string + Account string + Database string + Name string +} + +func MongoDbCollectionID(input string) (*MongoDbCollectionId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, fmt.Errorf("[ERROR] Unable to parse MongoDb Collection ID %q: %+v", input, err) + } + + mongodbCollection := MongoDbCollectionId{ + ResourceGroup: id.ResourceGroup, + } + + if mongodbCollection.Account, err = id.PopSegment("databaseAccounts"); err != nil { + return nil, err + } + + if mongodbCollection.Database, err = id.PopSegment("mongodbDatabases"); err != nil { + return nil, err + } + + if mongodbCollection.Name, err = id.PopSegment("collections"); err != nil { + return nil, err + } + + return &mongodbCollection, nil +} diff --git a/azurerm/internal/services/cosmos/parse/mongo_collection_test.go b/azurerm/internal/services/cosmos/parse/mongo_collection_test.go new file mode 100644 index 000000000000..d794009b988d --- /dev/null +++ b/azurerm/internal/services/cosmos/parse/mongo_collection_test.go @@ -0,0 +1,95 @@ +package parse + +import ( + "testing" +) + +func TestMongoDbCollectionId(t *testing.T) { + testData := []struct { + Name string + Input string + Error bool + Expect *MongoDbCollectionId + }{ + { + Name: "Empty", + Input: "", + Error: true, + }, + { + Name: "No Resource Groups Segment", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000", + Error: true, + }, + { + Name: "No Resource Groups Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", + Error: true, + }, + { + Name: "Resource Group ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", + Error: true, + }, + { + Name: "Missing Database Account Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", + Error: true, + }, + { + Name: "Missing MongoDB Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/mongodbDatabases/", + Error: true, + }, + { + Name: "Missing Collection Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/mongodbDatabases/db1/collections/", + Error: true, + }, + { + Name: "MongoDB Collection ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/mongodbDatabases/db1/collections/coll1", + Error: false, + Expect: &MongoDbCollectionId{ + ResourceGroup: "resGroup1", + Account: "acc1", + Database: "db1", + Name: "coll1", + }, + }, + { + Name: "Wrong Casing", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/MongodbDatabases/db1/Collections/coll1", + Error: true, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Name) + + actual, err := MongoDbCollectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expected a value but got an error: %s", err) + } + + if actual.Name != v.Expect.Name { + t.Fatalf("Expected %q but got %q for Name", v.Expect.Name, actual.Name) + } + + if actual.Database != v.Expect.Database { + t.Fatalf("Expected %q but got %q for Database", v.Expect.Database, actual.Database) + } + + if actual.Account != v.Expect.Account { + t.Fatalf("Expected %q but got %q for Account", v.Expect.Account, actual.Account) + } + + if actual.ResourceGroup != v.Expect.ResourceGroup { + t.Fatalf("Expected %q but got %q for Resource Group", v.Expect.ResourceGroup, actual.ResourceGroup) + } + } +} diff --git a/azurerm/internal/services/cosmos/parse/mongo_database.go b/azurerm/internal/services/cosmos/parse/mongo_database.go new file mode 100644 index 000000000000..b046f935b526 --- /dev/null +++ b/azurerm/internal/services/cosmos/parse/mongo_database.go @@ -0,0 +1,34 @@ +package parse + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" +) + +type MongoDbDatabaseId struct { + ResourceGroup string + Account string + Name string +} + +func MongoDbDatabaseID(input string) (*MongoDbDatabaseId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, fmt.Errorf("[ERROR] Unable to parse MongoDb Database ID %q: %+v", input, err) + } + + mongodbDatabase := MongoDbDatabaseId{ + ResourceGroup: id.ResourceGroup, + } + + if mongodbDatabase.Account, err = id.PopSegment("databaseAccounts"); err != nil { + return nil, err + } + + if mongodbDatabase.Name, err = id.PopSegment("mongodbDatabases"); err != nil { + return nil, err + } + + return &mongodbDatabase, nil +} diff --git a/azurerm/internal/services/cosmos/parse/mongo_database_test.go b/azurerm/internal/services/cosmos/parse/mongo_database_test.go new file mode 100644 index 000000000000..51807008ce9d --- /dev/null +++ b/azurerm/internal/services/cosmos/parse/mongo_database_test.go @@ -0,0 +1,85 @@ +package parse + +import ( + "testing" +) + +func TestMongoDbDatabaseID(t *testing.T) { + testData := []struct { + Name string + Input string + Error bool + Expect *MongoDbDatabaseId + }{ + { + Name: "Empty", + Input: "", + Error: true, + }, + { + Name: "No Resource Groups Segment", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000", + Error: true, + }, + { + Name: "No Resource Groups Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", + Error: true, + }, + { + Name: "Resource Group ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", + Error: true, + }, + { + Name: "Missing Database Account Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", + Error: true, + }, + { + Name: "Missing MongoDB Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/mongodbDatabases/", + Error: true, + }, + { + Name: "MongoDB Database ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/mongodbDatabases/db1", + Error: false, + Expect: &MongoDbDatabaseId{ + ResourceGroup: "resGroup1", + Account: "acc1", + Name: "db1", + }, + }, + { + Name: "Wrong Casing", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/MongodbDatabases/db1", + Error: true, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Name) + + actual, err := MongoDbDatabaseID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expected a value but got an error: %s", err) + } + + if actual.Name != v.Expect.Name { + t.Fatalf("Expected %q but got %q for Name", v.Expect.Name, actual.Name) + } + + if actual.Account != v.Expect.Account { + t.Fatalf("Expected %q but got %q for Account", v.Expect.Account, actual.Account) + } + + if actual.ResourceGroup != v.Expect.ResourceGroup { + t.Fatalf("Expected %q but got %q for Resource Group", v.Expect.ResourceGroup, actual.ResourceGroup) + } + } +} diff --git a/azurerm/internal/services/cosmos/parse/sql_container.go b/azurerm/internal/services/cosmos/parse/sql_container.go new file mode 100644 index 000000000000..aa353e37582c --- /dev/null +++ b/azurerm/internal/services/cosmos/parse/sql_container.go @@ -0,0 +1,39 @@ +package parse + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" +) + +type SqlContainerId struct { + ResourceGroup string + Account string + Database string + Name string +} + +func SqlContainerID(input string) (*SqlContainerId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, fmt.Errorf("[ERROR] Unable to parse SQL Container ID %q: %+v", input, err) + } + + sqlContainer := SqlContainerId{ + ResourceGroup: id.ResourceGroup, + } + + if sqlContainer.Account, err = id.PopSegment("databaseAccounts"); err != nil { + return nil, err + } + + if sqlContainer.Database, err = id.PopSegment("sqlDatabases"); err != nil { + return nil, err + } + + if sqlContainer.Name, err = id.PopSegment("containers"); err != nil { + return nil, err + } + + return &sqlContainer, nil +} diff --git a/azurerm/internal/services/cosmos/parse/sql_container_test.go b/azurerm/internal/services/cosmos/parse/sql_container_test.go new file mode 100644 index 000000000000..958b64cfbb52 --- /dev/null +++ b/azurerm/internal/services/cosmos/parse/sql_container_test.go @@ -0,0 +1,95 @@ +package parse + +import ( + "testing" +) + +func TestSqlContainerID(t *testing.T) { + testData := []struct { + Name string + Input string + Error bool + Expect *SqlContainerId + }{ + { + Name: "Empty", + Input: "", + Error: true, + }, + { + Name: "No Resource Groups Segment", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000", + Error: true, + }, + { + Name: "No Resource Groups Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", + Error: true, + }, + { + Name: "Resource Group ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", + Error: true, + }, + { + Name: "Missing Database Account Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", + Error: true, + }, + { + Name: "Missing SQL Database Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/", + Error: true, + }, + { + Name: "Missing SQL Container Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1/containers/", + Error: true, + }, + { + Name: "SQL Container ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1/containers/container1", + Error: false, + Expect: &SqlContainerId{ + ResourceGroup: "resGroup1", + Account: "acc1", + Database: "db1", + Name: "container1", + }, + }, + { + Name: "Wrong Casing", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1/Containers/container1", + Error: true, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Name) + + actual, err := SqlContainerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expected a value but got an error: %s", err) + } + + if actual.Name != v.Expect.Name { + t.Fatalf("Expected %q but got %q for Name", v.Expect.Name, actual.Name) + } + + if actual.Database != v.Expect.Database { + t.Fatalf("Expected %q but got %q for Database", v.Expect.Database, actual.Database) + } + + if actual.Account != v.Expect.Account { + t.Fatalf("Expected %q but got %q for Account", v.Expect.Account, actual.Account) + } + + if actual.ResourceGroup != v.Expect.ResourceGroup { + t.Fatalf("Expected %q but got %q for Resource Group", v.Expect.ResourceGroup, actual.ResourceGroup) + } + } +} diff --git a/azurerm/internal/services/cosmos/parse/sql_database.go b/azurerm/internal/services/cosmos/parse/sql_database.go new file mode 100644 index 000000000000..8fa75b5e6fce --- /dev/null +++ b/azurerm/internal/services/cosmos/parse/sql_database.go @@ -0,0 +1,34 @@ +package parse + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" +) + +type SqlDatabaseId struct { + ResourceGroup string + Account string + Name string +} + +func SqlDatabaseID(input string) (*SqlDatabaseId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, fmt.Errorf("[ERROR] Unable to parse SQL Database ID %q: %+v", input, err) + } + + sqlDatabase := SqlDatabaseId{ + ResourceGroup: id.ResourceGroup, + } + + if sqlDatabase.Account, err = id.PopSegment("databaseAccounts"); err != nil { + return nil, err + } + + if sqlDatabase.Name, err = id.PopSegment("sqlDatabases"); err != nil { + return nil, err + } + + return &sqlDatabase, nil +} diff --git a/azurerm/internal/services/cosmos/parse/sql_database_test.go b/azurerm/internal/services/cosmos/parse/sql_database_test.go new file mode 100644 index 000000000000..808d63b0a1df --- /dev/null +++ b/azurerm/internal/services/cosmos/parse/sql_database_test.go @@ -0,0 +1,85 @@ +package parse + +import ( + "testing" +) + +func TestSqlDatabaseID(t *testing.T) { + testData := []struct { + Name string + Input string + Error bool + Expect *SqlDatabaseId + }{ + { + Name: "Empty", + Input: "", + Error: true, + }, + { + Name: "No Resource Groups Segment", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000", + Error: true, + }, + { + Name: "No Resource Groups Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", + Error: true, + }, + { + Name: "Resource Group ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", + Error: true, + }, + { + Name: "Missing Database Account Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", + Error: true, + }, + { + Name: "Missing SQL Database Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/", + Error: true, + }, + { + Name: "SQL Database ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/sqlDatabases/db1", + Error: false, + Expect: &SqlDatabaseId{ + ResourceGroup: "resGroup1", + Account: "acc1", + Name: "db1", + }, + }, + { + Name: "Wrong Casing", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/SqlDatabases/db1", + Error: true, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Name) + + actual, err := SqlDatabaseID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expected a value but got an error: %s", err) + } + + if actual.Name != v.Expect.Name { + t.Fatalf("Expected %q but got %q for Name", v.Expect.Name, actual.Name) + } + + if actual.Account != v.Expect.Account { + t.Fatalf("Expected %q but got %q for Account", v.Expect.Account, actual.Account) + } + + if actual.ResourceGroup != v.Expect.ResourceGroup { + t.Fatalf("Expected %q but got %q for Resource Group", v.Expect.ResourceGroup, actual.ResourceGroup) + } + } +} diff --git a/azurerm/internal/services/cosmos/parse/table.go b/azurerm/internal/services/cosmos/parse/table.go new file mode 100644 index 000000000000..c58e728b3740 --- /dev/null +++ b/azurerm/internal/services/cosmos/parse/table.go @@ -0,0 +1,34 @@ +package parse + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" +) + +type TableId struct { + ResourceGroup string + Account string + Name string +} + +func TableID(input string) (*TableId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, fmt.Errorf("[ERROR] Unable to parse Table ID %q: %+v", input, err) + } + + table := TableId{ + ResourceGroup: id.ResourceGroup, + } + + if table.Account, err = id.PopSegment("databaseAccounts"); err != nil { + return nil, err + } + + if table.Name, err = id.PopSegment("tables"); err != nil { + return nil, err + } + + return &table, nil +} diff --git a/azurerm/internal/services/cosmos/parse/table_test.go b/azurerm/internal/services/cosmos/parse/table_test.go new file mode 100644 index 000000000000..443057be11b2 --- /dev/null +++ b/azurerm/internal/services/cosmos/parse/table_test.go @@ -0,0 +1,95 @@ +package parse + +import ( + "testing" +) + +func TestTableID(t *testing.T) { + testData := []struct { + Name string + Input string + Error bool + Expect *TableId + }{ + { + Name: "Empty", + Input: "", + Error: true, + }, + { + Name: "No Resource Groups Segment", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000", + Error: true, + }, + { + Name: "No Resource Groups Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", + Error: true, + }, + { + Name: "Resource Group ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", + Error: true, + }, + { + Name: "Missing Database Account Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/", + Error: true, + }, + { + Name: "Missing Table Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/tables/", + Error: true, + }, + { + Name: "Table ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/tables/table1", + Error: false, + Expect: &TableId{ + ResourceGroup: "resGroup1", + Account: "acc1", + Name: "table1", + }, + }, + { + Name: "Existing 2015-04-08 SDK Table ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/apis/table/tables/table1", + Error: false, + Expect: &TableId{ + ResourceGroup: "resGroup1", + Account: "acc1", + Name: "table1", + }, + }, + { + Name: "Wrong Casing", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.DocumentDB/databaseAccounts/acc1/Tables/table1", + Error: true, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Name) + + actual, err := TableID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expected a value but got an error: %s", err) + } + + if actual.Name != v.Expect.Name { + t.Fatalf("Expected %q but got %q for Name", v.Expect.Name, actual.Name) + } + + if actual.Account != v.Expect.Account { + t.Fatalf("Expected %q but got %q for Account", v.Expect.Account, actual.Account) + } + + if actual.ResourceGroup != v.Expect.ResourceGroup { + t.Fatalf("Expected %q but got %q for Resource Group", v.Expect.ResourceGroup, actual.ResourceGroup) + } + } +} diff --git a/azurerm/internal/services/cosmos/tests/cosmos_db_account_data_source_test.go b/azurerm/internal/services/cosmos/tests/cosmos_db_account_data_source_test.go index 4260b2905ec7..7462204d5062 100644 --- a/azurerm/internal/services/cosmos/tests/cosmos_db_account_data_source_test.go +++ b/azurerm/internal/services/cosmos/tests/cosmos_db_account_data_source_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb" + "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" ) @@ -38,11 +38,13 @@ func TestAccDataSourceAzureRMCosmosDBAccount_complete(t *testing.T) { { Config: testAccDataSourceAzureRMCosmosDBAccount_complete(data), Check: resource.ComposeAggregateTestCheckFunc( - checkAccAzureRMCosmosDBAccount_basic(data, documentdb.BoundedStaleness, 2), + checkAccAzureRMCosmosDBAccount_basic(data, documentdb.BoundedStaleness, 3), resource.TestCheckResourceAttr(data.ResourceName, "geo_location.0.location", data.Locations.Primary), resource.TestCheckResourceAttr(data.ResourceName, "geo_location.1.location", data.Locations.Secondary), + resource.TestCheckResourceAttr(data.ResourceName, "geo_location.2.location", data.Locations.Ternary), resource.TestCheckResourceAttr(data.ResourceName, "geo_location.0.failover_priority", "0"), resource.TestCheckResourceAttr(data.ResourceName, "geo_location.1.failover_priority", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "geo_location.2.failover_priority", "2"), ), }, }, diff --git a/azurerm/internal/services/cosmos/tests/cosmosdb_account_resource_test.go b/azurerm/internal/services/cosmos/tests/cosmosdb_account_resource_test.go index 69de434222e0..d650de59de72 100644 --- a/azurerm/internal/services/cosmos/tests/cosmosdb_account_resource_test.go +++ b/azurerm/internal/services/cosmos/tests/cosmosdb_account_resource_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb" + "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" @@ -137,18 +137,23 @@ func testAccAzureRMCosmosDBAccount_updateConsistency(t *testing.T, kind document }, data.ImportStep(), { - Config: testAccAzureRMCosmosDBAccount_basic(data, kind, documentdb.Eventual), - Check: checkAccAzureRMCosmosDBAccount_basic(data, documentdb.Eventual, 1), + Config: testAccAzureRMCosmosDBAccount_consistency(data, kind, documentdb.Strong, 8, 880), + Check: checkAccAzureRMCosmosDBAccount_basic(data, documentdb.Strong, 1), + }, + data.ImportStep(), + { + Config: testAccAzureRMCosmosDBAccount_basic(data, kind, documentdb.BoundedStaleness), + Check: checkAccAzureRMCosmosDBAccount_basic(data, documentdb.BoundedStaleness, 1), }, data.ImportStep(), { - Config: testAccAzureRMCosmosDBAccount_consistency(data, kind, documentdb.Eventual, 7, 770), - Check: checkAccAzureRMCosmosDBAccount_basic(data, documentdb.Eventual, 1), + Config: testAccAzureRMCosmosDBAccount_consistency(data, kind, documentdb.BoundedStaleness, 7, 770), + Check: checkAccAzureRMCosmosDBAccount_basic(data, documentdb.BoundedStaleness, 1), }, data.ImportStep(), { - Config: testAccAzureRMCosmosDBAccount_consistency(data, kind, documentdb.Eventual, 77, 700), - Check: checkAccAzureRMCosmosDBAccount_basic(data, documentdb.Eventual, 1), + Config: testAccAzureRMCosmosDBAccount_consistency(data, kind, documentdb.BoundedStaleness, 77, 700), + Check: checkAccAzureRMCosmosDBAccount_basic(data, documentdb.BoundedStaleness, 1), }, data.ImportStep(), { @@ -489,12 +494,12 @@ resource "azurerm_cosmosdb_account" "import" { offer_type = azurerm_cosmosdb_account.test.offer_type consistency_policy { - consistency_level = azurerm_cosmosdb_account.consistency_policy[0].consistency_level + consistency_level = azurerm_cosmosdb_account.test.consistency_policy[0].consistency_level } geo_location { - location = azurerm_cosmosdb_account.geo_location[0].location - failover_priority = azurerm_cosmosdb_account.geo_location[0].location + location = azurerm_resource_group.test.location + failover_priority = 0 } } `, testAccAzureRMCosmosDBAccount_basic(data, "GlobalDocumentDB", consistency)) @@ -604,7 +609,6 @@ resource "azurerm_cosmosdb_account" "test" { } geo_location { - prefix = "acctest-%[2]d-custom-id" location = "%[5]s" failover_priority = 1 } @@ -629,8 +633,9 @@ resource "azurerm_cosmosdb_account" "test" { kind = "%[3]s" consistency_policy { - consistency_level = "%[4]s" - max_staleness_prefix = 170000 + consistency_level = "%[4]s" + max_interval_in_seconds = 360 + max_staleness_prefix = 170000 } is_virtual_network_filter_enabled = true @@ -647,13 +652,11 @@ resource "azurerm_cosmosdb_account" "test" { } geo_location { - prefix = "acctest-%[2]d-custom-id-updated" location = "%[5]s" failover_priority = 1 } geo_location { - prefix = "acctest-%[2]d-custom-id-added" location = "%[6]s" failover_priority = 2 } diff --git a/azurerm/internal/services/cosmos/tests/cosmosdb_cassandra_keyspace_resource_test.go b/azurerm/internal/services/cosmos/tests/cosmosdb_cassandra_keyspace_resource_test.go index 03fbef53b7ec..ed961ebbdc1a 100644 --- a/azurerm/internal/services/cosmos/tests/cosmosdb_cassandra_keyspace_resource_test.go +++ b/azurerm/internal/services/cosmos/tests/cosmosdb_cassandra_keyspace_resource_test.go @@ -5,7 +5,7 @@ import ( "net/http" "testing" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb" + "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" @@ -81,7 +81,7 @@ func TestAccAzureRMCosmosDbCassandraKeyspace_update(t *testing.T) { } func testCheckAzureRMCosmosDbCassandraKeyspaceDestroy(s *terraform.State) error { - client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.DatabaseClient + client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.CassandraClient ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext for _, rs := range s.RootModule().Resources { @@ -110,7 +110,7 @@ func testCheckAzureRMCosmosDbCassandraKeyspaceDestroy(s *terraform.State) error func testCheckAzureRMCosmosDbCassandraKeyspaceExists(resourceName string) resource.TestCheckFunc { return func(s *terraform.State) error { - client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.DatabaseClient + client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.CassandraClient ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext // Ensure we have enough information in state to look up in API diff --git a/azurerm/internal/services/cosmos/tests/cosmosdb_gremlin_database_resource_test.go b/azurerm/internal/services/cosmos/tests/cosmosdb_gremlin_database_resource_test.go index f2c843bf2b8c..8f8aa53c177c 100644 --- a/azurerm/internal/services/cosmos/tests/cosmosdb_gremlin_database_resource_test.go +++ b/azurerm/internal/services/cosmos/tests/cosmosdb_gremlin_database_resource_test.go @@ -5,7 +5,7 @@ import ( "net/http" "testing" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb" + "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" @@ -83,7 +83,7 @@ func TestAccAzureRMCosmosGremlinDatabase_complete(t *testing.T) { } func testCheckAzureRMCosmosGremlinDatabaseDestroy(s *terraform.State) error { - client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.DatabaseClient + client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.GremlinClient ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext for _, rs := range s.RootModule().Resources { @@ -112,7 +112,7 @@ func testCheckAzureRMCosmosGremlinDatabaseDestroy(s *terraform.State) error { func testCheckAzureRMCosmosGremlinDatabaseExists(resourceName string) resource.TestCheckFunc { return func(s *terraform.State) error { - client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.DatabaseClient + client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.GremlinClient ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext // Ensure we have enough information in state to look up in API diff --git a/azurerm/internal/services/cosmos/tests/cosmosdb_gremlin_graph_resource_test.go b/azurerm/internal/services/cosmos/tests/cosmosdb_gremlin_graph_resource_test.go index 7f7989629c1f..88e150f1eebb 100644 --- a/azurerm/internal/services/cosmos/tests/cosmosdb_gremlin_graph_resource_test.go +++ b/azurerm/internal/services/cosmos/tests/cosmosdb_gremlin_graph_resource_test.go @@ -120,7 +120,7 @@ func TestAccAzureRMCosmosDbGremlinGraph_update(t *testing.T) { } func testCheckAzureRMCosmosDbGremlinGraphDestroy(s *terraform.State) error { - client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.DatabaseClient + client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.GremlinClient ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext for _, rs := range s.RootModule().Resources { @@ -150,7 +150,7 @@ func testCheckAzureRMCosmosDbGremlinGraphDestroy(s *terraform.State) error { func testCheckAzureRmCosmosDbGremlinGraphExists(resourceName string) resource.TestCheckFunc { return func(s *terraform.State) error { - client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.DatabaseClient + client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.GremlinClient ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext // Ensure we have enough information in state to look up in API @@ -165,7 +165,7 @@ func testCheckAzureRmCosmosDbGremlinGraphExists(resourceName string) resource.Te resourceGroup := rs.Primary.Attributes["resource_group_name"] database := rs.Primary.Attributes["database_name"] - resp, err := client.GetGremlinGraph(ctx, resourceGroup, database, account, name) + resp, err := client.GetGremlinGraph(ctx, resourceGroup, account, database, name) if err != nil { return fmt.Errorf("Bad: Get on cosmosAccountsClient: %+v", err) } diff --git a/azurerm/internal/services/cosmos/tests/cosmosdb_mongo_collection_resource_test.go b/azurerm/internal/services/cosmos/tests/cosmosdb_mongo_collection_resource_test.go index 8605cc6aa0ec..81a106d94b05 100644 --- a/azurerm/internal/services/cosmos/tests/cosmosdb_mongo_collection_resource_test.go +++ b/azurerm/internal/services/cosmos/tests/cosmosdb_mongo_collection_resource_test.go @@ -144,7 +144,7 @@ func TestAccAzureRMCosmosDbMongoCollection_withIndex(t *testing.T) { } func testCheckAzureRMCosmosDbMongoCollectionDestroy(s *terraform.State) error { - client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.DatabaseClient + client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.MongoDbClient ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext for _, rs := range s.RootModule().Resources { @@ -174,7 +174,7 @@ func testCheckAzureRMCosmosDbMongoCollectionDestroy(s *terraform.State) error { func testCheckAzureRMCosmosDbMongoCollectionExists(resourceName string) resource.TestCheckFunc { return func(s *terraform.State) error { - client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.DatabaseClient + client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.MongoDbClient ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext // Ensure we have enough information in state to look up in API diff --git a/azurerm/internal/services/cosmos/tests/cosmosdb_mongo_database_resource_test.go b/azurerm/internal/services/cosmos/tests/cosmosdb_mongo_database_resource_test.go index c01c01fc9b96..d22746cf5716 100644 --- a/azurerm/internal/services/cosmos/tests/cosmosdb_mongo_database_resource_test.go +++ b/azurerm/internal/services/cosmos/tests/cosmosdb_mongo_database_resource_test.go @@ -5,7 +5,7 @@ import ( "net/http" "testing" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb" + "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" @@ -52,7 +52,7 @@ func TestAccAzureRMCosmosDbMongoDatabase_complete(t *testing.T) { } func testCheckAzureRMCosmosDbMongoDatabaseDestroy(s *terraform.State) error { - client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.DatabaseClient + client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.MongoDbClient ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext for _, rs := range s.RootModule().Resources { @@ -81,7 +81,7 @@ func testCheckAzureRMCosmosDbMongoDatabaseDestroy(s *terraform.State) error { func testCheckAzureRMCosmosDbMongoDatabaseExists(resourceName string) resource.TestCheckFunc { return func(s *terraform.State) error { - client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.DatabaseClient + client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.MongoDbClient ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext // Ensure we have enough information in state to look up in API diff --git a/azurerm/internal/services/cosmos/tests/cosmosdb_sql_container_resource_test.go b/azurerm/internal/services/cosmos/tests/cosmosdb_sql_container_resource_test.go index e7b4459653d7..e6d4aaffbb4d 100644 --- a/azurerm/internal/services/cosmos/tests/cosmosdb_sql_container_resource_test.go +++ b/azurerm/internal/services/cosmos/tests/cosmosdb_sql_container_resource_test.go @@ -85,7 +85,7 @@ func TestAccAzureRMCosmosDbSqlContainer_update(t *testing.T) { } func testCheckAzureRMCosmosDbSqlContainerDestroy(s *terraform.State) error { - client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.DatabaseClient + client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.SqlClient ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext for _, rs := range s.RootModule().Resources { @@ -115,7 +115,7 @@ func testCheckAzureRMCosmosDbSqlContainerDestroy(s *terraform.State) error { func testCheckAzureRMCosmosDbSqlContainerExists(resourceName string) resource.TestCheckFunc { return func(s *terraform.State) error { - client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.DatabaseClient + client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.SqlClient ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext // Ensure we have enough information in state to look up in API diff --git a/azurerm/internal/services/cosmos/tests/cosmosdb_sql_database_resource_test.go b/azurerm/internal/services/cosmos/tests/cosmosdb_sql_database_resource_test.go index b59fd9421b56..4d9d6e0ea3d5 100644 --- a/azurerm/internal/services/cosmos/tests/cosmosdb_sql_database_resource_test.go +++ b/azurerm/internal/services/cosmos/tests/cosmosdb_sql_database_resource_test.go @@ -5,7 +5,7 @@ import ( "net/http" "testing" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb" + "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" @@ -63,7 +63,7 @@ func TestAccAzureRMCosmosDbSqlDatabase_update(t *testing.T) { } func testCheckAzureRMCosmosDbSqlDatabaseDestroy(s *terraform.State) error { - client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.DatabaseClient + client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.SqlClient ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext for _, rs := range s.RootModule().Resources { @@ -92,7 +92,7 @@ func testCheckAzureRMCosmosDbSqlDatabaseDestroy(s *terraform.State) error { func testCheckAzureRMCosmosDbSqlDatabaseExists(resourceName string) resource.TestCheckFunc { return func(s *terraform.State) error { - client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.DatabaseClient + client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.SqlClient ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext // Ensure we have enough information in state to look up in API diff --git a/azurerm/internal/services/cosmos/tests/cosmosdb_table_resource_test.go b/azurerm/internal/services/cosmos/tests/cosmosdb_table_resource_test.go index 1bd2e3970e81..c18ff3a7095b 100644 --- a/azurerm/internal/services/cosmos/tests/cosmosdb_table_resource_test.go +++ b/azurerm/internal/services/cosmos/tests/cosmosdb_table_resource_test.go @@ -5,7 +5,7 @@ import ( "net/http" "testing" - "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb" + "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" @@ -63,7 +63,7 @@ func TestAccAzureRMCosmosDbTable_update(t *testing.T) { } func testCheckAzureRMCosmosDbTableDestroy(s *terraform.State) error { - client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.DatabaseClient + client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.TableClient ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext for _, rs := range s.RootModule().Resources { @@ -92,7 +92,7 @@ func testCheckAzureRMCosmosDbTableDestroy(s *terraform.State) error { func testCheckAzureRMCosmosDbTableExists(resourceName string) resource.TestCheckFunc { return func(s *terraform.State) error { - client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.DatabaseClient + client := acceptance.AzureProvider.Meta().(*clients.Client).Cosmos.TableClient ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext // Ensure we have enough information in state to look up in API diff --git a/go.mod b/go.mod index 7f56d8720344..a8a2757e7520 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/satori/uuid v0.0.0-20160927100844-b061729afc07 github.com/sergi/go-diff v1.1.0 github.com/terraform-providers/terraform-provider-azuread v0.9.0 - github.com/tombuildsstuff/giovanni v0.11.0 + github.com/tombuildsstuff/giovanni v0.10.0 golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 golang.org/x/net v0.0.0-20200301022130-244492dfa37a gopkg.in/yaml.v2 v2.2.4 diff --git a/go.sum b/go.sum index 9cffc10ad4e8..0879dc9203a2 100644 --- a/go.sum +++ b/go.sum @@ -238,8 +238,8 @@ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJy github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/terraform-providers/terraform-provider-azuread v0.9.0 h1:XLzFgVHakq6qjJ2L0o/tN2yHu/hT4vIW9sKtejr7gPs= github.com/terraform-providers/terraform-provider-azuread v0.9.0/go.mod h1:sSDzB/8CD639+yWo5lZf+NJvGSYQBSS6z+GoET9IrzE= -github.com/tombuildsstuff/giovanni v0.11.0 h1:Sr3jCt5EvmqTjT3UDa9yBANiBAfm4kcrtFtSZsCNSGs= -github.com/tombuildsstuff/giovanni v0.11.0/go.mod h1:pTD/ehWd8XPp4/NGTPgL7AGI4Jhb+kKcJ0RiklkoR44= +github.com/tombuildsstuff/giovanni v0.10.0 h1:XqZBPVD2hETa30FFdMz/zVfnidMnUrIMMmKIH7hWnWA= +github.com/tombuildsstuff/giovanni v0.10.0/go.mod h1:WwPhFP2+WnhJzvPYDnsyBab2wOIksMX6xm+Tg+jVvKw= github.com/tombuildsstuff/go-autorest v14.0.1-0.20200416184303-d4e299a3c04a+incompatible h1:9645FYqYopS+TFknygW7EC9PCbIC5T4WvWUpktyE2JA= github.com/tombuildsstuff/go-autorest v14.0.1-0.20200416184303-d4e299a3c04a+incompatible/go.mod h1:OVwh0+NZeL2RTqclVEX+p20Qys7Ihpd52PD0eqFDXtY= github.com/tombuildsstuff/go-autorest/autorest v0.10.1-0.20200416184303-d4e299a3c04a h1:F/4zKpn8ra3rhPMBzrVc7LYL1GB1ucl/va4I+4ubUWg= diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/databaseaccounts.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/databaseaccounts.go deleted file mode 100644 index cf1d031b070e..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/databaseaccounts.go +++ /dev/null @@ -1,6622 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// 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 azure Cosmos DB Database Service Resource Provider REST API -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 -} - -// 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 = "2015-04-08" - 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. -// Parameters: -// resourceGroupName - name of an Azure resource group. -// 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.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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}, - }}}}}); 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 = "2015-04-08" - 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 - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - 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 DatabaseAccount, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateUpdateCassandraKeyspace create or update an Azure Cosmos DB Cassandra keyspace -// Parameters: -// resourceGroupName - name of an Azure resource group. -// accountName - cosmos DB database account name. -// keyspaceName - cosmos DB keyspace name. -// createUpdateCassandraKeyspaceParameters - the parameters to provide for the current Cassandra keyspace. -func (client DatabaseAccountsClient) CreateUpdateCassandraKeyspace(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, createUpdateCassandraKeyspaceParameters CassandraKeyspaceCreateUpdateParameters) (result DatabaseAccountsCreateUpdateCassandraKeyspaceFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.CreateUpdateCassandraKeyspace") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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}}}, - {Target: "createUpdateCassandraKeyspaceParameters.CassandraKeyspaceCreateUpdateProperties.Options", Name: validation.Null, Rule: true, Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "CreateUpdateCassandraKeyspace", err.Error()) - } - - req, err := client.CreateUpdateCassandraKeyspacePreparer(ctx, resourceGroupName, accountName, keyspaceName, createUpdateCassandraKeyspaceParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateUpdateCassandraKeyspace", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateCassandraKeyspaceSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateUpdateCassandraKeyspace", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdateCassandraKeyspacePreparer prepares the CreateUpdateCassandraKeyspace request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/cassandra/keyspaces/{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 DatabaseAccountsClient) CreateUpdateCassandraKeyspaceSender(req *http.Request) (future DatabaseAccountsCreateUpdateCassandraKeyspaceFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// CreateUpdateCassandraKeyspaceResponder handles the response to the CreateUpdateCassandraKeyspace request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) CreateUpdateCassandraKeyspaceResponder(resp *http.Response) (result CassandraKeyspace, 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 - name of an Azure resource group. -// 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 DatabaseAccountsClient) CreateUpdateCassandraTable(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string, createUpdateCassandraTableParameters CassandraTableCreateUpdateParameters) (result DatabaseAccountsCreateUpdateCassandraTableFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.CreateUpdateCassandraTable") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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}}}, - {Target: "createUpdateCassandraTableParameters.CassandraTableCreateUpdateProperties.Options", Name: validation.Null, Rule: true, Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "CreateUpdateCassandraTable", err.Error()) - } - - req, err := client.CreateUpdateCassandraTablePreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName, createUpdateCassandraTableParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateUpdateCassandraTable", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateCassandraTableSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateUpdateCassandraTable", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdateCassandraTablePreparer prepares the CreateUpdateCassandraTable request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/cassandra/keyspaces/{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 DatabaseAccountsClient) CreateUpdateCassandraTableSender(req *http.Request) (future DatabaseAccountsCreateUpdateCassandraTableFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// CreateUpdateCassandraTableResponder handles the response to the CreateUpdateCassandraTable request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) CreateUpdateCassandraTableResponder(resp *http.Response) (result CassandraTable, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateUpdateGremlinDatabase create or update an Azure Cosmos DB Gremlin database -// Parameters: -// resourceGroupName - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// createUpdateGremlinDatabaseParameters - the parameters to provide for the current Gremlin database. -func (client DatabaseAccountsClient) CreateUpdateGremlinDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateGremlinDatabaseParameters GremlinDatabaseCreateUpdateParameters) (result DatabaseAccountsCreateUpdateGremlinDatabaseFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.CreateUpdateGremlinDatabase") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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}}}, - {Target: "createUpdateGremlinDatabaseParameters.GremlinDatabaseCreateUpdateProperties.Options", Name: validation.Null, Rule: true, Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "CreateUpdateGremlinDatabase", err.Error()) - } - - req, err := client.CreateUpdateGremlinDatabasePreparer(ctx, resourceGroupName, accountName, databaseName, createUpdateGremlinDatabaseParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateUpdateGremlinDatabase", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateGremlinDatabaseSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateUpdateGremlinDatabase", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdateGremlinDatabasePreparer prepares the CreateUpdateGremlinDatabase request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/gremlin/databases/{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 DatabaseAccountsClient) CreateUpdateGremlinDatabaseSender(req *http.Request) (future DatabaseAccountsCreateUpdateGremlinDatabaseFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// CreateUpdateGremlinDatabaseResponder handles the response to the CreateUpdateGremlinDatabase request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) CreateUpdateGremlinDatabaseResponder(resp *http.Response) (result GremlinDatabase, 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 - name of an Azure resource group. -// 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 DatabaseAccountsClient) CreateUpdateGremlinGraph(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string, createUpdateGremlinGraphParameters GremlinGraphCreateUpdateParameters) (result DatabaseAccountsCreateUpdateGremlinGraphFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.CreateUpdateGremlinGraph") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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.Options", Name: validation.Null, Rule: true, Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "CreateUpdateGremlinGraph", err.Error()) - } - - req, err := client.CreateUpdateGremlinGraphPreparer(ctx, resourceGroupName, accountName, databaseName, graphName, createUpdateGremlinGraphParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateUpdateGremlinGraph", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateGremlinGraphSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateUpdateGremlinGraph", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdateGremlinGraphPreparer prepares the CreateUpdateGremlinGraph request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/gremlin/databases/{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 DatabaseAccountsClient) CreateUpdateGremlinGraphSender(req *http.Request) (future DatabaseAccountsCreateUpdateGremlinGraphFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// CreateUpdateGremlinGraphResponder handles the response to the CreateUpdateGremlinGraph request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) CreateUpdateGremlinGraphResponder(resp *http.Response) (result GremlinGraph, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateUpdateMongoDBCollection create or update an Azure Cosmos DB MongoDB Collection -// Parameters: -// resourceGroupName - name of an Azure resource group. -// 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 DatabaseAccountsClient) CreateUpdateMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, createUpdateMongoDBCollectionParameters MongoDBCollectionCreateUpdateParameters) (result DatabaseAccountsCreateUpdateMongoDBCollectionFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.CreateUpdateMongoDBCollection") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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}}}, - {Target: "createUpdateMongoDBCollectionParameters.MongoDBCollectionCreateUpdateProperties.Options", Name: validation.Null, Rule: true, Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "CreateUpdateMongoDBCollection", err.Error()) - } - - req, err := client.CreateUpdateMongoDBCollectionPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName, createUpdateMongoDBCollectionParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateUpdateMongoDBCollection", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateMongoDBCollectionSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateUpdateMongoDBCollection", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdateMongoDBCollectionPreparer prepares the CreateUpdateMongoDBCollection request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/mongodb/databases/{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 DatabaseAccountsClient) CreateUpdateMongoDBCollectionSender(req *http.Request) (future DatabaseAccountsCreateUpdateMongoDBCollectionFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// CreateUpdateMongoDBCollectionResponder handles the response to the CreateUpdateMongoDBCollection request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) CreateUpdateMongoDBCollectionResponder(resp *http.Response) (result MongoDBCollection, 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// createUpdateMongoDBDatabaseParameters - the parameters to provide for the current MongoDB database. -func (client DatabaseAccountsClient) CreateUpdateMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateMongoDBDatabaseParameters MongoDBDatabaseCreateUpdateParameters) (result DatabaseAccountsCreateUpdateMongoDBDatabaseFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.CreateUpdateMongoDBDatabase") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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}}}, - {Target: "createUpdateMongoDBDatabaseParameters.MongoDBDatabaseCreateUpdateProperties.Options", Name: validation.Null, Rule: true, Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "CreateUpdateMongoDBDatabase", err.Error()) - } - - req, err := client.CreateUpdateMongoDBDatabasePreparer(ctx, resourceGroupName, accountName, databaseName, createUpdateMongoDBDatabaseParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateUpdateMongoDBDatabase", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateMongoDBDatabaseSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateUpdateMongoDBDatabase", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdateMongoDBDatabasePreparer prepares the CreateUpdateMongoDBDatabase request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/mongodb/databases/{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 DatabaseAccountsClient) CreateUpdateMongoDBDatabaseSender(req *http.Request) (future DatabaseAccountsCreateUpdateMongoDBDatabaseFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// CreateUpdateMongoDBDatabaseResponder handles the response to the CreateUpdateMongoDBDatabase request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) CreateUpdateMongoDBDatabaseResponder(resp *http.Response) (result MongoDBDatabase, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateUpdateSQLContainer create or update an Azure Cosmos DB SQL container -// Parameters: -// resourceGroupName - name of an Azure resource group. -// 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 DatabaseAccountsClient) CreateUpdateSQLContainer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, createUpdateSQLContainerParameters SQLContainerCreateUpdateParameters) (result DatabaseAccountsCreateUpdateSQLContainerFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.CreateUpdateSQLContainer") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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.Options", Name: validation.Null, Rule: true, Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "CreateUpdateSQLContainer", err.Error()) - } - - req, err := client.CreateUpdateSQLContainerPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, createUpdateSQLContainerParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateUpdateSQLContainer", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateSQLContainerSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateUpdateSQLContainer", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdateSQLContainerPreparer prepares the CreateUpdateSQLContainer request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/sql/databases/{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 DatabaseAccountsClient) CreateUpdateSQLContainerSender(req *http.Request) (future DatabaseAccountsCreateUpdateSQLContainerFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// CreateUpdateSQLContainerResponder handles the response to the CreateUpdateSQLContainer request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) CreateUpdateSQLContainerResponder(resp *http.Response) (result SQLContainer, 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// createUpdateSQLDatabaseParameters - the parameters to provide for the current SQL database. -func (client DatabaseAccountsClient) CreateUpdateSQLDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string, createUpdateSQLDatabaseParameters SQLDatabaseCreateUpdateParameters) (result DatabaseAccountsCreateUpdateSQLDatabaseFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.CreateUpdateSQLDatabase") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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}}}, - {Target: "createUpdateSQLDatabaseParameters.SQLDatabaseCreateUpdateProperties.Options", Name: validation.Null, Rule: true, Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "CreateUpdateSQLDatabase", err.Error()) - } - - req, err := client.CreateUpdateSQLDatabasePreparer(ctx, resourceGroupName, accountName, databaseName, createUpdateSQLDatabaseParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateUpdateSQLDatabase", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateSQLDatabaseSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateUpdateSQLDatabase", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdateSQLDatabasePreparer prepares the CreateUpdateSQLDatabase request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/sql/databases/{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 DatabaseAccountsClient) CreateUpdateSQLDatabaseSender(req *http.Request) (future DatabaseAccountsCreateUpdateSQLDatabaseFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// CreateUpdateSQLDatabaseResponder handles the response to the CreateUpdateSQLDatabase request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) CreateUpdateSQLDatabaseResponder(resp *http.Response) (result SQLDatabase, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateUpdateTable create or update an Azure Cosmos DB Table -// Parameters: -// resourceGroupName - name of an Azure resource group. -// accountName - cosmos DB database account name. -// tableName - cosmos DB table name. -// createUpdateTableParameters - the parameters to provide for the current Table. -func (client DatabaseAccountsClient) CreateUpdateTable(ctx context.Context, resourceGroupName string, accountName string, tableName string, createUpdateTableParameters TableCreateUpdateParameters) (result DatabaseAccountsCreateUpdateTableFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.CreateUpdateTable") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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}}}, - {Target: "createUpdateTableParameters.TableCreateUpdateProperties.Options", Name: validation.Null, Rule: true, Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "CreateUpdateTable", err.Error()) - } - - req, err := client.CreateUpdateTablePreparer(ctx, resourceGroupName, accountName, tableName, createUpdateTableParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateUpdateTable", nil, "Failure preparing request") - return - } - - result, err = client.CreateUpdateTableSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "CreateUpdateTable", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateUpdateTablePreparer prepares the CreateUpdateTable request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/table/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 DatabaseAccountsClient) CreateUpdateTableSender(req *http.Request) (future DatabaseAccountsCreateUpdateTableFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// CreateUpdateTableResponder handles the response to the CreateUpdateTable request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) CreateUpdateTableResponder(resp *http.Response) (result Table, 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 an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - name of an Azure resource group. -// 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.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2015-04-08" - 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 - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - 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 -} - -// DeleteCassandraKeyspace deletes an existing Azure Cosmos DB Cassandra keyspace. -// Parameters: -// resourceGroupName - name of an Azure resource group. -// accountName - cosmos DB database account name. -// keyspaceName - cosmos DB keyspace name. -func (client DatabaseAccountsClient) DeleteCassandraKeyspace(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result DatabaseAccountsDeleteCassandraKeyspaceFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.DeleteCassandraKeyspace") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "DeleteCassandraKeyspace", err.Error()) - } - - req, err := client.DeleteCassandraKeyspacePreparer(ctx, resourceGroupName, accountName, keyspaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "DeleteCassandraKeyspace", nil, "Failure preparing request") - return - } - - result, err = client.DeleteCassandraKeyspaceSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "DeleteCassandraKeyspace", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteCassandraKeyspacePreparer prepares the DeleteCassandraKeyspace request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/cassandra/keyspaces/{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 DatabaseAccountsClient) DeleteCassandraKeyspaceSender(req *http.Request) (future DatabaseAccountsDeleteCassandraKeyspaceFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// DeleteCassandraKeyspaceResponder handles the response to the DeleteCassandraKeyspace request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -// keyspaceName - cosmos DB keyspace name. -// tableName - cosmos DB table name. -func (client DatabaseAccountsClient) DeleteCassandraTable(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result DatabaseAccountsDeleteCassandraTableFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.DeleteCassandraTable") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "DeleteCassandraTable", err.Error()) - } - - req, err := client.DeleteCassandraTablePreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "DeleteCassandraTable", nil, "Failure preparing request") - return - } - - result, err = client.DeleteCassandraTableSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "DeleteCassandraTable", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteCassandraTablePreparer prepares the DeleteCassandraTable request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/cassandra/keyspaces/{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 DatabaseAccountsClient) DeleteCassandraTableSender(req *http.Request) (future DatabaseAccountsDeleteCassandraTableFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// DeleteCassandraTableResponder handles the response to the DeleteCassandraTable request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) 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 -} - -// DeleteGremlinDatabase deletes an existing Azure Cosmos DB Gremlin database. -// Parameters: -// resourceGroupName - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client DatabaseAccountsClient) DeleteGremlinDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result DatabaseAccountsDeleteGremlinDatabaseFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.DeleteGremlinDatabase") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "DeleteGremlinDatabase", err.Error()) - } - - req, err := client.DeleteGremlinDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "DeleteGremlinDatabase", nil, "Failure preparing request") - return - } - - result, err = client.DeleteGremlinDatabaseSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "DeleteGremlinDatabase", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteGremlinDatabasePreparer prepares the DeleteGremlinDatabase request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/gremlin/databases/{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 DatabaseAccountsClient) DeleteGremlinDatabaseSender(req *http.Request) (future DatabaseAccountsDeleteGremlinDatabaseFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// DeleteGremlinDatabaseResponder handles the response to the DeleteGremlinDatabase request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// graphName - cosmos DB graph name. -func (client DatabaseAccountsClient) DeleteGremlinGraph(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result DatabaseAccountsDeleteGremlinGraphFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.DeleteGremlinGraph") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "DeleteGremlinGraph", err.Error()) - } - - req, err := client.DeleteGremlinGraphPreparer(ctx, resourceGroupName, accountName, databaseName, graphName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "DeleteGremlinGraph", nil, "Failure preparing request") - return - } - - result, err = client.DeleteGremlinGraphSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "DeleteGremlinGraph", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteGremlinGraphPreparer prepares the DeleteGremlinGraph request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/gremlin/databases/{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 DatabaseAccountsClient) DeleteGremlinGraphSender(req *http.Request) (future DatabaseAccountsDeleteGremlinGraphFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// DeleteGremlinGraphResponder handles the response to the DeleteGremlinGraph request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) 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 -} - -// DeleteMongoDBCollection deletes an existing Azure Cosmos DB MongoDB Collection. -// Parameters: -// resourceGroupName - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// collectionName - cosmos DB collection name. -func (client DatabaseAccountsClient) DeleteMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result DatabaseAccountsDeleteMongoDBCollectionFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.DeleteMongoDBCollection") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "DeleteMongoDBCollection", err.Error()) - } - - req, err := client.DeleteMongoDBCollectionPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "DeleteMongoDBCollection", nil, "Failure preparing request") - return - } - - result, err = client.DeleteMongoDBCollectionSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "DeleteMongoDBCollection", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteMongoDBCollectionPreparer prepares the DeleteMongoDBCollection request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/mongodb/databases/{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 DatabaseAccountsClient) DeleteMongoDBCollectionSender(req *http.Request) (future DatabaseAccountsDeleteMongoDBCollectionFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// DeleteMongoDBCollectionResponder handles the response to the DeleteMongoDBCollection request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client DatabaseAccountsClient) DeleteMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result DatabaseAccountsDeleteMongoDBDatabaseFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.DeleteMongoDBDatabase") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "DeleteMongoDBDatabase", err.Error()) - } - - req, err := client.DeleteMongoDBDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "DeleteMongoDBDatabase", nil, "Failure preparing request") - return - } - - result, err = client.DeleteMongoDBDatabaseSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "DeleteMongoDBDatabase", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteMongoDBDatabasePreparer prepares the DeleteMongoDBDatabase request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/mongodb/databases/{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 DatabaseAccountsClient) DeleteMongoDBDatabaseSender(req *http.Request) (future DatabaseAccountsDeleteMongoDBDatabaseFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// DeleteMongoDBDatabaseResponder handles the response to the DeleteMongoDBDatabase request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) 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 -} - -// DeleteSQLContainer deletes an existing Azure Cosmos DB SQL container. -// Parameters: -// resourceGroupName - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// containerName - cosmos DB container name. -func (client DatabaseAccountsClient) DeleteSQLContainer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result DatabaseAccountsDeleteSQLContainerFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.DeleteSQLContainer") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "DeleteSQLContainer", err.Error()) - } - - req, err := client.DeleteSQLContainerPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "DeleteSQLContainer", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSQLContainerSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "DeleteSQLContainer", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteSQLContainerPreparer prepares the DeleteSQLContainer request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/sql/databases/{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 DatabaseAccountsClient) DeleteSQLContainerSender(req *http.Request) (future DatabaseAccountsDeleteSQLContainerFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// DeleteSQLContainerResponder handles the response to the DeleteSQLContainer request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client DatabaseAccountsClient) DeleteSQLDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result DatabaseAccountsDeleteSQLDatabaseFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.DeleteSQLDatabase") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "DeleteSQLDatabase", err.Error()) - } - - req, err := client.DeleteSQLDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "DeleteSQLDatabase", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSQLDatabaseSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "DeleteSQLDatabase", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteSQLDatabasePreparer prepares the DeleteSQLDatabase request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/sql/databases/{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 DatabaseAccountsClient) DeleteSQLDatabaseSender(req *http.Request) (future DatabaseAccountsDeleteSQLDatabaseFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// DeleteSQLDatabaseResponder handles the response to the DeleteSQLDatabase request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) 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 -} - -// DeleteTable deletes an existing Azure Cosmos DB Table. -// Parameters: -// resourceGroupName - name of an Azure resource group. -// accountName - cosmos DB database account name. -// tableName - cosmos DB table name. -func (client DatabaseAccountsClient) DeleteTable(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result DatabaseAccountsDeleteTableFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.DeleteTable") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "DeleteTable", err.Error()) - } - - req, err := client.DeleteTablePreparer(ctx, resourceGroupName, accountName, tableName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "DeleteTable", nil, "Failure preparing request") - return - } - - result, err = client.DeleteTableSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "DeleteTable", result.Response(), "Failure sending request") - return - } - - return -} - -// DeleteTablePreparer prepares the DeleteTable request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/table/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 DatabaseAccountsClient) DeleteTableSender(req *http.Request) (future DatabaseAccountsDeleteTableFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// DeleteTableResponder handles the response to the DeleteTable request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) 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 -} - -// 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 - name of an Azure resource group. -// 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.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2015-04-08" - 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 - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -func (client DatabaseAccountsClient) Get(ctx context.Context, resourceGroupName string, accountName string) (result DatabaseAccount, 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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 -} - -// 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 = "2015-04-08" - 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 DatabaseAccount, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetCassandraKeyspace gets the Cassandra keyspaces under an existing Azure Cosmos DB database account with the -// provided name. -// Parameters: -// resourceGroupName - name of an Azure resource group. -// accountName - cosmos DB database account name. -// keyspaceName - cosmos DB keyspace name. -func (client DatabaseAccountsClient) GetCassandraKeyspace(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result CassandraKeyspace, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "GetCassandraKeyspace", err.Error()) - } - - req, err := client.GetCassandraKeyspacePreparer(ctx, resourceGroupName, accountName, keyspaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "GetCassandraKeyspace", resp, "Failure sending request") - return - } - - result, err = client.GetCassandraKeyspaceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetCassandraKeyspace", resp, "Failure responding to request") - } - - return -} - -// GetCassandraKeyspacePreparer prepares the GetCassandraKeyspace request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/cassandra/keyspaces/{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 DatabaseAccountsClient) 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 DatabaseAccountsClient) GetCassandraKeyspaceResponder(resp *http.Response) (result CassandraKeyspace, 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -// keyspaceName - cosmos DB keyspace name. -func (client DatabaseAccountsClient) GetCassandraKeyspaceThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result Throughput, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "GetCassandraKeyspaceThroughput", err.Error()) - } - - req, err := client.GetCassandraKeyspaceThroughputPreparer(ctx, resourceGroupName, accountName, keyspaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "GetCassandraKeyspaceThroughput", resp, "Failure sending request") - return - } - - result, err = client.GetCassandraKeyspaceThroughputResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetCassandraKeyspaceThroughput", resp, "Failure responding to request") - } - - return -} - -// GetCassandraKeyspaceThroughputPreparer prepares the GetCassandraKeyspaceThroughput request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/cassandra/keyspaces/{keyspaceName}/settings/throughput", 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 DatabaseAccountsClient) 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 DatabaseAccountsClient) GetCassandraKeyspaceThroughputResponder(resp *http.Response) (result Throughput, 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -// keyspaceName - cosmos DB keyspace name. -// tableName - cosmos DB table name. -func (client DatabaseAccountsClient) GetCassandraTable(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result CassandraTable, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "GetCassandraTable", err.Error()) - } - - req, err := client.GetCassandraTablePreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "GetCassandraTable", resp, "Failure sending request") - return - } - - result, err = client.GetCassandraTableResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetCassandraTable", resp, "Failure responding to request") - } - - return -} - -// GetCassandraTablePreparer prepares the GetCassandraTable request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/cassandra/keyspaces/{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 DatabaseAccountsClient) 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 DatabaseAccountsClient) GetCassandraTableResponder(resp *http.Response) (result CassandraTable, 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -// keyspaceName - cosmos DB keyspace name. -// tableName - cosmos DB table name. -func (client DatabaseAccountsClient) GetCassandraTableThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string) (result Throughput, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "GetCassandraTableThroughput", err.Error()) - } - - req, err := client.GetCassandraTableThroughputPreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "GetCassandraTableThroughput", resp, "Failure sending request") - return - } - - result, err = client.GetCassandraTableThroughputResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetCassandraTableThroughput", resp, "Failure responding to request") - } - - return -} - -// GetCassandraTableThroughputPreparer prepares the GetCassandraTableThroughput request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/cassandra/keyspaces/{keyspaceName}/tables/{tableName}/settings/throughput", 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 DatabaseAccountsClient) 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 DatabaseAccountsClient) GetCassandraTableThroughputResponder(resp *http.Response) (result Throughput, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetGremlinDatabase gets the Gremlin databases under an existing Azure Cosmos DB database account with the provided -// name. -// Parameters: -// resourceGroupName - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client DatabaseAccountsClient) GetGremlinDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result GremlinDatabase, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "GetGremlinDatabase", err.Error()) - } - - req, err := client.GetGremlinDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "GetGremlinDatabase", resp, "Failure sending request") - return - } - - result, err = client.GetGremlinDatabaseResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetGremlinDatabase", resp, "Failure responding to request") - } - - return -} - -// GetGremlinDatabasePreparer prepares the GetGremlinDatabase request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/gremlin/databases/{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 DatabaseAccountsClient) 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 DatabaseAccountsClient) GetGremlinDatabaseResponder(resp *http.Response) (result GremlinDatabase, 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client DatabaseAccountsClient) GetGremlinDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result Throughput, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "GetGremlinDatabaseThroughput", err.Error()) - } - - req, err := client.GetGremlinDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "GetGremlinDatabaseThroughput", resp, "Failure sending request") - return - } - - result, err = client.GetGremlinDatabaseThroughputResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetGremlinDatabaseThroughput", resp, "Failure responding to request") - } - - return -} - -// GetGremlinDatabaseThroughputPreparer prepares the GetGremlinDatabaseThroughput request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/gremlin/databases/{databaseName}/settings/throughput", 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 DatabaseAccountsClient) 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 DatabaseAccountsClient) GetGremlinDatabaseThroughputResponder(resp *http.Response) (result Throughput, 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// graphName - cosmos DB graph name. -func (client DatabaseAccountsClient) GetGremlinGraph(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result GremlinGraph, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "GetGremlinGraph", err.Error()) - } - - req, err := client.GetGremlinGraphPreparer(ctx, resourceGroupName, accountName, databaseName, graphName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "GetGremlinGraph", resp, "Failure sending request") - return - } - - result, err = client.GetGremlinGraphResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetGremlinGraph", resp, "Failure responding to request") - } - - return -} - -// GetGremlinGraphPreparer prepares the GetGremlinGraph request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/gremlin/databases/{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 DatabaseAccountsClient) 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 DatabaseAccountsClient) GetGremlinGraphResponder(resp *http.Response) (result GremlinGraph, 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// graphName - cosmos DB graph name. -func (client DatabaseAccountsClient) GetGremlinGraphThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string) (result Throughput, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "GetGremlinGraphThroughput", err.Error()) - } - - req, err := client.GetGremlinGraphThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, graphName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "GetGremlinGraphThroughput", resp, "Failure sending request") - return - } - - result, err = client.GetGremlinGraphThroughputResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetGremlinGraphThroughput", resp, "Failure responding to request") - } - - return -} - -// GetGremlinGraphThroughputPreparer prepares the GetGremlinGraphThroughput request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/gremlin/databases/{databaseName}/graphs/{graphName}/settings/throughput", 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 DatabaseAccountsClient) 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 DatabaseAccountsClient) GetGremlinGraphThroughputResponder(resp *http.Response) (result Throughput, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetMongoDBCollection gets the MongoDB collection under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// collectionName - cosmos DB collection name. -func (client DatabaseAccountsClient) GetMongoDBCollection(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result MongoDBCollection, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "GetMongoDBCollection", err.Error()) - } - - req, err := client.GetMongoDBCollectionPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "GetMongoDBCollection", resp, "Failure sending request") - return - } - - result, err = client.GetMongoDBCollectionResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetMongoDBCollection", resp, "Failure responding to request") - } - - return -} - -// GetMongoDBCollectionPreparer prepares the GetMongoDBCollection request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/mongodb/databases/{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 DatabaseAccountsClient) 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 DatabaseAccountsClient) GetMongoDBCollectionResponder(resp *http.Response) (result MongoDBCollection, 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// collectionName - cosmos DB collection name. -func (client DatabaseAccountsClient) GetMongoDBCollectionThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string) (result Throughput, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "GetMongoDBCollectionThroughput", err.Error()) - } - - req, err := client.GetMongoDBCollectionThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "GetMongoDBCollectionThroughput", resp, "Failure sending request") - return - } - - result, err = client.GetMongoDBCollectionThroughputResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetMongoDBCollectionThroughput", resp, "Failure responding to request") - } - - return -} - -// GetMongoDBCollectionThroughputPreparer prepares the GetMongoDBCollectionThroughput request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/mongodb/databases/{databaseName}/collections/{collectionName}/settings/throughput", 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 DatabaseAccountsClient) 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 DatabaseAccountsClient) GetMongoDBCollectionThroughputResponder(resp *http.Response) (result Throughput, 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client DatabaseAccountsClient) GetMongoDBDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBDatabase, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "GetMongoDBDatabase", err.Error()) - } - - req, err := client.GetMongoDBDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "GetMongoDBDatabase", resp, "Failure sending request") - return - } - - result, err = client.GetMongoDBDatabaseResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetMongoDBDatabase", resp, "Failure responding to request") - } - - return -} - -// GetMongoDBDatabasePreparer prepares the GetMongoDBDatabase request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/mongodb/databases/{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 DatabaseAccountsClient) 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 DatabaseAccountsClient) GetMongoDBDatabaseResponder(resp *http.Response) (result MongoDBDatabase, 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client DatabaseAccountsClient) GetMongoDBDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result Throughput, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "GetMongoDBDatabaseThroughput", err.Error()) - } - - req, err := client.GetMongoDBDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "GetMongoDBDatabaseThroughput", resp, "Failure sending request") - return - } - - result, err = client.GetMongoDBDatabaseThroughputResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetMongoDBDatabaseThroughput", resp, "Failure responding to request") - } - - return -} - -// GetMongoDBDatabaseThroughputPreparer prepares the GetMongoDBDatabaseThroughput request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/mongodb/databases/{databaseName}/settings/throughput", 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 DatabaseAccountsClient) 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 DatabaseAccountsClient) GetMongoDBDatabaseThroughputResponder(resp *http.Response) (result Throughput, 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 - name of an Azure resource group. -// 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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 -} - -// 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 = "2015-04-08" - 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 -} - -// GetSQLContainer gets the SQL container under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// containerName - cosmos DB container name. -func (client DatabaseAccountsClient) GetSQLContainer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result SQLContainer, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "GetSQLContainer", err.Error()) - } - - req, err := client.GetSQLContainerPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "GetSQLContainer", resp, "Failure sending request") - return - } - - result, err = client.GetSQLContainerResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetSQLContainer", resp, "Failure responding to request") - } - - return -} - -// GetSQLContainerPreparer prepares the GetSQLContainer request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/sql/databases/{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 DatabaseAccountsClient) 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 DatabaseAccountsClient) GetSQLContainerResponder(resp *http.Response) (result SQLContainer, 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -// containerName - cosmos DB container name. -func (client DatabaseAccountsClient) GetSQLContainerThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string) (result Throughput, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "GetSQLContainerThroughput", err.Error()) - } - - req, err := client.GetSQLContainerThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, containerName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "GetSQLContainerThroughput", resp, "Failure sending request") - return - } - - result, err = client.GetSQLContainerThroughputResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetSQLContainerThroughput", resp, "Failure responding to request") - } - - return -} - -// GetSQLContainerThroughputPreparer prepares the GetSQLContainerThroughput request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/sql/databases/{databaseName}/containers/{containerName}/settings/throughput", 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 DatabaseAccountsClient) 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 DatabaseAccountsClient) GetSQLContainerThroughputResponder(resp *http.Response) (result Throughput, 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client DatabaseAccountsClient) GetSQLDatabase(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result SQLDatabase, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "GetSQLDatabase", err.Error()) - } - - req, err := client.GetSQLDatabasePreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "GetSQLDatabase", resp, "Failure sending request") - return - } - - result, err = client.GetSQLDatabaseResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetSQLDatabase", resp, "Failure responding to request") - } - - return -} - -// GetSQLDatabasePreparer prepares the GetSQLDatabase request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/sql/databases/{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 DatabaseAccountsClient) 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 DatabaseAccountsClient) GetSQLDatabaseResponder(resp *http.Response) (result SQLDatabase, 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client DatabaseAccountsClient) GetSQLDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result Throughput, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "GetSQLDatabaseThroughput", err.Error()) - } - - req, err := client.GetSQLDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "GetSQLDatabaseThroughput", resp, "Failure sending request") - return - } - - result, err = client.GetSQLDatabaseThroughputResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetSQLDatabaseThroughput", resp, "Failure responding to request") - } - - return -} - -// GetSQLDatabaseThroughputPreparer prepares the GetSQLDatabaseThroughput request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/sql/databases/{databaseName}/settings/throughput", 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 DatabaseAccountsClient) 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 DatabaseAccountsClient) GetSQLDatabaseThroughputResponder(resp *http.Response) (result Throughput, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetTable gets the Tables under an existing Azure Cosmos DB database account with the provided name. -// Parameters: -// resourceGroupName - name of an Azure resource group. -// accountName - cosmos DB database account name. -// tableName - cosmos DB table name. -func (client DatabaseAccountsClient) GetTable(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result Table, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "GetTable", err.Error()) - } - - req, err := client.GetTablePreparer(ctx, resourceGroupName, accountName, tableName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "GetTable", resp, "Failure sending request") - return - } - - result, err = client.GetTableResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetTable", resp, "Failure responding to request") - } - - return -} - -// GetTablePreparer prepares the GetTable request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/table/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 DatabaseAccountsClient) 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 DatabaseAccountsClient) GetTableResponder(resp *http.Response) (result Table, 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -// tableName - cosmos DB table name. -func (client DatabaseAccountsClient) GetTableThroughput(ctx context.Context, resourceGroupName string, accountName string, tableName string) (result Throughput, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "GetTableThroughput", err.Error()) - } - - req, err := client.GetTableThroughputPreparer(ctx, resourceGroupName, accountName, tableName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "GetTableThroughput", resp, "Failure sending request") - return - } - - result, err = client.GetTableThroughputResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "GetTableThroughput", resp, "Failure responding to request") - } - - return -} - -// GetTableThroughputPreparer prepares the GetTableThroughput request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/table/tables/{tableName}/settings/throughput", 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 DatabaseAccountsClient) 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 DatabaseAccountsClient) GetTableThroughputResponder(resp *http.Response) (result Throughput, 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) - }() - } - 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 -} - -// 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 = "2015-04-08" - 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 - name of an Azure resource group. -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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 -} - -// 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 = "2015-04-08" - 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 -} - -// ListCassandraKeyspaces lists the Cassandra keyspaces under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - name of an Azure resource group. -// accountName - cosmos DB database account name. -func (client DatabaseAccountsClient) ListCassandraKeyspaces(ctx context.Context, resourceGroupName string, accountName string) (result CassandraKeyspaceListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "ListCassandraKeyspaces", err.Error()) - } - - req, err := client.ListCassandraKeyspacesPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "ListCassandraKeyspaces", resp, "Failure sending request") - return - } - - result, err = client.ListCassandraKeyspacesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListCassandraKeyspaces", resp, "Failure responding to request") - } - - return -} - -// ListCassandraKeyspacesPreparer prepares the ListCassandraKeyspaces request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/cassandra/keyspaces", 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 DatabaseAccountsClient) 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 DatabaseAccountsClient) 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -// keyspaceName - cosmos DB keyspace name. -func (client DatabaseAccountsClient) ListCassandraTables(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string) (result CassandraTableListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "ListCassandraTables", err.Error()) - } - - req, err := client.ListCassandraTablesPreparer(ctx, resourceGroupName, accountName, keyspaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "ListCassandraTables", resp, "Failure sending request") - return - } - - result, err = client.ListCassandraTablesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListCassandraTables", resp, "Failure responding to request") - } - - return -} - -// ListCassandraTablesPreparer prepares the ListCassandraTables request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/cassandra/keyspaces/{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 DatabaseAccountsClient) 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 DatabaseAccountsClient) 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 -} - -// ListConnectionStrings lists the connection strings for the specified Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - name of an Azure resource group. -// 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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 -} - -// 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 = "2015-04-08" - 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 -} - -// ListGremlinDatabases lists the Gremlin databases under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - name of an Azure resource group. -// accountName - cosmos DB database account name. -func (client DatabaseAccountsClient) ListGremlinDatabases(ctx context.Context, resourceGroupName string, accountName string) (result GremlinDatabaseListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "ListGremlinDatabases", err.Error()) - } - - req, err := client.ListGremlinDatabasesPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "ListGremlinDatabases", resp, "Failure sending request") - return - } - - result, err = client.ListGremlinDatabasesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListGremlinDatabases", resp, "Failure responding to request") - } - - return -} - -// ListGremlinDatabasesPreparer prepares the ListGremlinDatabases request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/gremlin/databases", 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 DatabaseAccountsClient) 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 DatabaseAccountsClient) 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client DatabaseAccountsClient) ListGremlinGraphs(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result GremlinGraphListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "ListGremlinGraphs", err.Error()) - } - - req, err := client.ListGremlinGraphsPreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "ListGremlinGraphs", resp, "Failure sending request") - return - } - - result, err = client.ListGremlinGraphsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListGremlinGraphs", resp, "Failure responding to request") - } - - return -} - -// ListGremlinGraphsPreparer prepares the ListGremlinGraphs request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/gremlin/databases/{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 DatabaseAccountsClient) 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 DatabaseAccountsClient) 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 -} - -// ListKeys lists the access keys for the specified Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - name of an Azure resource group. -// 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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 -} - -// 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 = "2015-04-08" - 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 - name of an Azure resource group. -// 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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 -} - -// 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 = "2015-04-08" - 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 - name of an Azure resource group. -// 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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 -} - -// 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 = "2015-04-08" - 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 -} - -// ListMongoDBCollections lists the MongoDB collection under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client DatabaseAccountsClient) ListMongoDBCollections(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result MongoDBCollectionListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "ListMongoDBCollections", err.Error()) - } - - req, err := client.ListMongoDBCollectionsPreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "ListMongoDBCollections", resp, "Failure sending request") - return - } - - result, err = client.ListMongoDBCollectionsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListMongoDBCollections", resp, "Failure responding to request") - } - - return -} - -// ListMongoDBCollectionsPreparer prepares the ListMongoDBCollections request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/mongodb/databases/{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 DatabaseAccountsClient) 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 DatabaseAccountsClient) 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -func (client DatabaseAccountsClient) ListMongoDBDatabases(ctx context.Context, resourceGroupName string, accountName string) (result MongoDBDatabaseListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "ListMongoDBDatabases", err.Error()) - } - - req, err := client.ListMongoDBDatabasesPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "ListMongoDBDatabases", resp, "Failure sending request") - return - } - - result, err = client.ListMongoDBDatabasesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListMongoDBDatabases", resp, "Failure responding to request") - } - - return -} - -// ListMongoDBDatabasesPreparer prepares the ListMongoDBDatabases request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/mongodb/databases", 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 DatabaseAccountsClient) 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 DatabaseAccountsClient) 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 -} - -// ListReadOnlyKeys lists the read-only access keys for the specified Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - name of an Azure resource group. -// 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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 -} - -// 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 = "2015-04-08" - 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 -} - -// ListSQLContainers lists the SQL container under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - name of an Azure resource group. -// accountName - cosmos DB database account name. -// databaseName - cosmos DB database name. -func (client DatabaseAccountsClient) ListSQLContainers(ctx context.Context, resourceGroupName string, accountName string, databaseName string) (result SQLContainerListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "ListSQLContainers", err.Error()) - } - - req, err := client.ListSQLContainersPreparer(ctx, resourceGroupName, accountName, databaseName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "ListSQLContainers", resp, "Failure sending request") - return - } - - result, err = client.ListSQLContainersResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListSQLContainers", resp, "Failure responding to request") - } - - return -} - -// ListSQLContainersPreparer prepares the ListSQLContainers request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/sql/databases/{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 DatabaseAccountsClient) 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 DatabaseAccountsClient) 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 - name of an Azure resource group. -// accountName - cosmos DB database account name. -func (client DatabaseAccountsClient) ListSQLDatabases(ctx context.Context, resourceGroupName string, accountName string) (result SQLDatabaseListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "ListSQLDatabases", err.Error()) - } - - req, err := client.ListSQLDatabasesPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "ListSQLDatabases", resp, "Failure sending request") - return - } - - result, err = client.ListSQLDatabasesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListSQLDatabases", resp, "Failure responding to request") - } - - return -} - -// ListSQLDatabasesPreparer prepares the ListSQLDatabases request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/sql/databases", 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 DatabaseAccountsClient) 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 DatabaseAccountsClient) 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 -} - -// ListTables lists the Tables under an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - name of an Azure resource group. -// accountName - cosmos DB database account name. -func (client DatabaseAccountsClient) ListTables(ctx context.Context, resourceGroupName string, accountName string) (result TableListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "ListTables", err.Error()) - } - - req, err := client.ListTablesPreparer(ctx, resourceGroupName, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "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.DatabaseAccountsClient", "ListTables", resp, "Failure sending request") - return - } - - result, err = client.ListTablesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "ListTables", resp, "Failure responding to request") - } - - return -} - -// ListTablesPreparer prepares the ListTables request. -func (client DatabaseAccountsClient) 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 = "2015-04-08" - 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}/apis/table/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 DatabaseAccountsClient) 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 DatabaseAccountsClient) 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 -} - -// ListUsages retrieves the usages (most recent data) for the given database account. -// Parameters: -// resourceGroupName - name of an Azure resource group. -// 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: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 -} - -// 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 = "2015-04-08" - 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 - name of an Azure resource group. -// 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.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2015-04-08" - 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 - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - 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 - name of an Azure resource group. -// 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.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2015-04-08" - 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 - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - 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 -} - -// Patch patches the properties of an existing Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - name of an Azure resource group. -// accountName - cosmos DB database account name. -// updateParameters - the tags parameter to patch for the current database account. -func (client DatabaseAccountsClient) Patch(ctx context.Context, resourceGroupName string, accountName string, updateParameters DatabaseAccountPatchParameters) (result DatabaseAccountsPatchFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.Patch") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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", "Patch", err.Error()) - } - - req, err := client.PatchPreparer(ctx, resourceGroupName, accountName, updateParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Patch", nil, "Failure preparing request") - return - } - - result, err = client.PatchSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "Patch", result.Response(), "Failure sending request") - return - } - - return -} - -// PatchPreparer prepares the Patch request. -func (client DatabaseAccountsClient) PatchPreparer(ctx context.Context, resourceGroupName string, accountName string, updateParameters DatabaseAccountPatchParameters) (*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 = "2015-04-08" - 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)) -} - -// PatchSender sends the Patch request. The method will close the -// http.Response Body if it receives an error. -func (client DatabaseAccountsClient) PatchSender(req *http.Request) (future DatabaseAccountsPatchFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// PatchResponder handles the response to the Patch request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) PatchResponder(resp *http.Response) (result DatabaseAccount, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// RegenerateKey regenerates an access key for the specified Azure Cosmos DB database account. -// Parameters: -// resourceGroupName - name of an Azure resource group. -// 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.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2015-04-08" - 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 - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - 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 -} - -// UpdateCassandraKeyspaceThroughput update RUs per second of an Azure Cosmos DB Cassandra Keyspace -// Parameters: -// resourceGroupName - name of an Azure resource group. -// 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 DatabaseAccountsClient) UpdateCassandraKeyspaceThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, updateThroughputParameters ThroughputUpdateParameters) (result DatabaseAccountsUpdateCassandraKeyspaceThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.UpdateCassandraKeyspaceThroughput") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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.ThroughputUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputUpdateProperties.Resource.Throughput", Name: validation.Null, Rule: true, Chain: nil}}}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "UpdateCassandraKeyspaceThroughput", err.Error()) - } - - req, err := client.UpdateCassandraKeyspaceThroughputPreparer(ctx, resourceGroupName, accountName, keyspaceName, updateThroughputParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "UpdateCassandraKeyspaceThroughput", nil, "Failure preparing request") - return - } - - result, err = client.UpdateCassandraKeyspaceThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "UpdateCassandraKeyspaceThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdateCassandraKeyspaceThroughputPreparer prepares the UpdateCassandraKeyspaceThroughput request. -func (client DatabaseAccountsClient) UpdateCassandraKeyspaceThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, updateThroughputParameters ThroughputUpdateParameters) (*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 = "2015-04-08" - 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}/apis/cassandra/keyspaces/{keyspaceName}/settings/throughput", 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 DatabaseAccountsClient) UpdateCassandraKeyspaceThroughputSender(req *http.Request) (future DatabaseAccountsUpdateCassandraKeyspaceThroughputFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// UpdateCassandraKeyspaceThroughputResponder handles the response to the UpdateCassandraKeyspaceThroughput request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) UpdateCassandraKeyspaceThroughputResponder(resp *http.Response) (result Throughput, 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 - name of an Azure resource group. -// 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 DatabaseAccountsClient) UpdateCassandraTableThroughput(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string, updateThroughputParameters ThroughputUpdateParameters) (result DatabaseAccountsUpdateCassandraTableThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.UpdateCassandraTableThroughput") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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.ThroughputUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputUpdateProperties.Resource.Throughput", Name: validation.Null, Rule: true, Chain: nil}}}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "UpdateCassandraTableThroughput", err.Error()) - } - - req, err := client.UpdateCassandraTableThroughputPreparer(ctx, resourceGroupName, accountName, keyspaceName, tableName, updateThroughputParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "UpdateCassandraTableThroughput", nil, "Failure preparing request") - return - } - - result, err = client.UpdateCassandraTableThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "UpdateCassandraTableThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdateCassandraTableThroughputPreparer prepares the UpdateCassandraTableThroughput request. -func (client DatabaseAccountsClient) UpdateCassandraTableThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, keyspaceName string, tableName string, updateThroughputParameters ThroughputUpdateParameters) (*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 = "2015-04-08" - 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}/apis/cassandra/keyspaces/{keyspaceName}/tables/{tableName}/settings/throughput", 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 DatabaseAccountsClient) UpdateCassandraTableThroughputSender(req *http.Request) (future DatabaseAccountsUpdateCassandraTableThroughputFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// UpdateCassandraTableThroughputResponder handles the response to the UpdateCassandraTableThroughput request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) UpdateCassandraTableThroughputResponder(resp *http.Response) (result Throughput, 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 - name of an Azure resource group. -// 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 DatabaseAccountsClient) UpdateGremlinDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputUpdateParameters) (result DatabaseAccountsUpdateGremlinDatabaseThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.UpdateGremlinDatabaseThroughput") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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.ThroughputUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputUpdateProperties.Resource.Throughput", Name: validation.Null, Rule: true, Chain: nil}}}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "UpdateGremlinDatabaseThroughput", err.Error()) - } - - req, err := client.UpdateGremlinDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, updateThroughputParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "UpdateGremlinDatabaseThroughput", nil, "Failure preparing request") - return - } - - result, err = client.UpdateGremlinDatabaseThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "UpdateGremlinDatabaseThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdateGremlinDatabaseThroughputPreparer prepares the UpdateGremlinDatabaseThroughput request. -func (client DatabaseAccountsClient) UpdateGremlinDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputUpdateParameters) (*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 = "2015-04-08" - 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}/apis/gremlin/databases/{databaseName}/settings/throughput", 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 DatabaseAccountsClient) UpdateGremlinDatabaseThroughputSender(req *http.Request) (future DatabaseAccountsUpdateGremlinDatabaseThroughputFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// UpdateGremlinDatabaseThroughputResponder handles the response to the UpdateGremlinDatabaseThroughput request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) UpdateGremlinDatabaseThroughputResponder(resp *http.Response) (result Throughput, 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 - name of an Azure resource group. -// 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 DatabaseAccountsClient) UpdateGremlinGraphThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string, updateThroughputParameters ThroughputUpdateParameters) (result DatabaseAccountsUpdateGremlinGraphThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.UpdateGremlinGraphThroughput") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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.ThroughputUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputUpdateProperties.Resource.Throughput", Name: validation.Null, Rule: true, Chain: nil}}}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "UpdateGremlinGraphThroughput", err.Error()) - } - - req, err := client.UpdateGremlinGraphThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, graphName, updateThroughputParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "UpdateGremlinGraphThroughput", nil, "Failure preparing request") - return - } - - result, err = client.UpdateGremlinGraphThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "UpdateGremlinGraphThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdateGremlinGraphThroughputPreparer prepares the UpdateGremlinGraphThroughput request. -func (client DatabaseAccountsClient) UpdateGremlinGraphThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, graphName string, updateThroughputParameters ThroughputUpdateParameters) (*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 = "2015-04-08" - 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}/apis/gremlin/databases/{databaseName}/graphs/{graphName}/settings/throughput", 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 DatabaseAccountsClient) UpdateGremlinGraphThroughputSender(req *http.Request) (future DatabaseAccountsUpdateGremlinGraphThroughputFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// UpdateGremlinGraphThroughputResponder handles the response to the UpdateGremlinGraphThroughput request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) UpdateGremlinGraphThroughputResponder(resp *http.Response) (result Throughput, 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 - name of an Azure resource group. -// 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 DatabaseAccountsClient) UpdateMongoDBCollectionThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, updateThroughputParameters ThroughputUpdateParameters) (result DatabaseAccountsUpdateMongoDBCollectionThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.UpdateMongoDBCollectionThroughput") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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.ThroughputUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputUpdateProperties.Resource.Throughput", Name: validation.Null, Rule: true, Chain: nil}}}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "UpdateMongoDBCollectionThroughput", err.Error()) - } - - req, err := client.UpdateMongoDBCollectionThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, collectionName, updateThroughputParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "UpdateMongoDBCollectionThroughput", nil, "Failure preparing request") - return - } - - result, err = client.UpdateMongoDBCollectionThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "UpdateMongoDBCollectionThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdateMongoDBCollectionThroughputPreparer prepares the UpdateMongoDBCollectionThroughput request. -func (client DatabaseAccountsClient) UpdateMongoDBCollectionThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, collectionName string, updateThroughputParameters ThroughputUpdateParameters) (*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 = "2015-04-08" - 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}/apis/mongodb/databases/{databaseName}/collections/{collectionName}/settings/throughput", 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 DatabaseAccountsClient) UpdateMongoDBCollectionThroughputSender(req *http.Request) (future DatabaseAccountsUpdateMongoDBCollectionThroughputFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// UpdateMongoDBCollectionThroughputResponder handles the response to the UpdateMongoDBCollectionThroughput request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) UpdateMongoDBCollectionThroughputResponder(resp *http.Response) (result Throughput, 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 - name of an Azure resource group. -// 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 DatabaseAccountsClient) UpdateMongoDBDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputUpdateParameters) (result DatabaseAccountsUpdateMongoDBDatabaseThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.UpdateMongoDBDatabaseThroughput") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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.ThroughputUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputUpdateProperties.Resource.Throughput", Name: validation.Null, Rule: true, Chain: nil}}}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "UpdateMongoDBDatabaseThroughput", err.Error()) - } - - req, err := client.UpdateMongoDBDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, updateThroughputParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "UpdateMongoDBDatabaseThroughput", nil, "Failure preparing request") - return - } - - result, err = client.UpdateMongoDBDatabaseThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "UpdateMongoDBDatabaseThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdateMongoDBDatabaseThroughputPreparer prepares the UpdateMongoDBDatabaseThroughput request. -func (client DatabaseAccountsClient) UpdateMongoDBDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputUpdateParameters) (*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 = "2015-04-08" - 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}/apis/mongodb/databases/{databaseName}/settings/throughput", 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 DatabaseAccountsClient) UpdateMongoDBDatabaseThroughputSender(req *http.Request) (future DatabaseAccountsUpdateMongoDBDatabaseThroughputFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// UpdateMongoDBDatabaseThroughputResponder handles the response to the UpdateMongoDBDatabaseThroughput request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) UpdateMongoDBDatabaseThroughputResponder(resp *http.Response) (result Throughput, 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 - name of an Azure resource group. -// 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 DatabaseAccountsClient) UpdateSQLContainerThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, updateThroughputParameters ThroughputUpdateParameters) (result DatabaseAccountsUpdateSQLContainerThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.UpdateSQLContainerThroughput") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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.ThroughputUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputUpdateProperties.Resource.Throughput", Name: validation.Null, Rule: true, Chain: nil}}}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "UpdateSQLContainerThroughput", err.Error()) - } - - req, err := client.UpdateSQLContainerThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, containerName, updateThroughputParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "UpdateSQLContainerThroughput", nil, "Failure preparing request") - return - } - - result, err = client.UpdateSQLContainerThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "UpdateSQLContainerThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdateSQLContainerThroughputPreparer prepares the UpdateSQLContainerThroughput request. -func (client DatabaseAccountsClient) UpdateSQLContainerThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, updateThroughputParameters ThroughputUpdateParameters) (*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 = "2015-04-08" - 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}/apis/sql/databases/{databaseName}/containers/{containerName}/settings/throughput", 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 DatabaseAccountsClient) UpdateSQLContainerThroughputSender(req *http.Request) (future DatabaseAccountsUpdateSQLContainerThroughputFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// UpdateSQLContainerThroughputResponder handles the response to the UpdateSQLContainerThroughput request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) UpdateSQLContainerThroughputResponder(resp *http.Response) (result Throughput, 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 - name of an Azure resource group. -// 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 DatabaseAccountsClient) UpdateSQLDatabaseThroughput(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputUpdateParameters) (result DatabaseAccountsUpdateSQLDatabaseThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.UpdateSQLDatabaseThroughput") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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.ThroughputUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputUpdateProperties.Resource.Throughput", Name: validation.Null, Rule: true, Chain: nil}}}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "UpdateSQLDatabaseThroughput", err.Error()) - } - - req, err := client.UpdateSQLDatabaseThroughputPreparer(ctx, resourceGroupName, accountName, databaseName, updateThroughputParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "UpdateSQLDatabaseThroughput", nil, "Failure preparing request") - return - } - - result, err = client.UpdateSQLDatabaseThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "UpdateSQLDatabaseThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdateSQLDatabaseThroughputPreparer prepares the UpdateSQLDatabaseThroughput request. -func (client DatabaseAccountsClient) UpdateSQLDatabaseThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, databaseName string, updateThroughputParameters ThroughputUpdateParameters) (*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 = "2015-04-08" - 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}/apis/sql/databases/{databaseName}/settings/throughput", 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 DatabaseAccountsClient) UpdateSQLDatabaseThroughputSender(req *http.Request) (future DatabaseAccountsUpdateSQLDatabaseThroughputFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// UpdateSQLDatabaseThroughputResponder handles the response to the UpdateSQLDatabaseThroughput request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) UpdateSQLDatabaseThroughputResponder(resp *http.Response) (result Throughput, 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 - name of an Azure resource group. -// 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 DatabaseAccountsClient) UpdateTableThroughput(ctx context.Context, resourceGroupName string, accountName string, tableName string, updateThroughputParameters ThroughputUpdateParameters) (result DatabaseAccountsUpdateTableThroughputFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseAccountsClient.UpdateTableThroughput") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.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}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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.ThroughputUpdateProperties", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputUpdateProperties.Resource", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "updateThroughputParameters.ThroughputUpdateProperties.Resource.Throughput", Name: validation.Null, Rule: true, Chain: nil}}}, - }}}}}); err != nil { - return result, validation.NewError("documentdb.DatabaseAccountsClient", "UpdateTableThroughput", err.Error()) - } - - req, err := client.UpdateTableThroughputPreparer(ctx, resourceGroupName, accountName, tableName, updateThroughputParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "UpdateTableThroughput", nil, "Failure preparing request") - return - } - - result, err = client.UpdateTableThroughputSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsClient", "UpdateTableThroughput", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdateTableThroughputPreparer prepares the UpdateTableThroughput request. -func (client DatabaseAccountsClient) UpdateTableThroughputPreparer(ctx context.Context, resourceGroupName string, accountName string, tableName string, updateThroughputParameters ThroughputUpdateParameters) (*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 = "2015-04-08" - 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}/apis/table/tables/{tableName}/settings/throughput", 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 DatabaseAccountsClient) UpdateTableThroughputSender(req *http.Request) (future DatabaseAccountsUpdateTableThroughputFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} - -// UpdateTableThroughputResponder handles the response to the UpdateTableThroughput request. The method always -// closes the http.Response Body. -func (client DatabaseAccountsClient) UpdateTableThroughputResponder(resp *http.Response) (result Throughput, 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/2015-04-08/documentdb/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/models.go deleted file mode 100644 index 16b7c393ebe4..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/models.go +++ /dev/null @@ -1,4021 +0,0 @@ -package documentdb - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// 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/2015-04-08/documentdb" - -// ConflictResolutionMode enumerates the values for conflict resolution mode. -type ConflictResolutionMode string - -const ( - // Custom ... - Custom ConflictResolutionMode = "Custom" - // LastWriterWins ... - LastWriterWins ConflictResolutionMode = "LastWriterWins" -) - -// PossibleConflictResolutionModeValues returns an array of possible values for the ConflictResolutionMode const type. -func PossibleConflictResolutionModeValues() []ConflictResolutionMode { - return []ConflictResolutionMode{Custom, LastWriterWins} -} - -// ConnectorOffer enumerates the values for connector offer. -type ConnectorOffer string - -const ( - // Small ... - Small ConnectorOffer = "Small" -) - -// PossibleConnectorOfferValues returns an array of possible values for the ConnectorOffer const type. -func PossibleConnectorOfferValues() []ConnectorOffer { - return []ConnectorOffer{Small} -} - -// DatabaseAccountKind enumerates the values for database account kind. -type DatabaseAccountKind string - -const ( - // GlobalDocumentDB ... - GlobalDocumentDB DatabaseAccountKind = "GlobalDocumentDB" - // MongoDB ... - MongoDB DatabaseAccountKind = "MongoDB" - // Parse ... - Parse DatabaseAccountKind = "Parse" -) - -// PossibleDatabaseAccountKindValues returns an array of possible values for the DatabaseAccountKind const type. -func PossibleDatabaseAccountKindValues() []DatabaseAccountKind { - return []DatabaseAccountKind{GlobalDocumentDB, MongoDB, Parse} -} - -// DatabaseAccountOfferType enumerates the values for database account offer type. -type DatabaseAccountOfferType string - -const ( - // Standard ... - Standard DatabaseAccountOfferType = "Standard" -) - -// PossibleDatabaseAccountOfferTypeValues returns an array of possible values for the DatabaseAccountOfferType const type. -func PossibleDatabaseAccountOfferTypeValues() []DatabaseAccountOfferType { - return []DatabaseAccountOfferType{Standard} -} - -// DataType enumerates the values for data type. -type DataType string - -const ( - // LineString ... - LineString DataType = "LineString" - // MultiPolygon ... - MultiPolygon DataType = "MultiPolygon" - // Number ... - Number DataType = "Number" - // Point ... - Point DataType = "Point" - // Polygon ... - Polygon DataType = "Polygon" - // String ... - String DataType = "String" -) - -// PossibleDataTypeValues returns an array of possible values for the DataType const type. -func PossibleDataTypeValues() []DataType { - return []DataType{LineString, MultiPolygon, Number, Point, Polygon, String} -} - -// DefaultConsistencyLevel enumerates the values for default consistency level. -type DefaultConsistencyLevel string - -const ( - // BoundedStaleness ... - BoundedStaleness DefaultConsistencyLevel = "BoundedStaleness" - // ConsistentPrefix ... - ConsistentPrefix DefaultConsistencyLevel = "ConsistentPrefix" - // Eventual ... - Eventual DefaultConsistencyLevel = "Eventual" - // Session ... - Session DefaultConsistencyLevel = "Session" - // Strong ... - Strong DefaultConsistencyLevel = "Strong" -) - -// PossibleDefaultConsistencyLevelValues returns an array of possible values for the DefaultConsistencyLevel const type. -func PossibleDefaultConsistencyLevelValues() []DefaultConsistencyLevel { - return []DefaultConsistencyLevel{BoundedStaleness, ConsistentPrefix, Eventual, Session, Strong} -} - -// IndexingMode enumerates the values for indexing mode. -type IndexingMode string - -const ( - // Consistent ... - Consistent IndexingMode = "Consistent" - // Lazy ... - Lazy IndexingMode = "Lazy" - // None ... - None IndexingMode = "None" -) - -// PossibleIndexingModeValues returns an array of possible values for the IndexingMode const type. -func PossibleIndexingModeValues() []IndexingMode { - return []IndexingMode{Consistent, Lazy, None} -} - -// IndexKind enumerates the values for index kind. -type IndexKind string - -const ( - // Hash ... - Hash IndexKind = "Hash" - // Range ... - Range IndexKind = "Range" - // Spatial ... - Spatial IndexKind = "Spatial" -) - -// PossibleIndexKindValues returns an array of possible values for the IndexKind const type. -func PossibleIndexKindValues() []IndexKind { - return []IndexKind{Hash, Range, Spatial} -} - -// KeyKind enumerates the values for key kind. -type KeyKind string - -const ( - // Primary ... - Primary KeyKind = "primary" - // PrimaryReadonly ... - PrimaryReadonly KeyKind = "primaryReadonly" - // Secondary ... - Secondary KeyKind = "secondary" - // SecondaryReadonly ... - SecondaryReadonly KeyKind = "secondaryReadonly" -) - -// PossibleKeyKindValues returns an array of possible values for the KeyKind const type. -func PossibleKeyKindValues() []KeyKind { - return []KeyKind{Primary, PrimaryReadonly, Secondary, SecondaryReadonly} -} - -// PartitionKind enumerates the values for partition kind. -type PartitionKind string - -const ( - // PartitionKindHash ... - PartitionKindHash PartitionKind = "Hash" - // PartitionKindRange ... - PartitionKindRange PartitionKind = "Range" -) - -// PossiblePartitionKindValues returns an array of possible values for the PartitionKind const type. -func PossiblePartitionKindValues() []PartitionKind { - return []PartitionKind{PartitionKindHash, 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} -} - -// UnitType enumerates the values for unit type. -type UnitType string - -const ( - // Bytes ... - Bytes UnitType = "Bytes" - // BytesPerSecond ... - BytesPerSecond UnitType = "BytesPerSecond" - // Count ... - Count UnitType = "Count" - // CountPerSecond ... - CountPerSecond UnitType = "CountPerSecond" - // Milliseconds ... - Milliseconds UnitType = "Milliseconds" - // Percent ... - Percent UnitType = "Percent" - // Seconds ... - Seconds UnitType = "Seconds" -) - -// PossibleUnitTypeValues returns an array of possible values for the UnitType const type. -func PossibleUnitTypeValues() []UnitType { - return []UnitType{Bytes, BytesPerSecond, Count, CountPerSecond, Milliseconds, Percent, Seconds} -} - -// 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"` -} - -// CassandraKeyspace an Azure Cosmos DB Cassandra keyspace. -type CassandraKeyspace struct { - autorest.Response `json:"-"` - // CassandraKeyspaceProperties - The properties of an Azure Cosmos DB Cassandra keyspace - *CassandraKeyspaceProperties `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"` - // 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 CassandraKeyspace. -func (ck CassandraKeyspace) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ck.CassandraKeyspaceProperties != nil { - objectMap["properties"] = ck.CassandraKeyspaceProperties - } - if ck.Location != nil { - objectMap["location"] = ck.Location - } - if ck.Tags != nil { - objectMap["tags"] = ck.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for CassandraKeyspace struct. -func (ck *CassandraKeyspace) 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 cassandraKeyspaceProperties CassandraKeyspaceProperties - err = json.Unmarshal(*v, &cassandraKeyspaceProperties) - if err != nil { - return err - } - ck.CassandraKeyspaceProperties = &cassandraKeyspaceProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - ck.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - ck.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - ck.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - ck.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - ck.Tags = tags - } - } - } - - return nil -} - -// 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"` -} - -// 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 - } - 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 - } - } - } - - 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 map[string]*string `json:"options"` -} - -// MarshalJSON is the custom marshaler for CassandraKeyspaceCreateUpdateProperties. -func (ckcup CassandraKeyspaceCreateUpdateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ckcup.Resource != nil { - objectMap["resource"] = ckcup.Resource - } - if ckcup.Options != nil { - objectMap["options"] = ckcup.Options - } - return json.Marshal(objectMap) -} - -// 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 *[]CassandraKeyspace `json:"value,omitempty"` -} - -// CassandraKeyspaceProperties the properties of an Azure Cosmos DB Cassandra keyspace -type CassandraKeyspaceProperties struct { - // ID - Name of the Cosmos DB Cassandra keyspace - ID *string `json:"id,omitempty"` -} - -// CassandraKeyspaceResource cosmos DB Cassandra keyspace id 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"` -} - -// 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"` -} - -// CassandraTable an Azure Cosmos DB Cassandra table. -type CassandraTable struct { - autorest.Response `json:"-"` - // CassandraTableProperties - The properties of an Azure Cosmos DB Cassandra table - *CassandraTableProperties `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"` - // 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 CassandraTable. -func (ct CassandraTable) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ct.CassandraTableProperties != nil { - objectMap["properties"] = ct.CassandraTableProperties - } - if ct.Location != nil { - objectMap["location"] = ct.Location - } - if ct.Tags != nil { - objectMap["tags"] = ct.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for CassandraTable struct. -func (ct *CassandraTable) 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 cassandraTableProperties CassandraTableProperties - err = json.Unmarshal(*v, &cassandraTableProperties) - if err != nil { - return err - } - ct.CassandraTableProperties = &cassandraTableProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - ct.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - ct.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - ct.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - ct.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - ct.Tags = tags - } - } - } - - return nil -} - -// 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"` -} - -// 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 - } - 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 - } - } - } - - 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 map[string]*string `json:"options"` -} - -// MarshalJSON is the custom marshaler for CassandraTableCreateUpdateProperties. -func (ctcup CassandraTableCreateUpdateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ctcup.Resource != nil { - objectMap["resource"] = ctcup.Resource - } - if ctcup.Options != nil { - objectMap["options"] = ctcup.Options - } - return json.Marshal(objectMap) -} - -// 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 *[]CassandraTable `json:"value,omitempty"` -} - -// CassandraTableProperties the properties of an Azure Cosmos DB Cassandra table -type CassandraTableProperties 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"` -} - -// CassandraTableResource cosmos DB Cassandra table id 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"` -} - -// 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"` -} - -// 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"` -} - -// ConflictResolutionPolicy the conflict resolution policy for the container. -type ConflictResolutionPolicy struct { - // Mode - Indicates the conflict resolution mode. Possible values include: 'LastWriterWins', 'Custom' - 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"` -} - -// 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: 'Eventual', 'Session', 'BoundedStaleness', 'Strong', 'ConsistentPrefix' - 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. Possible values include: 'PartitionKindHash', 'PartitionKindRange' - Kind PartitionKind `json:"kind,omitempty"` -} - -// DatabaseAccount an Azure Cosmos DB database account. -type DatabaseAccount struct { - autorest.Response `json:"-"` - // Kind - Indicates the type of database account. This can only be set at database account creation. Possible values include: 'GlobalDocumentDB', 'MongoDB', 'Parse' - Kind DatabaseAccountKind `json:"kind,omitempty"` - *DatabaseAccountProperties `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"` - // 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 DatabaseAccount. -func (da DatabaseAccount) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if da.Kind != "" { - objectMap["kind"] = da.Kind - } - if da.DatabaseAccountProperties != nil { - objectMap["properties"] = da.DatabaseAccountProperties - } - if da.Location != nil { - objectMap["location"] = da.Location - } - if da.Tags != nil { - objectMap["tags"] = da.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for DatabaseAccount struct. -func (da *DatabaseAccount) 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 - } - da.Kind = kind - } - case "properties": - if v != nil { - var databaseAccountProperties DatabaseAccountProperties - err = json.Unmarshal(*v, &databaseAccountProperties) - if err != nil { - return err - } - da.DatabaseAccountProperties = &databaseAccountProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - da.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - da.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - da.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - da.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - da.Tags = tags - } - } - } - - return nil -} - -// 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"` -} - -// 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: 'GlobalDocumentDB', 'MongoDB', 'Parse' - Kind DatabaseAccountKind `json:"kind,omitempty"` - *DatabaseAccountCreateUpdateProperties `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"` - // 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.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 "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"` - // IPRangeFilter - Cosmos DB Firewall Support: This value specifies the set of IP addresses or IP address ranges in CIDR form to be included as the allowed list of client IPs for a given database account. IP addresses/ranges must be comma separated and must not contain any spaces. - IPRangeFilter *string `json:"ipRangeFilter,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: 'Small' - ConnectorOffer ConnectorOffer `json:"connectorOffer,omitempty"` -} - -// 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"` -} - -// 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"` -} - -// DatabaseAccountPatchParameters parameters for patching Azure Cosmos DB database account properties. -type DatabaseAccountPatchParameters struct { - Tags map[string]*string `json:"tags"` - *DatabaseAccountPatchProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for DatabaseAccountPatchParameters. -func (dapp DatabaseAccountPatchParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if dapp.Tags != nil { - objectMap["tags"] = dapp.Tags - } - if dapp.DatabaseAccountPatchProperties != nil { - objectMap["properties"] = dapp.DatabaseAccountPatchProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for DatabaseAccountPatchParameters struct. -func (dapp *DatabaseAccountPatchParameters) 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 - } - dapp.Tags = tags - } - case "properties": - if v != nil { - var databaseAccountPatchProperties DatabaseAccountPatchProperties - err = json.Unmarshal(*v, &databaseAccountPatchProperties) - if err != nil { - return err - } - dapp.DatabaseAccountPatchProperties = &databaseAccountPatchProperties - } - } - } - - return nil -} - -// DatabaseAccountPatchProperties properties to update Azure Cosmos DB database accounts. -type DatabaseAccountPatchProperties struct { - // Capabilities - List of Cosmos DB capabilities for the account - Capabilities *[]Capability `json:"capabilities,omitempty"` -} - -// DatabaseAccountProperties properties for the database account. -type DatabaseAccountProperties 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: 'Standard' - DatabaseAccountOfferType DatabaseAccountOfferType `json:"databaseAccountOfferType,omitempty"` - // IPRangeFilter - Cosmos DB Firewall Support: This value specifies the set of IP addresses or IP address ranges in CIDR form to be included as the allowed list of client IPs for a given database account. IP addresses/ranges must be comma separated and must not contain any spaces. - IPRangeFilter *string `json:"ipRangeFilter,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"` - // 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"` - // 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: 'Small' - ConnectorOffer ConnectorOffer `json:"connectorOffer,omitempty"` -} - -// DatabaseAccountRegenerateKeyParameters parameters to regenerate the keys within the database account. -type DatabaseAccountRegenerateKeyParameters struct { - // KeyKind - The access key to regenerate. Possible values include: 'Primary', 'Secondary', 'PrimaryReadonly', 'SecondaryReadonly' - KeyKind KeyKind `json:"keyKind,omitempty"` -} - -// DatabaseAccountsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type DatabaseAccountsCreateOrUpdateFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsCreateOrUpdateFuture) Result(client DatabaseAccountsClient) (da DatabaseAccount, 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 { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsCreateOrUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if da.Response.Response, err = future.GetResult(sender); err == nil && da.Response.Response.StatusCode != http.StatusNoContent { - da, err = client.CreateOrUpdateResponder(da.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateOrUpdateFuture", "Result", da.Response.Response, "Failure responding to request") - } - } - return -} - -// DatabaseAccountsCreateUpdateCassandraKeyspaceFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type DatabaseAccountsCreateUpdateCassandraKeyspaceFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsCreateUpdateCassandraKeyspaceFuture) Result(client DatabaseAccountsClient) (ck CassandraKeyspace, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateUpdateCassandraKeyspaceFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsCreateUpdateCassandraKeyspaceFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if ck.Response.Response, err = future.GetResult(sender); err == nil && ck.Response.Response.StatusCode != http.StatusNoContent { - ck, err = client.CreateUpdateCassandraKeyspaceResponder(ck.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateUpdateCassandraKeyspaceFuture", "Result", ck.Response.Response, "Failure responding to request") - } - } - return -} - -// DatabaseAccountsCreateUpdateCassandraTableFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type DatabaseAccountsCreateUpdateCassandraTableFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsCreateUpdateCassandraTableFuture) Result(client DatabaseAccountsClient) (ct CassandraTable, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateUpdateCassandraTableFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsCreateUpdateCassandraTableFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if ct.Response.Response, err = future.GetResult(sender); err == nil && ct.Response.Response.StatusCode != http.StatusNoContent { - ct, err = client.CreateUpdateCassandraTableResponder(ct.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateUpdateCassandraTableFuture", "Result", ct.Response.Response, "Failure responding to request") - } - } - return -} - -// DatabaseAccountsCreateUpdateGremlinDatabaseFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type DatabaseAccountsCreateUpdateGremlinDatabaseFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsCreateUpdateGremlinDatabaseFuture) Result(client DatabaseAccountsClient) (gd GremlinDatabase, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateUpdateGremlinDatabaseFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsCreateUpdateGremlinDatabaseFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if gd.Response.Response, err = future.GetResult(sender); err == nil && gd.Response.Response.StatusCode != http.StatusNoContent { - gd, err = client.CreateUpdateGremlinDatabaseResponder(gd.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateUpdateGremlinDatabaseFuture", "Result", gd.Response.Response, "Failure responding to request") - } - } - return -} - -// DatabaseAccountsCreateUpdateGremlinGraphFuture an abstraction for monitoring and retrieving the results -// of a long-running operation. -type DatabaseAccountsCreateUpdateGremlinGraphFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsCreateUpdateGremlinGraphFuture) Result(client DatabaseAccountsClient) (gg GremlinGraph, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateUpdateGremlinGraphFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsCreateUpdateGremlinGraphFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if gg.Response.Response, err = future.GetResult(sender); err == nil && gg.Response.Response.StatusCode != http.StatusNoContent { - gg, err = client.CreateUpdateGremlinGraphResponder(gg.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateUpdateGremlinGraphFuture", "Result", gg.Response.Response, "Failure responding to request") - } - } - return -} - -// DatabaseAccountsCreateUpdateMongoDBCollectionFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type DatabaseAccountsCreateUpdateMongoDBCollectionFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsCreateUpdateMongoDBCollectionFuture) Result(client DatabaseAccountsClient) (mdc MongoDBCollection, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateUpdateMongoDBCollectionFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsCreateUpdateMongoDBCollectionFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if mdc.Response.Response, err = future.GetResult(sender); err == nil && mdc.Response.Response.StatusCode != http.StatusNoContent { - mdc, err = client.CreateUpdateMongoDBCollectionResponder(mdc.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateUpdateMongoDBCollectionFuture", "Result", mdc.Response.Response, "Failure responding to request") - } - } - return -} - -// DatabaseAccountsCreateUpdateMongoDBDatabaseFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type DatabaseAccountsCreateUpdateMongoDBDatabaseFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsCreateUpdateMongoDBDatabaseFuture) Result(client DatabaseAccountsClient) (mdd MongoDBDatabase, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateUpdateMongoDBDatabaseFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsCreateUpdateMongoDBDatabaseFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if mdd.Response.Response, err = future.GetResult(sender); err == nil && mdd.Response.Response.StatusCode != http.StatusNoContent { - mdd, err = client.CreateUpdateMongoDBDatabaseResponder(mdd.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateUpdateMongoDBDatabaseFuture", "Result", mdd.Response.Response, "Failure responding to request") - } - } - return -} - -// DatabaseAccountsCreateUpdateSQLContainerFuture an abstraction for monitoring and retrieving the results -// of a long-running operation. -type DatabaseAccountsCreateUpdateSQLContainerFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsCreateUpdateSQLContainerFuture) Result(client DatabaseAccountsClient) (sc SQLContainer, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateUpdateSQLContainerFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsCreateUpdateSQLContainerFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if sc.Response.Response, err = future.GetResult(sender); err == nil && sc.Response.Response.StatusCode != http.StatusNoContent { - sc, err = client.CreateUpdateSQLContainerResponder(sc.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateUpdateSQLContainerFuture", "Result", sc.Response.Response, "Failure responding to request") - } - } - return -} - -// DatabaseAccountsCreateUpdateSQLDatabaseFuture an abstraction for monitoring and retrieving the results -// of a long-running operation. -type DatabaseAccountsCreateUpdateSQLDatabaseFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsCreateUpdateSQLDatabaseFuture) Result(client DatabaseAccountsClient) (sd SQLDatabase, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateUpdateSQLDatabaseFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsCreateUpdateSQLDatabaseFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if sd.Response.Response, err = future.GetResult(sender); err == nil && sd.Response.Response.StatusCode != http.StatusNoContent { - sd, err = client.CreateUpdateSQLDatabaseResponder(sd.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateUpdateSQLDatabaseFuture", "Result", sd.Response.Response, "Failure responding to request") - } - } - return -} - -// DatabaseAccountsCreateUpdateTableFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type DatabaseAccountsCreateUpdateTableFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsCreateUpdateTableFuture) Result(client DatabaseAccountsClient) (t Table, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateUpdateTableFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsCreateUpdateTableFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if t.Response.Response, err = future.GetResult(sender); err == nil && t.Response.Response.StatusCode != http.StatusNoContent { - t, err = client.CreateUpdateTableResponder(t.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsCreateUpdateTableFuture", "Result", t.Response.Response, "Failure responding to request") - } - } - return -} - -// DatabaseAccountsDeleteCassandraKeyspaceFuture an abstraction for monitoring and retrieving the results -// of a long-running operation. -type DatabaseAccountsDeleteCassandraKeyspaceFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsDeleteCassandraKeyspaceFuture) 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.DatabaseAccountsDeleteCassandraKeyspaceFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsDeleteCassandraKeyspaceFuture") - return - } - ar.Response = future.Response() - return -} - -// DatabaseAccountsDeleteCassandraTableFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type DatabaseAccountsDeleteCassandraTableFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsDeleteCassandraTableFuture) 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.DatabaseAccountsDeleteCassandraTableFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsDeleteCassandraTableFuture") - return - } - ar.Response = future.Response() - return -} - -// DatabaseAccountsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type DatabaseAccountsDeleteFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -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 { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsDeleteFuture") - return - } - ar.Response = future.Response() - return -} - -// DatabaseAccountsDeleteGremlinDatabaseFuture an abstraction for monitoring and retrieving the results of -// a long-running operation. -type DatabaseAccountsDeleteGremlinDatabaseFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsDeleteGremlinDatabaseFuture) 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.DatabaseAccountsDeleteGremlinDatabaseFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsDeleteGremlinDatabaseFuture") - return - } - ar.Response = future.Response() - return -} - -// DatabaseAccountsDeleteGremlinGraphFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type DatabaseAccountsDeleteGremlinGraphFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsDeleteGremlinGraphFuture) 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.DatabaseAccountsDeleteGremlinGraphFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsDeleteGremlinGraphFuture") - return - } - ar.Response = future.Response() - return -} - -// DatabaseAccountsDeleteMongoDBCollectionFuture an abstraction for monitoring and retrieving the results -// of a long-running operation. -type DatabaseAccountsDeleteMongoDBCollectionFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsDeleteMongoDBCollectionFuture) 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.DatabaseAccountsDeleteMongoDBCollectionFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsDeleteMongoDBCollectionFuture") - return - } - ar.Response = future.Response() - return -} - -// DatabaseAccountsDeleteMongoDBDatabaseFuture an abstraction for monitoring and retrieving the results of -// a long-running operation. -type DatabaseAccountsDeleteMongoDBDatabaseFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsDeleteMongoDBDatabaseFuture) 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.DatabaseAccountsDeleteMongoDBDatabaseFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsDeleteMongoDBDatabaseFuture") - return - } - ar.Response = future.Response() - return -} - -// DatabaseAccountsDeleteSQLContainerFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type DatabaseAccountsDeleteSQLContainerFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsDeleteSQLContainerFuture) 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.DatabaseAccountsDeleteSQLContainerFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsDeleteSQLContainerFuture") - return - } - ar.Response = future.Response() - return -} - -// DatabaseAccountsDeleteSQLDatabaseFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type DatabaseAccountsDeleteSQLDatabaseFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsDeleteSQLDatabaseFuture) 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.DatabaseAccountsDeleteSQLDatabaseFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsDeleteSQLDatabaseFuture") - return - } - ar.Response = future.Response() - return -} - -// DatabaseAccountsDeleteTableFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type DatabaseAccountsDeleteTableFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsDeleteTableFuture) 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.DatabaseAccountsDeleteTableFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsDeleteTableFuture") - return - } - ar.Response = future.Response() - return -} - -// DatabaseAccountsFailoverPriorityChangeFuture an abstraction for monitoring and retrieving the results of -// a long-running operation. -type DatabaseAccountsFailoverPriorityChangeFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -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 { - 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 *[]DatabaseAccount `json:"value,omitempty"` -} - -// DatabaseAccountsOfflineRegionFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type DatabaseAccountsOfflineRegionFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -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 { - 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.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -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 { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsOnlineRegionFuture") - return - } - ar.Response = future.Response() - return -} - -// DatabaseAccountsPatchFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type DatabaseAccountsPatchFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsPatchFuture) Result(client DatabaseAccountsClient) (da DatabaseAccount, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsPatchFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsPatchFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if da.Response.Response, err = future.GetResult(sender); err == nil && da.Response.Response.StatusCode != http.StatusNoContent { - da, err = client.PatchResponder(da.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsPatchFuture", "Result", da.Response.Response, "Failure responding to request") - } - } - return -} - -// DatabaseAccountsRegenerateKeyFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type DatabaseAccountsRegenerateKeyFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -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 { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsRegenerateKeyFuture") - return - } - ar.Response = future.Response() - return -} - -// DatabaseAccountsUpdateCassandraKeyspaceThroughputFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type DatabaseAccountsUpdateCassandraKeyspaceThroughputFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsUpdateCassandraKeyspaceThroughputFuture) Result(client DatabaseAccountsClient) (t Throughput, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateCassandraKeyspaceThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsUpdateCassandraKeyspaceThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if t.Response.Response, err = future.GetResult(sender); err == nil && t.Response.Response.StatusCode != http.StatusNoContent { - t, err = client.UpdateCassandraKeyspaceThroughputResponder(t.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateCassandraKeyspaceThroughputFuture", "Result", t.Response.Response, "Failure responding to request") - } - } - return -} - -// DatabaseAccountsUpdateCassandraTableThroughputFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type DatabaseAccountsUpdateCassandraTableThroughputFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsUpdateCassandraTableThroughputFuture) Result(client DatabaseAccountsClient) (t Throughput, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateCassandraTableThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsUpdateCassandraTableThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if t.Response.Response, err = future.GetResult(sender); err == nil && t.Response.Response.StatusCode != http.StatusNoContent { - t, err = client.UpdateCassandraTableThroughputResponder(t.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateCassandraTableThroughputFuture", "Result", t.Response.Response, "Failure responding to request") - } - } - return -} - -// DatabaseAccountsUpdateGremlinDatabaseThroughputFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type DatabaseAccountsUpdateGremlinDatabaseThroughputFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsUpdateGremlinDatabaseThroughputFuture) Result(client DatabaseAccountsClient) (t Throughput, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateGremlinDatabaseThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsUpdateGremlinDatabaseThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if t.Response.Response, err = future.GetResult(sender); err == nil && t.Response.Response.StatusCode != http.StatusNoContent { - t, err = client.UpdateGremlinDatabaseThroughputResponder(t.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateGremlinDatabaseThroughputFuture", "Result", t.Response.Response, "Failure responding to request") - } - } - return -} - -// DatabaseAccountsUpdateGremlinGraphThroughputFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type DatabaseAccountsUpdateGremlinGraphThroughputFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsUpdateGremlinGraphThroughputFuture) Result(client DatabaseAccountsClient) (t Throughput, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateGremlinGraphThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsUpdateGremlinGraphThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if t.Response.Response, err = future.GetResult(sender); err == nil && t.Response.Response.StatusCode != http.StatusNoContent { - t, err = client.UpdateGremlinGraphThroughputResponder(t.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateGremlinGraphThroughputFuture", "Result", t.Response.Response, "Failure responding to request") - } - } - return -} - -// DatabaseAccountsUpdateMongoDBCollectionThroughputFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type DatabaseAccountsUpdateMongoDBCollectionThroughputFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsUpdateMongoDBCollectionThroughputFuture) Result(client DatabaseAccountsClient) (t Throughput, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateMongoDBCollectionThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsUpdateMongoDBCollectionThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if t.Response.Response, err = future.GetResult(sender); err == nil && t.Response.Response.StatusCode != http.StatusNoContent { - t, err = client.UpdateMongoDBCollectionThroughputResponder(t.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateMongoDBCollectionThroughputFuture", "Result", t.Response.Response, "Failure responding to request") - } - } - return -} - -// DatabaseAccountsUpdateMongoDBDatabaseThroughputFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type DatabaseAccountsUpdateMongoDBDatabaseThroughputFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsUpdateMongoDBDatabaseThroughputFuture) Result(client DatabaseAccountsClient) (t Throughput, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateMongoDBDatabaseThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsUpdateMongoDBDatabaseThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if t.Response.Response, err = future.GetResult(sender); err == nil && t.Response.Response.StatusCode != http.StatusNoContent { - t, err = client.UpdateMongoDBDatabaseThroughputResponder(t.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateMongoDBDatabaseThroughputFuture", "Result", t.Response.Response, "Failure responding to request") - } - } - return -} - -// DatabaseAccountsUpdateSQLContainerThroughputFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type DatabaseAccountsUpdateSQLContainerThroughputFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsUpdateSQLContainerThroughputFuture) Result(client DatabaseAccountsClient) (t Throughput, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateSQLContainerThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsUpdateSQLContainerThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if t.Response.Response, err = future.GetResult(sender); err == nil && t.Response.Response.StatusCode != http.StatusNoContent { - t, err = client.UpdateSQLContainerThroughputResponder(t.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateSQLContainerThroughputFuture", "Result", t.Response.Response, "Failure responding to request") - } - } - return -} - -// DatabaseAccountsUpdateSQLDatabaseThroughputFuture an abstraction for monitoring and retrieving the -// results of a long-running operation. -type DatabaseAccountsUpdateSQLDatabaseThroughputFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsUpdateSQLDatabaseThroughputFuture) Result(client DatabaseAccountsClient) (t Throughput, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateSQLDatabaseThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsUpdateSQLDatabaseThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if t.Response.Response, err = future.GetResult(sender); err == nil && t.Response.Response.StatusCode != http.StatusNoContent { - t, err = client.UpdateSQLDatabaseThroughputResponder(t.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateSQLDatabaseThroughputFuture", "Result", t.Response.Response, "Failure responding to request") - } - } - return -} - -// DatabaseAccountsUpdateTableThroughputFuture an abstraction for monitoring and retrieving the results of -// a long-running operation. -type DatabaseAccountsUpdateTableThroughputFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *DatabaseAccountsUpdateTableThroughputFuture) Result(client DatabaseAccountsClient) (t Throughput, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateTableThroughputFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("documentdb.DatabaseAccountsUpdateTableThroughputFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if t.Response.Response, err = future.GetResult(sender); err == nil && t.Response.Response.StatusCode != http.StatusNoContent { - t, err = client.UpdateTableThroughputResponder(t.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "documentdb.DatabaseAccountsUpdateTableThroughputFuture", "Result", t.Response.Response, "Failure responding to request") - } - } - return -} - -// 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 and -// SQL containers. -type ExtendedResourceProperties struct { - // Rid - A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // Ts - A system generated property that denotes the last updated timestamp of the resource. - Ts interface{} `json:"_ts,omitempty"` - // Etag - A system generated property representing the resource etag required for optimistic concurrency control. - Etag *string `json:"_etag,omitempty"` -} - -// 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"` -} - -// GremlinDatabase an Azure Cosmos DB Gremlin database. -type GremlinDatabase struct { - autorest.Response `json:"-"` - // GremlinDatabaseProperties - The properties of an Azure Cosmos DB SQL database - *GremlinDatabaseProperties `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"` - // 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 GremlinDatabase. -func (gd GremlinDatabase) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if gd.GremlinDatabaseProperties != nil { - objectMap["properties"] = gd.GremlinDatabaseProperties - } - if gd.Location != nil { - objectMap["location"] = gd.Location - } - if gd.Tags != nil { - objectMap["tags"] = gd.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for GremlinDatabase struct. -func (gd *GremlinDatabase) 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 gremlinDatabaseProperties GremlinDatabaseProperties - err = json.Unmarshal(*v, &gremlinDatabaseProperties) - if err != nil { - return err - } - gd.GremlinDatabaseProperties = &gremlinDatabaseProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - gd.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - gd.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - gd.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - gd.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - gd.Tags = tags - } - } - } - - return nil -} - -// 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"` -} - -// 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 - } - 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 - } - } - } - - 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 map[string]*string `json:"options"` -} - -// MarshalJSON is the custom marshaler for GremlinDatabaseCreateUpdateProperties. -func (gdcup GremlinDatabaseCreateUpdateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if gdcup.Resource != nil { - objectMap["resource"] = gdcup.Resource - } - if gdcup.Options != nil { - objectMap["options"] = gdcup.Options - } - return json.Marshal(objectMap) -} - -// 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 *[]GremlinDatabase `json:"value,omitempty"` -} - -// GremlinDatabaseProperties the properties of an Azure Cosmos DB SQL database -type GremlinDatabaseProperties struct { - // Rid - A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // Ts - A system generated property that denotes the last updated timestamp of the resource. - Ts interface{} `json:"_ts,omitempty"` - // Etag - A system generated property representing the resource etag required for optimistic concurrency control. - Etag *string `json:"_etag,omitempty"` - // ID - Name of the Cosmos DB Gremlin database - ID *string `json:"id,omitempty"` -} - -// GremlinDatabaseResource cosmos DB Gremlin database id object -type GremlinDatabaseResource struct { - // ID - Name of the Cosmos DB Gremlin database - ID *string `json:"id,omitempty"` -} - -// GremlinGraph an Azure Cosmos DB Gremlin graph. -type GremlinGraph struct { - autorest.Response `json:"-"` - // GremlinGraphProperties - The properties of an Azure Cosmos DB Gremlin graph - *GremlinGraphProperties `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"` - // 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 GremlinGraph. -func (gg GremlinGraph) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if gg.GremlinGraphProperties != nil { - objectMap["properties"] = gg.GremlinGraphProperties - } - if gg.Location != nil { - objectMap["location"] = gg.Location - } - if gg.Tags != nil { - objectMap["tags"] = gg.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for GremlinGraph struct. -func (gg *GremlinGraph) 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 gremlinGraphProperties GremlinGraphProperties - err = json.Unmarshal(*v, &gremlinGraphProperties) - if err != nil { - return err - } - gg.GremlinGraphProperties = &gremlinGraphProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - gg.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - gg.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - gg.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - gg.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - gg.Tags = tags - } - } - } - - return nil -} - -// 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"` -} - -// 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 - } - 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 - } - } - } - - 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 map[string]*string `json:"options"` -} - -// MarshalJSON is the custom marshaler for GremlinGraphCreateUpdateProperties. -func (ggcup GremlinGraphCreateUpdateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ggcup.Resource != nil { - objectMap["resource"] = ggcup.Resource - } - if ggcup.Options != nil { - objectMap["options"] = ggcup.Options - } - return json.Marshal(objectMap) -} - -// 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 *[]GremlinGraph `json:"value,omitempty"` -} - -// GremlinGraphProperties the properties of an Azure Cosmos DB Gremlin graph -type GremlinGraphProperties 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 - A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // Ts - A system generated property that denotes the last updated timestamp of the resource. - Ts interface{} `json:"_ts,omitempty"` - // Etag - A system generated property representing the resource etag required for optimistic concurrency control. - Etag *string `json:"_etag,omitempty"` -} - -// 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"` -} - -// 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: 'String', 'Number', 'Point', 'Polygon', 'LineString', 'MultiPolygon' - 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: 'Hash', 'Range', 'Spatial' - 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: 'Consistent', 'Lazy', 'None' - 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"` -} - -// 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"` -} - -// 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: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', 'BytesPerSecond', 'Milliseconds' - 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"` -} - -// 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"` -} - -// 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: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', 'BytesPerSecond', 'Milliseconds' - 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"` -} - -// 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"` -} - -// 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"` -} - -// 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"` -} - -// 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"` -} - -// MongoDBCollection an Azure Cosmos DB MongoDB collection. -type MongoDBCollection struct { - autorest.Response `json:"-"` - // MongoDBCollectionProperties - The properties of an Azure Cosmos DB MongoDB collection - *MongoDBCollectionProperties `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"` - // 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 MongoDBCollection. -func (mdc MongoDBCollection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mdc.MongoDBCollectionProperties != nil { - objectMap["properties"] = mdc.MongoDBCollectionProperties - } - if mdc.Location != nil { - objectMap["location"] = mdc.Location - } - if mdc.Tags != nil { - objectMap["tags"] = mdc.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for MongoDBCollection struct. -func (mdc *MongoDBCollection) 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 mongoDBCollectionProperties MongoDBCollectionProperties - err = json.Unmarshal(*v, &mongoDBCollectionProperties) - if err != nil { - return err - } - mdc.MongoDBCollectionProperties = &mongoDBCollectionProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - mdc.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - mdc.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - mdc.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - mdc.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - mdc.Tags = tags - } - } - } - - return nil -} - -// 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"` -} - -// 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 - } - 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 - } - } - } - - 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 map[string]*string `json:"options"` -} - -// MarshalJSON is the custom marshaler for MongoDBCollectionCreateUpdateProperties. -func (mdccup MongoDBCollectionCreateUpdateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mdccup.Resource != nil { - objectMap["resource"] = mdccup.Resource - } - if mdccup.Options != nil { - objectMap["options"] = mdccup.Options - } - return json.Marshal(objectMap) -} - -// 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 *[]MongoDBCollection `json:"value,omitempty"` -} - -// MongoDBCollectionProperties the properties of an Azure Cosmos DB MongoDB collection -type MongoDBCollectionProperties 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"` -} - -// MarshalJSON is the custom marshaler for MongoDBCollectionProperties. -func (mdcp MongoDBCollectionProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mdcp.ID != nil { - objectMap["id"] = mdcp.ID - } - if mdcp.ShardKey != nil { - objectMap["shardKey"] = mdcp.ShardKey - } - if mdcp.Indexes != nil { - objectMap["indexes"] = mdcp.Indexes - } - 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"` -} - -// 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 - } - return json.Marshal(objectMap) -} - -// MongoDBDatabase an Azure Cosmos DB MongoDB database. -type MongoDBDatabase struct { - autorest.Response `json:"-"` - // MongoDBDatabaseProperties - The properties of an Azure Cosmos DB MongoDB database - *MongoDBDatabaseProperties `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"` - // 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 MongoDBDatabase. -func (mdd MongoDBDatabase) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mdd.MongoDBDatabaseProperties != nil { - objectMap["properties"] = mdd.MongoDBDatabaseProperties - } - if mdd.Location != nil { - objectMap["location"] = mdd.Location - } - if mdd.Tags != nil { - objectMap["tags"] = mdd.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for MongoDBDatabase struct. -func (mdd *MongoDBDatabase) 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 mongoDBDatabaseProperties MongoDBDatabaseProperties - err = json.Unmarshal(*v, &mongoDBDatabaseProperties) - if err != nil { - return err - } - mdd.MongoDBDatabaseProperties = &mongoDBDatabaseProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - mdd.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - mdd.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - mdd.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - mdd.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - mdd.Tags = tags - } - } - } - - return nil -} - -// 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"` -} - -// 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 - } - 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 - } - } - } - - 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 map[string]*string `json:"options"` -} - -// MarshalJSON is the custom marshaler for MongoDBDatabaseCreateUpdateProperties. -func (mddcup MongoDBDatabaseCreateUpdateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mddcup.Resource != nil { - objectMap["resource"] = mddcup.Resource - } - if mddcup.Options != nil { - objectMap["options"] = mddcup.Options - } - return json.Marshal(objectMap) -} - -// 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 *[]MongoDBDatabase `json:"value,omitempty"` -} - -// MongoDBDatabaseProperties the properties of an Azure Cosmos DB MongoDB database -type MongoDBDatabaseProperties struct { - // ID - Name of the Cosmos DB MongoDB database - ID *string `json:"id,omitempty"` -} - -// MongoDBDatabaseResource cosmos DB MongoDB database id object -type MongoDBDatabaseResource struct { - // ID - Name of the Cosmos DB MongoDB database - ID *string `json:"id,omitempty"` -} - -// 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"` -} - -// 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 -} - -// 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.NextLink == nil || len(to.String(olr.NextLink)) < 1 { - 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) - }() - } - next, err := page.fn(ctx, page.olr) - if err != nil { - return err - } - page.olr = next - 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(getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { - return OperationListResultPage{fn: getNextPage} -} - -// 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: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', 'BytesPerSecond', 'Milliseconds' - 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"` -} - -// 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"` -} - -// 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: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', 'BytesPerSecond', 'Milliseconds' - 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"` -} - -// 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"` -} - -// 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: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', 'BytesPerSecond', 'Milliseconds' - 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"` -} - -// 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"` -} - -// 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"` -} - -// 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 the core properties of ARM resources. -type Resource 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"` - // 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 Resource. -func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if r.Location != nil { - objectMap["location"] = r.Location - } - if r.Tags != nil { - objectMap["tags"] = r.Tags - } - return json.Marshal(objectMap) -} - -// SQLContainer an Azure Cosmos DB container. -type SQLContainer struct { - autorest.Response `json:"-"` - // SQLContainerProperties - The properties of an Azure Cosmos DB container - *SQLContainerProperties `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"` - // 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 SQLContainer. -func (sc SQLContainer) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if sc.SQLContainerProperties != nil { - objectMap["properties"] = sc.SQLContainerProperties - } - if sc.Location != nil { - objectMap["location"] = sc.Location - } - if sc.Tags != nil { - objectMap["tags"] = sc.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for SQLContainer struct. -func (sc *SQLContainer) 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 SQLContainerProperties SQLContainerProperties - err = json.Unmarshal(*v, &SQLContainerProperties) - if err != nil { - return err - } - sc.SQLContainerProperties = &SQLContainerProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - sc.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - sc.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - sc.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - sc.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - sc.Tags = tags - } - } - } - - return nil -} - -// 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"` -} - -// 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 - } - 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 - } - } - } - - 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 map[string]*string `json:"options"` -} - -// MarshalJSON is the custom marshaler for SQLContainerCreateUpdateProperties. -func (sccup SQLContainerCreateUpdateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if sccup.Resource != nil { - objectMap["resource"] = sccup.Resource - } - if sccup.Options != nil { - objectMap["options"] = sccup.Options - } - return json.Marshal(objectMap) -} - -// 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 *[]SQLContainer `json:"value,omitempty"` -} - -// SQLContainerProperties the properties of an Azure Cosmos DB container -type SQLContainerProperties 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"` - // Rid - A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // Ts - A system generated property that denotes the last updated timestamp of the resource. - Ts interface{} `json:"_ts,omitempty"` - // Etag - A system generated property representing the resource etag required for optimistic concurrency control. - Etag *string `json:"_etag,omitempty"` -} - -// 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"` -} - -// SQLDatabase an Azure Cosmos DB SQL database. -type SQLDatabase struct { - autorest.Response `json:"-"` - // SQLDatabaseProperties - The properties of an Azure Cosmos DB SQL database - *SQLDatabaseProperties `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"` - // 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 SQLDatabase. -func (sd SQLDatabase) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if sd.SQLDatabaseProperties != nil { - objectMap["properties"] = sd.SQLDatabaseProperties - } - if sd.Location != nil { - objectMap["location"] = sd.Location - } - if sd.Tags != nil { - objectMap["tags"] = sd.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for SQLDatabase struct. -func (sd *SQLDatabase) 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 SQLDatabaseProperties SQLDatabaseProperties - err = json.Unmarshal(*v, &SQLDatabaseProperties) - if err != nil { - return err - } - sd.SQLDatabaseProperties = &SQLDatabaseProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - sd.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - sd.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - sd.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - sd.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - sd.Tags = tags - } - } - } - - return nil -} - -// 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"` -} - -// 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 - } - 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 - } - } - } - - 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 map[string]*string `json:"options"` -} - -// MarshalJSON is the custom marshaler for SQLDatabaseCreateUpdateProperties. -func (sdcup SQLDatabaseCreateUpdateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if sdcup.Resource != nil { - objectMap["resource"] = sdcup.Resource - } - if sdcup.Options != nil { - objectMap["options"] = sdcup.Options - } - return json.Marshal(objectMap) -} - -// 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 *[]SQLDatabase `json:"value,omitempty"` -} - -// SQLDatabaseProperties the properties of an Azure Cosmos DB SQL database -type SQLDatabaseProperties struct { - // ID - Name of the Cosmos DB SQL database - ID *string `json:"id,omitempty"` - // Rid - A system generated property. A unique identifier. - Rid *string `json:"_rid,omitempty"` - // Ts - A system generated property that denotes the last updated timestamp of the resource. - Ts interface{} `json:"_ts,omitempty"` - // Etag - 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"` -} - -// SQLDatabaseResource cosmos DB SQL database id object -type SQLDatabaseResource struct { - // ID - Name of the Cosmos DB SQL database - ID *string `json:"id,omitempty"` -} - -// Table an Azure Cosmos DB Table. -type Table struct { - autorest.Response `json:"-"` - // TableProperties - The properties of an Azure Cosmos DB Table - *TableProperties `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"` - // 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 Table. -func (t Table) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if t.TableProperties != nil { - objectMap["properties"] = t.TableProperties - } - if t.Location != nil { - objectMap["location"] = t.Location - } - if t.Tags != nil { - objectMap["tags"] = t.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for Table struct. -func (t *Table) 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 tableProperties TableProperties - err = json.Unmarshal(*v, &tableProperties) - if err != nil { - return err - } - t.TableProperties = &tableProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - t.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - t.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - t.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - t.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - t.Tags = tags - } - } - } - - return nil -} - -// 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"` -} - -// 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 - } - 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 - } - } - } - - 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 map[string]*string `json:"options"` -} - -// MarshalJSON is the custom marshaler for TableCreateUpdateProperties. -func (tcup TableCreateUpdateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if tcup.Resource != nil { - objectMap["resource"] = tcup.Resource - } - if tcup.Options != nil { - objectMap["options"] = tcup.Options - } - return json.Marshal(objectMap) -} - -// 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 *[]Table `json:"value,omitempty"` -} - -// TableProperties the properties of an Azure Cosmos Table -type TableProperties struct { - // ID - Name of the Cosmos DB table - ID *string `json:"id,omitempty"` -} - -// TableResource cosmos DB table id object -type TableResource struct { - // ID - Name of the Cosmos DB table - ID *string `json:"id,omitempty"` -} - -// Throughput an Azure Cosmos DB resource throughput. -type Throughput struct { - autorest.Response `json:"-"` - // ThroughputProperties - The properties of an Azure Cosmos DB resource throughput - *ThroughputProperties `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"` - // 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 Throughput. -func (t Throughput) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if t.ThroughputProperties != nil { - objectMap["properties"] = t.ThroughputProperties - } - if t.Location != nil { - objectMap["location"] = t.Location - } - if t.Tags != nil { - objectMap["tags"] = t.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for Throughput struct. -func (t *Throughput) 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 throughputProperties ThroughputProperties - err = json.Unmarshal(*v, &throughputProperties) - if err != nil { - return err - } - t.ThroughputProperties = &throughputProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - t.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - t.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - t.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - t.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - t.Tags = tags - } - } - } - - return nil -} - -// ThroughputProperties the properties of an Azure Cosmos DB resource throughput -type ThroughputProperties struct { - // Throughput - Value of the Cosmos DB resource throughput - Throughput *int32 `json:"throughput,omitempty"` -} - -// ThroughputResource cosmos DB resource throughput object -type ThroughputResource struct { - // Throughput - Value of the Cosmos DB resource throughput - Throughput *int32 `json:"throughput,omitempty"` -} - -// ThroughputUpdateParameters parameters to update Cosmos DB resource throughput. -type ThroughputUpdateParameters struct { - // ThroughputUpdateProperties - Properties to update Azure Cosmos DB resource throughput. - *ThroughputUpdateProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for ThroughputUpdateParameters. -func (tup ThroughputUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if tup.ThroughputUpdateProperties != nil { - objectMap["properties"] = tup.ThroughputUpdateProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for ThroughputUpdateParameters struct. -func (tup *ThroughputUpdateParameters) 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 throughputUpdateProperties ThroughputUpdateProperties - err = json.Unmarshal(*v, &throughputUpdateProperties) - if err != nil { - return err - } - tup.ThroughputUpdateProperties = &throughputUpdateProperties - } - } - } - - return nil -} - -// ThroughputUpdateProperties properties to update Azure Cosmos DB resource throughput. -type ThroughputUpdateProperties struct { - // Resource - The standard JSON format of a resource throughput - Resource *ThroughputResource `json:"resource,omitempty"` -} - -// 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: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', 'BytesPerSecond', 'Milliseconds' - 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"` -} - -// 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"` -} - -// 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/2020-04-01/documentdb/cassandraresources.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/cassandraresources.go new file mode 100644 index 000000000000..9836e3b8665b --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/cassandraresources.go @@ -0,0 +1,1185 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// 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 azure Cosmos DB Database Service Resource Provider REST API +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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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}}}, + {Target: "createUpdateCassandraKeyspaceParameters.CassandraKeyspaceCreateUpdateProperties.Options", 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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}}}, + {Target: "createUpdateCassandraTableParameters.CassandraTableCreateUpdateProperties.Options", 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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 +} + +// 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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/2015-04-08/documentdb/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/client.go similarity index 98% rename from vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/client.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/client.go index 686008d9006b..0ad2ff76e31b 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/client.go @@ -1,4 +1,4 @@ -// Package documentdb implements the Azure ARM Documentdb service API version 2015-04-08. +// Package documentdb implements the Azure ARM Documentdb service API version . // // Azure Cosmos DB Database Service Resource Provider REST API package documentdb diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/collection.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/collection.go similarity index 94% rename from vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/collection.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/collection.go index 4f08d9a32e7e..5b944c07b11a 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/collection.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/collection.go @@ -44,7 +44,7 @@ func NewCollectionClientWithBaseURI(baseURI string, subscriptionID string) Colle // ListMetricDefinitions retrieves metric definitions for the given collection. // Parameters: -// resourceGroupName - name of an Azure resource group. +// 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. @@ -60,6 +60,8 @@ func (client CollectionClient) ListMetricDefinitions(ctx context.Context, resour }() } 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}, @@ -102,7 +104,7 @@ func (client CollectionClient) ListMetricDefinitionsPreparer(ctx context.Context "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2015-04-08" + const APIVersion = "2020-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -135,7 +137,7 @@ func (client CollectionClient) ListMetricDefinitionsResponder(resp *http.Respons // ListMetrics retrieves the metrics determined by the given filter for the given database account and collection. // Parameters: -// resourceGroupName - name of an Azure resource group. +// 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. @@ -154,6 +156,8 @@ func (client CollectionClient) ListMetrics(ctx context.Context, resourceGroupNam }() } 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}, @@ -196,7 +200,7 @@ func (client CollectionClient) ListMetricsPreparer(ctx context.Context, resource "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2015-04-08" + const APIVersion = "2020-04-01" queryParameters := map[string]interface{}{ "$filter": autorest.Encode("query", filter), "api-version": APIVersion, @@ -230,7 +234,7 @@ func (client CollectionClient) ListMetricsResponder(resp *http.Response) (result // ListUsages retrieves the usages (most recent storage data) for the given collection. // Parameters: -// resourceGroupName - name of an Azure resource group. +// 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. @@ -248,6 +252,8 @@ func (client CollectionClient) ListUsages(ctx context.Context, resourceGroupName }() } 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}, @@ -290,7 +296,7 @@ func (client CollectionClient) ListUsagesPreparer(ctx context.Context, resourceG "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2015-04-08" + const APIVersion = "2020-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/collectionpartition.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/collectionpartition.go similarity index 95% rename from vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/collectionpartition.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/collectionpartition.go index 2ddb441640ac..634640fecb6f 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/collectionpartition.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/collectionpartition.go @@ -45,7 +45,7 @@ func NewCollectionPartitionClientWithBaseURI(baseURI string, subscriptionID stri // ListMetrics retrieves the metrics determined by the given filter for the given collection, split by partition. // Parameters: -// resourceGroupName - name of an Azure resource group. +// 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. @@ -64,6 +64,8 @@ func (client CollectionPartitionClient) ListMetrics(ctx context.Context, resourc }() } 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}, @@ -106,7 +108,7 @@ func (client CollectionPartitionClient) ListMetricsPreparer(ctx context.Context, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2015-04-08" + const APIVersion = "2020-04-01" queryParameters := map[string]interface{}{ "$filter": autorest.Encode("query", filter), "api-version": APIVersion, @@ -140,7 +142,7 @@ func (client CollectionPartitionClient) ListMetricsResponder(resp *http.Response // ListUsages retrieves the usages (most recent storage data) for the given collection, split by partition. // Parameters: -// resourceGroupName - name of an Azure resource group. +// 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. @@ -158,6 +160,8 @@ func (client CollectionPartitionClient) ListUsages(ctx context.Context, resource }() } 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}, @@ -200,7 +204,7 @@ func (client CollectionPartitionClient) ListUsagesPreparer(ctx context.Context, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2015-04-08" + const APIVersion = "2020-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/collectionpartitionregion.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/collectionpartitionregion.go similarity index 95% rename from vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/collectionpartitionregion.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/collectionpartitionregion.go index 9af8bdc250d2..5aed6c4548f1 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/collectionpartitionregion.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/collectionpartitionregion.go @@ -46,7 +46,7 @@ func NewCollectionPartitionRegionClientWithBaseURI(baseURI string, subscriptionI // ListMetrics retrieves the metrics determined by the given filter for the given collection and region, split by // partition. // Parameters: -// resourceGroupName - name of an Azure resource group. +// 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. @@ -66,6 +66,8 @@ func (client CollectionPartitionRegionClient) ListMetrics(ctx context.Context, r }() } 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}, @@ -109,7 +111,7 @@ func (client CollectionPartitionRegionClient) ListMetricsPreparer(ctx context.Co "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2015-04-08" + const APIVersion = "2020-04-01" queryParameters := map[string]interface{}{ "$filter": autorest.Encode("query", filter), "api-version": APIVersion, diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/collectionregion.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/collectionregion.go similarity index 95% rename from vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/collectionregion.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/collectionregion.go index 23b9ce067fc2..1c18f7f3db33 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/collectionregion.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/collectionregion.go @@ -46,7 +46,7 @@ func NewCollectionRegionClientWithBaseURI(baseURI string, subscriptionID string) // ListMetrics retrieves the metrics determined by the given filter for the given database account, collection and // region. // Parameters: -// resourceGroupName - name of an Azure resource group. +// 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. @@ -66,6 +66,8 @@ func (client CollectionRegionClient) ListMetrics(ctx context.Context, resourceGr }() } 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}, @@ -109,7 +111,7 @@ func (client CollectionRegionClient) ListMetricsPreparer(ctx context.Context, re "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2015-04-08" + const APIVersion = "2020-04-01" queryParameters := map[string]interface{}{ "$filter": autorest.Encode("query", filter), "api-version": APIVersion, diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/database.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/database.go similarity index 94% rename from vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/database.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/database.go index 1c13d9726e8e..c3c5298a954c 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/database.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/database.go @@ -44,7 +44,7 @@ func NewDatabaseClientWithBaseURI(baseURI string, subscriptionID string) Databas // ListMetricDefinitions retrieves metric definitions for the given database. // Parameters: -// resourceGroupName - name of an Azure resource group. +// 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) { @@ -59,6 +59,8 @@ func (client DatabaseClient) ListMetricDefinitions(ctx context.Context, resource }() } 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}, @@ -100,7 +102,7 @@ func (client DatabaseClient) ListMetricDefinitionsPreparer(ctx context.Context, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2015-04-08" + const APIVersion = "2020-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -133,7 +135,7 @@ func (client DatabaseClient) ListMetricDefinitionsResponder(resp *http.Response) // ListMetrics retrieves the metrics determined by the given filter for the given database account and database. // Parameters: -// resourceGroupName - name of an Azure resource group. +// 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 @@ -151,6 +153,8 @@ func (client DatabaseClient) ListMetrics(ctx context.Context, resourceGroupName }() } 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}, @@ -192,7 +196,7 @@ func (client DatabaseClient) ListMetricsPreparer(ctx context.Context, resourceGr "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2015-04-08" + const APIVersion = "2020-04-01" queryParameters := map[string]interface{}{ "$filter": autorest.Encode("query", filter), "api-version": APIVersion, @@ -226,7 +230,7 @@ func (client DatabaseClient) ListMetricsResponder(resp *http.Response) (result M // ListUsages retrieves the usages (most recent data) for the given database. // Parameters: -// resourceGroupName - name of an Azure resource group. +// 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 @@ -243,6 +247,8 @@ func (client DatabaseClient) ListUsages(ctx context.Context, resourceGroupName s }() } 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}, @@ -284,7 +290,7 @@ func (client DatabaseClient) ListUsagesPreparer(ctx context.Context, resourceGro "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2015-04-08" + const APIVersion = "2020-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/databaseaccountregion.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/databaseaccountregion.go similarity index 95% rename from vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/databaseaccountregion.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/databaseaccountregion.go index e4f89751d70c..bef97536b424 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/databaseaccountregion.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/databaseaccountregion.go @@ -45,7 +45,7 @@ func NewDatabaseAccountRegionClientWithBaseURI(baseURI string, subscriptionID st // ListMetrics retrieves the metrics determined by the given filter for the given database account and region. // Parameters: -// resourceGroupName - name of an Azure resource group. +// 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 @@ -63,6 +63,8 @@ func (client DatabaseAccountRegionClient) ListMetrics(ctx context.Context, resou }() } 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}, @@ -104,7 +106,7 @@ func (client DatabaseAccountRegionClient) ListMetricsPreparer(ctx context.Contex "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2015-04-08" + const APIVersion = "2020-04-01" queryParameters := map[string]interface{}{ "$filter": autorest.Encode("query", filter), "api-version": APIVersion, diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/databaseaccounts.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/databaseaccounts.go new file mode 100644 index 000000000000..d1a3c3139db3 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/databaseaccounts.go @@ -0,0 +1,1664 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// 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 azure Cosmos DB Database Service Resource Provider REST API +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 +} + +// 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 = "2020-04-01" + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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}, + }}}}}); 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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/2020-04-01/documentdb/gremlinresources.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/gremlinresources.go new file mode 100644 index 000000000000..dd505dc2552f --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/gremlinresources.go @@ -0,0 +1,1191 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// 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 azure Cosmos DB Database Service Resource Provider REST API +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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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}}}, + {Target: "createUpdateGremlinDatabaseParameters.GremlinDatabaseCreateUpdateProperties.Options", 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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}, + }}, + }}, + }}, + {Target: "createUpdateGremlinGraphParameters.GremlinGraphCreateUpdateProperties.Options", Name: validation.Null, Rule: true, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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 +} + +// 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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/2020-04-01/documentdb/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/models.go new file mode 100644 index 000000000000..ff89530373ed --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/models.go @@ -0,0 +1,6377 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// 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/2020-04-01/documentdb" + +// CompositePathSortOrder enumerates the values for composite path sort order. +type CompositePathSortOrder string + +const ( + // Ascending ... + Ascending CompositePathSortOrder = "Ascending" + // Descending ... + Descending CompositePathSortOrder = "Descending" +) + +// PossibleCompositePathSortOrderValues returns an array of possible values for the CompositePathSortOrder const type. +func PossibleCompositePathSortOrderValues() []CompositePathSortOrder { + return []CompositePathSortOrder{Ascending, Descending} +} + +// ConflictResolutionMode enumerates the values for conflict resolution mode. +type ConflictResolutionMode string + +const ( + // Custom ... + Custom ConflictResolutionMode = "Custom" + // LastWriterWins ... + LastWriterWins ConflictResolutionMode = "LastWriterWins" +) + +// PossibleConflictResolutionModeValues returns an array of possible values for the ConflictResolutionMode const type. +func PossibleConflictResolutionModeValues() []ConflictResolutionMode { + return []ConflictResolutionMode{Custom, LastWriterWins} +} + +// ConnectorOffer enumerates the values for connector offer. +type ConnectorOffer string + +const ( + // Small ... + Small ConnectorOffer = "Small" +) + +// PossibleConnectorOfferValues returns an array of possible values for the ConnectorOffer const type. +func PossibleConnectorOfferValues() []ConnectorOffer { + return []ConnectorOffer{Small} +} + +// DatabaseAccountKind enumerates the values for database account kind. +type DatabaseAccountKind string + +const ( + // GlobalDocumentDB ... + GlobalDocumentDB DatabaseAccountKind = "GlobalDocumentDB" + // MongoDB ... + MongoDB DatabaseAccountKind = "MongoDB" + // Parse ... + Parse DatabaseAccountKind = "Parse" +) + +// PossibleDatabaseAccountKindValues returns an array of possible values for the DatabaseAccountKind const type. +func PossibleDatabaseAccountKindValues() []DatabaseAccountKind { + return []DatabaseAccountKind{GlobalDocumentDB, MongoDB, Parse} +} + +// DatabaseAccountOfferType enumerates the values for database account offer type. +type DatabaseAccountOfferType string + +const ( + // Standard ... + Standard DatabaseAccountOfferType = "Standard" +) + +// PossibleDatabaseAccountOfferTypeValues returns an array of possible values for the DatabaseAccountOfferType const type. +func PossibleDatabaseAccountOfferTypeValues() []DatabaseAccountOfferType { + return []DatabaseAccountOfferType{Standard} +} + +// DataType enumerates the values for data type. +type DataType string + +const ( + // LineString ... + LineString DataType = "LineString" + // MultiPolygon ... + MultiPolygon DataType = "MultiPolygon" + // Number ... + Number DataType = "Number" + // Point ... + Point DataType = "Point" + // Polygon ... + Polygon DataType = "Polygon" + // String ... + String DataType = "String" +) + +// PossibleDataTypeValues returns an array of possible values for the DataType const type. +func PossibleDataTypeValues() []DataType { + return []DataType{LineString, MultiPolygon, Number, Point, Polygon, String} +} + +// DefaultConsistencyLevel enumerates the values for default consistency level. +type DefaultConsistencyLevel string + +const ( + // BoundedStaleness ... + BoundedStaleness DefaultConsistencyLevel = "BoundedStaleness" + // ConsistentPrefix ... + ConsistentPrefix DefaultConsistencyLevel = "ConsistentPrefix" + // Eventual ... + Eventual DefaultConsistencyLevel = "Eventual" + // Session ... + Session DefaultConsistencyLevel = "Session" + // Strong ... + Strong DefaultConsistencyLevel = "Strong" +) + +// PossibleDefaultConsistencyLevelValues returns an array of possible values for the DefaultConsistencyLevel const type. +func PossibleDefaultConsistencyLevelValues() []DefaultConsistencyLevel { + return []DefaultConsistencyLevel{BoundedStaleness, ConsistentPrefix, Eventual, Session, Strong} +} + +// IndexingMode enumerates the values for indexing mode. +type IndexingMode string + +const ( + // Consistent ... + Consistent IndexingMode = "Consistent" + // Lazy ... + Lazy IndexingMode = "Lazy" + // None ... + None IndexingMode = "None" +) + +// PossibleIndexingModeValues returns an array of possible values for the IndexingMode const type. +func PossibleIndexingModeValues() []IndexingMode { + return []IndexingMode{Consistent, Lazy, None} +} + +// IndexKind enumerates the values for index kind. +type IndexKind string + +const ( + // Hash ... + Hash IndexKind = "Hash" + // Range ... + Range IndexKind = "Range" + // Spatial ... + Spatial IndexKind = "Spatial" +) + +// PossibleIndexKindValues returns an array of possible values for the IndexKind const type. +func PossibleIndexKindValues() []IndexKind { + return []IndexKind{Hash, Range, Spatial} +} + +// KeyKind enumerates the values for key kind. +type KeyKind string + +const ( + // Primary ... + Primary KeyKind = "primary" + // PrimaryReadonly ... + PrimaryReadonly KeyKind = "primaryReadonly" + // Secondary ... + Secondary KeyKind = "secondary" + // SecondaryReadonly ... + SecondaryReadonly KeyKind = "secondaryReadonly" +) + +// PossibleKeyKindValues returns an array of possible values for the KeyKind const type. +func PossibleKeyKindValues() []KeyKind { + return []KeyKind{Primary, PrimaryReadonly, Secondary, SecondaryReadonly} +} + +// PartitionKind enumerates the values for partition kind. +type PartitionKind string + +const ( + // PartitionKindHash ... + PartitionKindHash PartitionKind = "Hash" + // PartitionKindRange ... + PartitionKindRange PartitionKind = "Range" +) + +// PossiblePartitionKindValues returns an array of possible values for the PartitionKind const type. +func PossiblePartitionKindValues() []PartitionKind { + return []PartitionKind{PartitionKindHash, 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 ( + // Disabled ... + Disabled PublicNetworkAccess = "Disabled" + // Enabled ... + Enabled PublicNetworkAccess = "Enabled" +) + +// PossiblePublicNetworkAccessValues returns an array of possible values for the PublicNetworkAccess const type. +func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { + return []PublicNetworkAccess{Disabled, Enabled} +} + +// ServerVersion enumerates the values for server version. +type ServerVersion string + +const ( + // ThreeFullStopSix ... + ThreeFullStopSix ServerVersion = "3.6" + // ThreeFullStopTwo ... + ThreeFullStopTwo ServerVersion = "3.2" +) + +// PossibleServerVersionValues returns an array of possible values for the ServerVersion const type. +func PossibleServerVersionValues() []ServerVersion { + return []ServerVersion{ThreeFullStopSix, ThreeFullStopTwo} +} + +// 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 ( + // All ... + All TriggerOperation = "All" + // Create ... + Create TriggerOperation = "Create" + // Delete ... + Delete TriggerOperation = "Delete" + // Replace ... + Replace TriggerOperation = "Replace" + // Update ... + Update TriggerOperation = "Update" +) + +// PossibleTriggerOperationValues returns an array of possible values for the TriggerOperation const type. +func PossibleTriggerOperationValues() []TriggerOperation { + return []TriggerOperation{All, Create, Delete, Replace, Update} +} + +// TriggerType enumerates the values for trigger type. +type TriggerType string + +const ( + // Post ... + Post TriggerType = "Post" + // Pre ... + Pre TriggerType = "Pre" +) + +// PossibleTriggerTypeValues returns an array of possible values for the TriggerType const type. +func PossibleTriggerTypeValues() []TriggerType { + return []TriggerType{Post, Pre} +} + +// UnitType enumerates the values for unit type. +type UnitType string + +const ( + // Bytes ... + Bytes UnitType = "Bytes" + // BytesPerSecond ... + BytesPerSecond UnitType = "BytesPerSecond" + // Count ... + Count UnitType = "Count" + // CountPerSecond ... + CountPerSecond UnitType = "CountPerSecond" + // Milliseconds ... + Milliseconds UnitType = "Milliseconds" + // Percent ... + Percent UnitType = "Percent" + // Seconds ... + Seconds UnitType = "Seconds" +) + +// PossibleUnitTypeValues returns an array of possible values for the UnitType const type. +func PossibleUnitTypeValues() []UnitType { + return []UnitType{Bytes, BytesPerSecond, Count, CountPerSecond, Milliseconds, Percent, Seconds} +} + +// APIProperties ... +type APIProperties struct { + // ServerVersion - Describes the ServerVersion of an a MongoDB account. Possible values include: 'ThreeFullStopTwo', 'ThreeFullStopSix' + 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"` +} + +// 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"` +} + +// 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 a 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. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,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"` +} + +// 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 interface{} `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// 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"` +} + +// 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + err = azure.NewAsyncOpIncompleteError("documentdb.CassandraResourcesDeleteCassandraTableFuture") + return + } + ar.Response = future.Response() + return +} + +// CassandraResourcesUpdateCassandraKeyspaceThroughputFuture an abstraction for monitoring and retrieving +// the results of a long-running operation. +type CassandraResourcesUpdateCassandraKeyspaceThroughputFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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 interface{} `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// 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: 'Ascending', 'Descending' + 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: 'LastWriterWins', 'Custom' + 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"` +} + +// 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: 'Eventual', 'Session', 'BoundedStaleness', 'Strong', 'ConsistentPrefix' + 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. Possible values include: 'PartitionKindHash', 'PartitionKindRange' + Kind PartitionKind `json:"kind,omitempty"` + // Version - Indicates the version of the partition key definition + Version *int32 `json:"version,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"` +} + +// 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: 'GlobalDocumentDB', 'MongoDB', 'Parse' + Kind DatabaseAccountKind `json:"kind,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.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 "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: 'Small' + 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"` + // PublicNetworkAccess - Whether requests from Public Network are allowed. Possible values include: 'Enabled', 'Disabled' + 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"` +} + +// 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: 'Standard' + 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: 'Small' + 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"` + // PublicNetworkAccess - Whether requests from Public Network are allowed. Possible values include: 'Enabled', 'Disabled' + 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"` +} + +// 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: 'GlobalDocumentDB', 'MongoDB', 'Parse' + Kind DatabaseAccountKind `json:"kind,omitempty"` + *DatabaseAccountGetProperties `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 DatabaseAccountGetResults. +func (dagr DatabaseAccountGetResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dagr.Kind != "" { + objectMap["kind"] = dagr.Kind + } + 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 "properties": + if v != nil { + var databaseAccountGetProperties DatabaseAccountGetProperties + err = json.Unmarshal(*v, &databaseAccountGetProperties) + if err != nil { + return err + } + dagr.DatabaseAccountGetProperties = &databaseAccountGetProperties + } + 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"` +} + +// 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"` +} + +// DatabaseAccountRegenerateKeyParameters parameters to regenerate the keys within the database account. +type DatabaseAccountRegenerateKeyParameters struct { + // KeyKind - The access key to regenerate. Possible values include: 'Primary', 'Secondary', 'PrimaryReadonly', 'SecondaryReadonly' + KeyKind KeyKind `json:"keyKind,omitempty"` +} + +// DatabaseAccountsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DatabaseAccountsCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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"` +} + +// DatabaseAccountsOfflineRegionFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DatabaseAccountsOfflineRegionFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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"` + *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.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 "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: 'Small' + 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"` + // PublicNetworkAccess - Whether requests from Public Network are allowed. Possible values include: 'Enabled', 'Disabled' + 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"` +} + +// 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 interface{} `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// 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"` +} + +// 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 interface{} `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// 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"` +} + +// 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 interface{} `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// 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"` +} + +// 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + err = azure.NewAsyncOpIncompleteError("documentdb.GremlinResourcesDeleteGremlinGraphFuture") + return + } + ar.Response = future.Response() + return +} + +// GremlinResourcesUpdateGremlinDatabaseThroughputFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type GremlinResourcesUpdateGremlinDatabaseThroughputFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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: 'String', 'Number', 'Point', 'Polygon', 'LineString', 'MultiPolygon' + 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: 'Hash', 'Range', 'Spatial' + 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: 'Consistent', 'Lazy', 'None' + 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"` +} + +// 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"` +} + +// 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: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', 'BytesPerSecond', 'Milliseconds' + 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"` +} + +// 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"` +} + +// 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: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', 'BytesPerSecond', 'Milliseconds' + 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"` +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// 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 interface{} `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"` +} + +// 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 interface{} `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// 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"` +} + +// 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + err = azure.NewAsyncOpIncompleteError("documentdb.MongoDBResourcesDeleteMongoDBDatabaseFuture") + return + } + ar.Response = future.Response() + return +} + +// MongoDBResourcesUpdateMongoDBCollectionThroughputFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type MongoDBResourcesUpdateMongoDBCollectionThroughputFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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"` +} + +// 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"` +} + +// 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"` +} + +// NotebookWorkspacesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type NotebookWorkspacesCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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 +} + +// 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.NextLink == nil || len(to.String(olr.NextLink)) < 1 { + 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) + }() + } + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + 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(getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{fn: getNextPage} +} + +// 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: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', 'BytesPerSecond', 'Milliseconds' + 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"` +} + +// 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"` +} + +// 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: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', 'BytesPerSecond', 'Milliseconds' + 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"` +} + +// 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"` +} + +// 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: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', 'BytesPerSecond', 'Milliseconds' + 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"` +} + +// 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"` +} + +// 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"` +} + +// 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. Ex- 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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"` +} + +// PrivateLinkServiceConnectionStateProperty connection State of the Private Endpoint Connection. +type PrivateLinkServiceConnectionStateProperty struct { + // Status - The private link service connection status. + Status *string `json:"status,omitempty"` + // ActionsRequired - READ-ONLY; Any action that is required beyond basic workflow (approve/ reject/ disconnect) + ActionsRequired *string `json:"actionsRequired,omitempty"` + // Description - The private link service connection description. + Description *string `json:"description,omitempty"` +} + +// ProxyResource the resource model definition for a ARM proxy resource. It will have everything other than +// required location and tags +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. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// 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 ... +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. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,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"` + // 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 interface{} `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// 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"` +} + +// 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"` +} + +// 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 interface{} `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"` +} + +// 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"` +} + +// 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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 +} + +// SQLResourcesCreateUpdateSQLStoredProcedureFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type SQLResourcesCreateUpdateSQLStoredProcedureFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesDeleteSQLDatabaseFuture") + return + } + ar.Response = future.Response() + return +} + +// SQLResourcesDeleteSQLStoredProcedureFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SQLResourcesDeleteSQLStoredProcedureFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + err = azure.NewAsyncOpIncompleteError("documentdb.SQLResourcesDeleteSQLUserDefinedFunctionFuture") + return + } + ar.Response = future.Response() + return +} + +// SQLResourcesUpdateSQLContainerThroughputFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type SQLResourcesUpdateSQLContainerThroughputFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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 +} + +// 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 interface{} `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// 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"` +} + +// 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: 'Pre', 'Post' + TriggerType TriggerType `json:"triggerType,omitempty"` + // TriggerOperation - The operation the trigger is associated with. Possible values include: 'All', 'Create', 'Update', 'Delete', 'Replace' + 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 interface{} `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// 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"` +} + +// 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: 'Pre', 'Post' + TriggerType TriggerType `json:"triggerType,omitempty"` + // TriggerOperation - The operation the trigger is associated with. Possible values include: 'All', 'Create', 'Update', 'Delete', 'Replace' + 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 interface{} `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// 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"` +} + +// 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"` +} + +// 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 interface{} `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// 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"` +} + +// 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + err = azure.NewAsyncOpIncompleteError("documentdb.TableResourcesDeleteTableFuture") + return + } + ar.Response = future.Response() + return +} + +// TableResourcesUpdateTableThroughputFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type TableResourcesUpdateTableThroughputFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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 interface{} `json:"_ts,omitempty"` + // Etag - READ-ONLY; A system generated property representing the resource etag required for optimistic concurrency control. + Etag *string `json:"_etag,omitempty"` +} + +// 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"` +} + +// 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 a ARM tracked top level resource +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. Ex- 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: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', 'BytesPerSecond', 'Milliseconds' + 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"` +} + +// 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"` +} + +// 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/2020-04-01/documentdb/mongodbresources.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/mongodbresources.go new file mode 100644 index 000000000000..8bf3c7b0a10a --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/mongodbresources.go @@ -0,0 +1,1185 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// 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 azure Cosmos DB Database Service Resource Provider REST API +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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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}}}, + {Target: "createUpdateMongoDBCollectionParameters.MongoDBCollectionCreateUpdateProperties.Options", 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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}}}, + {Target: "createUpdateMongoDBDatabaseParameters.MongoDBDatabaseCreateUpdateProperties.Options", 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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 +} + +// 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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/2020-04-01/documentdb/notebookworkspaces.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/notebookworkspaces.go new file mode 100644 index 000000000000..aa74bf3f4fe0 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/notebookworkspaces.go @@ -0,0 +1,673 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// 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 azure Cosmos DB Database Service Resource Provider REST API +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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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/2015-04-08/documentdb/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/operations.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/operations.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/operations.go index 4efa66498fab..fb206b1d9bf3 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/operations.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/operations.go @@ -77,7 +77,7 @@ func (client OperationsClient) List(ctx context.Context) (result OperationListRe // ListPreparer prepares the List request. func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2015-04-08" + const APIVersion = "2020-04-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/partitionkeyrangeid.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/partitionkeyrangeid.go similarity index 95% rename from vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/partitionkeyrangeid.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/partitionkeyrangeid.go index 9ec50bc1e9cd..b7c14ce7e3e4 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/partitionkeyrangeid.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/partitionkeyrangeid.go @@ -45,7 +45,7 @@ func NewPartitionKeyRangeIDClientWithBaseURI(baseURI string, subscriptionID stri // ListMetrics retrieves the metrics determined by the given filter for the given partition key range id. // Parameters: -// resourceGroupName - name of an Azure resource group. +// 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. @@ -65,6 +65,8 @@ func (client PartitionKeyRangeIDClient) ListMetrics(ctx context.Context, resourc }() } 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}, @@ -108,7 +110,7 @@ func (client PartitionKeyRangeIDClient) ListMetricsPreparer(ctx context.Context, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2015-04-08" + const APIVersion = "2020-04-01" queryParameters := map[string]interface{}{ "$filter": autorest.Encode("query", filter), "api-version": APIVersion, diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/partitionkeyrangeidregion.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/partitionkeyrangeidregion.go similarity index 96% rename from vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/partitionkeyrangeidregion.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/partitionkeyrangeidregion.go index c8513d6fc029..92ed8964824d 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/partitionkeyrangeidregion.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/partitionkeyrangeidregion.go @@ -45,7 +45,7 @@ func NewPartitionKeyRangeIDRegionClientWithBaseURI(baseURI string, subscriptionI // ListMetrics retrieves the metrics determined by the given filter for the given partition key range id and region. // Parameters: -// resourceGroupName - name of an Azure resource group. +// 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. @@ -66,6 +66,8 @@ func (client PartitionKeyRangeIDRegionClient) ListMetrics(ctx context.Context, r }() } 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}, @@ -110,7 +112,7 @@ func (client PartitionKeyRangeIDRegionClient) ListMetricsPreparer(ctx context.Co "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2015-04-08" + const APIVersion = "2020-04-01" queryParameters := map[string]interface{}{ "$filter": autorest.Encode("query", filter), "api-version": APIVersion, diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/percentile.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/percentile.go similarity index 95% rename from vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/percentile.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/percentile.go index bcb69da25baa..2c2979083b85 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/percentile.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/percentile.go @@ -45,7 +45,7 @@ func NewPercentileClientWithBaseURI(baseURI string, subscriptionID string) Perce // 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 - name of an Azure resource group. +// 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 @@ -62,6 +62,8 @@ func (client PercentileClient) ListMetrics(ctx context.Context, resourceGroupNam }() } 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}, @@ -102,7 +104,7 @@ func (client PercentileClient) ListMetricsPreparer(ctx context.Context, resource "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2015-04-08" + const APIVersion = "2020-04-01" queryParameters := map[string]interface{}{ "$filter": autorest.Encode("query", filter), "api-version": APIVersion, diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/percentilesourcetarget.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/percentilesourcetarget.go similarity index 95% rename from vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/percentilesourcetarget.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/percentilesourcetarget.go index 00a9038df32e..e9fc420b2f74 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/percentilesourcetarget.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/percentilesourcetarget.go @@ -46,7 +46,7 @@ func NewPercentileSourceTargetClientWithBaseURI(baseURI string, subscriptionID s // 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 - name of an Azure resource group. +// 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. @@ -67,6 +67,8 @@ func (client PercentileSourceTargetClient) ListMetrics(ctx context.Context, reso }() } 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}, @@ -109,7 +111,7 @@ func (client PercentileSourceTargetClient) ListMetricsPreparer(ctx context.Conte "targetRegion": autorest.Encode("path", targetRegion), } - const APIVersion = "2015-04-08" + const APIVersion = "2020-04-01" queryParameters := map[string]interface{}{ "$filter": autorest.Encode("query", filter), "api-version": APIVersion, diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/percentiletarget.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/percentiletarget.go similarity index 95% rename from vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/percentiletarget.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/percentiletarget.go index 066d3b5c061a..c27f403d1a20 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/percentiletarget.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/percentiletarget.go @@ -46,7 +46,7 @@ func NewPercentileTargetClientWithBaseURI(baseURI string, subscriptionID string) // 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 - name of an Azure resource group. +// 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. @@ -65,6 +65,8 @@ func (client PercentileTargetClient) ListMetrics(ctx context.Context, resourceGr }() } 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}, @@ -106,7 +108,7 @@ func (client PercentileTargetClient) ListMetricsPreparer(ctx context.Context, re "targetRegion": autorest.Encode("path", targetRegion), } - const APIVersion = "2015-04-08" + const APIVersion = "2020-04-01" queryParameters := map[string]interface{}{ "$filter": autorest.Encode("query", filter), "api-version": APIVersion, diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/privateendpointconnections.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/privateendpointconnections.go new file mode 100644 index 000000000000..e4646d97e623 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/privateendpointconnections.go @@ -0,0 +1,407 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// 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 azure Cosmos DB Database Service Resource Provider REST API +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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2019-08-01-preview" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2019-08-01-preview" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2019-08-01-preview" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2019-08-01-preview" + 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/2020-04-01/documentdb/privatelinkresources.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/privatelinkresources.go new file mode 100644 index 000000000000..1d64a0c10774 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/privatelinkresources.go @@ -0,0 +1,224 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// 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 azure Cosmos DB Database Service Resource Provider REST API +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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2019-08-01-preview" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2019-08-01-preview" + 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/2020-04-01/documentdb/sqlresources.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/sqlresources.go new file mode 100644 index 000000000000..8713305ebd2f --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/sqlresources.go @@ -0,0 +1,2347 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// 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 azure Cosmos DB Database Service Resource Provider REST API +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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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}, + }}, + }}, + }}, + {Target: "createUpdateSQLContainerParameters.SQLContainerCreateUpdateProperties.Options", Name: validation.Null, Rule: true, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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}}}, + {Target: "createUpdateSQLDatabaseParameters.SQLDatabaseCreateUpdateProperties.Options", 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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 +} + +// 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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}}}, + {Target: "createUpdateSQLStoredProcedureParameters.SQLStoredProcedureCreateUpdateProperties.Options", 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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}}}, + {Target: "createUpdateSQLTriggerParameters.SQLTriggerCreateUpdateProperties.Options", 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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}}}, + {Target: "createUpdateSQLUserDefinedFunctionParameters.SQLUserDefinedFunctionCreateUpdateProperties.Options", 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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 +} + +// 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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 +} + +// 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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 +} + +// 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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 +} + +// 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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/2020-04-01/documentdb/tableresources.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/tableresources.go new file mode 100644 index 000000000000..a2003d7498d0 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/tableresources.go @@ -0,0 +1,606 @@ +package documentdb + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// 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 azure Cosmos DB Database Service Resource Provider REST API +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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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}}}, + {Target: "createUpdateTableParameters.TableCreateUpdateProperties.Options", 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 +} + +// 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 = "2020-04-01" + 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 +} + +// 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.Response() != nil { + sc = result.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}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, 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 = "2020-04-01" + 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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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/2015-04-08/documentdb/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/version.go similarity index 94% rename from vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/version.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/version.go index fe4c03bff99f..9f771700d25b 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb/version.go @@ -21,7 +21,7 @@ import "github.com/Azure/azure-sdk-for-go/version" // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/" + Version() + " documentdb/2015-04-08" + return "Azure-SDK-For-Go/" + Version() + " documentdb/2020-04-01" } // Version returns the semantic version (see http://semver.org) of the client. diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/accounts/get_service_properties.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/accounts/get_service_properties.go index e622fff3ba46..0ce98e04bceb 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/accounts/get_service_properties.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/accounts/get_service_properties.go @@ -2,12 +2,11 @@ package accounts import ( "context" - "net/http" - "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/validation" "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" + "net/http" ) type GetServicePropertiesResult struct { diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/accounts/set_service_properties.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/accounts/set_service_properties.go index 17b7bcc7e763..a11178c6b7ca 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/accounts/set_service_properties.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/accounts/set_service_properties.go @@ -2,12 +2,11 @@ package accounts import ( "context" - "net/http" - "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/validation" "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" + "net/http" ) // SetServicePropertiesSender sends the SetServiceProperties request. The method will close the diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/blobs/api.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/blobs/api.go deleted file mode 100644 index 7e4f6494c2d1..000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/blobs/api.go +++ /dev/null @@ -1,45 +0,0 @@ -package blobs - -import ( - "context" - "os" - "time" - - "github.com/Azure/go-autorest/autorest" -) - -type StorageBlob interface { - AppendBlock(ctx context.Context, accountName, containerName, blobName string, input AppendBlockInput) (result AppendBlockResult, err error) - Copy(ctx context.Context, accountName, containerName, blobName string, input CopyInput) (result CopyResult, err error) - AbortCopy(ctx context.Context, accountName, containerName, blobName string, input AbortCopyInput) (result autorest.Response, err error) - CopyAndWait(ctx context.Context, accountName, containerName, blobName string, input CopyInput, pollingInterval time.Duration) error - Delete(ctx context.Context, accountName, containerName, blobName string, input DeleteInput) (result autorest.Response, err error) - DeleteSnapshot(ctx context.Context, accountName, containerName, blobName string, input DeleteSnapshotInput) (result autorest.Response, err error) - DeleteSnapshots(ctx context.Context, accountName, containerName, blobName string, input DeleteSnapshotsInput) (result autorest.Response, err error) - Get(ctx context.Context, accountName, containerName, blobName string, input GetInput) (result GetResult, err error) - GetBlockList(ctx context.Context, accountName, containerName, blobName string, input GetBlockListInput) (result GetBlockListResult, err error) - GetPageRanges(ctx context.Context, accountName, containerName, blobName string, input GetPageRangesInput) (result GetPageRangesResult, err error) - IncrementalCopyBlob(ctx context.Context, accountName, containerName, blobName string, input IncrementalCopyBlobInput) (result autorest.Response, err error) - AcquireLease(ctx context.Context, accountName, containerName, blobName string, input AcquireLeaseInput) (result AcquireLeaseResult, err error) - BreakLease(ctx context.Context, accountName, containerName, blobName string, input BreakLeaseInput) (result autorest.Response, err error) - ChangeLease(ctx context.Context, accountName, containerName, blobName string, input ChangeLeaseInput) (result ChangeLeaseResponse, err error) - ReleaseLease(ctx context.Context, accountName, containerName, blobName, leaseID string) (result autorest.Response, err error) - RenewLease(ctx context.Context, accountName, containerName, blobName, leaseID string) (result autorest.Response, err error) - SetMetaData(ctx context.Context, accountName, containerName, blobName string, input SetMetaDataInput) (result autorest.Response, err error) - GetProperties(ctx context.Context, accountName, containerName, blobName string, input GetPropertiesInput) (result GetPropertiesResult, err error) - SetProperties(ctx context.Context, accountName, containerName, blobName string, input SetPropertiesInput) (result SetPropertiesResult, err error) - PutAppendBlob(ctx context.Context, accountName, containerName, blobName string, input PutAppendBlobInput) (result autorest.Response, err error) - PutBlock(ctx context.Context, accountName, containerName, blobName string, input PutBlockInput) (result PutBlockResult, err error) - PutBlockBlob(ctx context.Context, accountName, containerName, blobName string, input PutBlockBlobInput) (result autorest.Response, err error) - PutBlockBlobFromFile(ctx context.Context, accountName, containerName, blobName string, file *os.File, input PutBlockBlobInput) error - PutBlockList(ctx context.Context, accountName, containerName, blobName string, input PutBlockListInput) (result PutBlockListResult, err error) - PutBlockFromURL(ctx context.Context, accountName, containerName, blobName string, input PutBlockFromURLInput) (result PutBlockFromURLResult, err error) - PutPageBlob(ctx context.Context, accountName, containerName, blobName string, input PutPageBlobInput) (result autorest.Response, err error) - PutPageClear(ctx context.Context, accountName, containerName, blobName string, input PutPageClearInput) (result autorest.Response, err error) - PutPageUpdate(ctx context.Context, accountName, containerName, blobName string, input PutPageUpdateInput) (result PutPageUpdateResult, err error) - GetResourceID(accountName, containerName, blobName string) string - SetTier(ctx context.Context, accountName, containerName, blobName string, tier AccessTier) (result autorest.Response, err error) - Snapshot(ctx context.Context, accountName, containerName, blobName string, input SnapshotInput) (result SnapshotResult, err error) - GetSnapshotProperties(ctx context.Context, accountName, containerName, blobName string, input GetSnapshotPropertiesInput) (result GetPropertiesResult, err error) - Undelete(ctx context.Context, accountName, containerName, blobName string) (result autorest.Response, err error) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/blobs/lease_acquire.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/blobs/lease_acquire.go index c4b49d73ae71..432c1f5fcda9 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/blobs/lease_acquire.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/blobs/lease_acquire.go @@ -98,7 +98,7 @@ func (client Client) AcquireLeasePreparer(ctx context.Context, accountName, cont } if input.ProposedLeaseID != nil { - headers["x-ms-proposed-lease-id"] = *input.ProposedLeaseID + headers["x-ms-proposed-lease-id"] = input.ProposedLeaseID } preparer := autorest.CreatePreparer( diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/containers/api.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/containers/api.go deleted file mode 100644 index 622f2b00eed7..000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/containers/api.go +++ /dev/null @@ -1,25 +0,0 @@ -package containers - -import ( - "context" - - "github.com/Azure/go-autorest/autorest" -) - -type StorageContainer interface { - Create(ctx context.Context, accountName, containerName string, input CreateInput) (result CreateResponse, err error) - Delete(ctx context.Context, accountName, containerName string) (result autorest.Response, err error) - GetProperties(ctx context.Context, accountName, containerName string) (ContainerProperties, error) - GetPropertiesWithLeaseID(ctx context.Context, accountName, containerName, leaseID string) (result ContainerProperties, err error) - AcquireLease(ctx context.Context, accountName, containerName string, input AcquireLeaseInput) (result AcquireLeaseResponse, err error) - BreakLease(ctx context.Context, accountName, containerName string, input BreakLeaseInput) (result BreakLeaseResponse, err error) - ChangeLease(ctx context.Context, accountName, containerName string, input ChangeLeaseInput) (result ChangeLeaseResponse, err error) - ReleaseLease(ctx context.Context, accountName, containerName, leaseID string) (result autorest.Response, err error) - RenewLease(ctx context.Context, accountName, containerName, leaseID string) (result autorest.Response, err error) - ListBlobs(ctx context.Context, accountName, containerName string, input ListBlobsInput) (result ListBlobsResult, err error) - GetResourceManagerResourceID(subscriptionID, resourceGroup, accountName, containerName string) string - SetAccessControl(ctx context.Context, accountName, containerName string, level AccessLevel) (autorest.Response, error) - SetAccessControlWithLeaseID(ctx context.Context, accountName, containerName, leaseID string, level AccessLevel) (result autorest.Response, err error) - SetMetaData(ctx context.Context, accountName, containerName string, metaData map[string]string) (autorest.Response, error) - SetMetaDataWithLeaseID(ctx context.Context, accountName, containerName, leaseID string, metaData map[string]string) (result autorest.Response, err error) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/containers/lease_renew.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/containers/lease_renew.go index cab50bff9d21..3fe17656cd87 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/containers/lease_renew.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/containers/lease_renew.go @@ -10,7 +10,7 @@ import ( "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" ) -// RenewLease renews the lock based on the Lease ID +// RenewLease renewes the lock based on the Lease ID func (client Client) RenewLease(ctx context.Context, accountName, containerName, leaseID string) (result autorest.Response, err error) { if accountName == "" { return result, validation.NewError("containers.Client", "RenewLease", "`accountName` cannot be an empty string.") diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/file/directories/api.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/file/directories/api.go deleted file mode 100644 index f567ede0500b..000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/file/directories/api.go +++ /dev/null @@ -1,16 +0,0 @@ -package directories - -import ( - "context" - - "github.com/Azure/go-autorest/autorest" -) - -type StorageDirectory interface { - Delete(ctx context.Context, accountName, shareName, path string) (result autorest.Response, err error) - GetMetaData(ctx context.Context, accountName, shareName, path string) (result GetMetaDataResult, err error) - SetMetaData(ctx context.Context, accountName, shareName, path string, metaData map[string]string) (result autorest.Response, err error) - Create(ctx context.Context, accountName, shareName, path string, metaData map[string]string) (result autorest.Response, err error) - GetResourceID(accountName, shareName, directoryName string) string - Get(ctx context.Context, accountName, shareName, path string) (result GetResult, err error) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/file/shares/api.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/file/shares/api.go deleted file mode 100644 index 62389b4c0a98..000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/file/shares/api.go +++ /dev/null @@ -1,24 +0,0 @@ -package shares - -import ( - "context" - - "github.com/Azure/go-autorest/autorest" -) - -type StorageShare interface { - SetACL(ctx context.Context, accountName, shareName string, acls []SignedIdentifier) (result autorest.Response, err error) - GetSnapshot(ctx context.Context, accountName, shareName, snapshotShare string) (result GetSnapshotPropertiesResult, err error) - GetStats(ctx context.Context, accountName, shareName string) (result GetStatsResult, err error) - GetACL(ctx context.Context, accountName, shareName string) (result GetACLResult, err error) - SetMetaData(ctx context.Context, accountName, shareName string, metaData map[string]string) (result autorest.Response, err error) - GetMetaData(ctx context.Context, accountName, shareName string) (result GetMetaDataResult, err error) - SetProperties(ctx context.Context, accountName, shareName string, newQuotaGB int) (result autorest.Response, err error) - DeleteSnapshot(ctx context.Context, accountName, shareName string, shareSnapshot string) (result autorest.Response, err error) - CreateSnapshot(ctx context.Context, accountName, shareName string, input CreateSnapshotInput) (result CreateSnapshotResult, err error) - GetResourceID(accountName, shareName string) string - GetResourceManagerResourceID(subscriptionID, resourceGroup, accountName, shareName string) string - GetProperties(ctx context.Context, accountName, shareName string) (result GetPropertiesResult, err error) - Delete(ctx context.Context, accountName, shareName string, deleteSnapshots bool) (result autorest.Response, err error) - Create(ctx context.Context, accountName, shareName string, input CreateInput) (result autorest.Response, err error) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/queue/queues/api.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/queue/queues/api.go deleted file mode 100644 index e4c14220b68c..000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/queue/queues/api.go +++ /dev/null @@ -1,17 +0,0 @@ -package queues - -import ( - "context" - - "github.com/Azure/go-autorest/autorest" -) - -type StorageQueue interface { - Delete(ctx context.Context, accountName, queueName string) (result autorest.Response, err error) - GetMetaData(ctx context.Context, accountName, queueName string) (result GetMetaDataResult, err error) - SetMetaData(ctx context.Context, accountName, queueName string, metaData map[string]string) (result autorest.Response, err error) - Create(ctx context.Context, accountName, queueName string, metaData map[string]string) (result autorest.Response, err error) - GetResourceID(accountName, queueName string) string - SetServiceProperties(ctx context.Context, accountName string, properties StorageServiceProperties) (result autorest.Response, err error) - GetServiceProperties(ctx context.Context, accountName string) (result StorageServicePropertiesResponse, err error) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/table/entities/api.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/table/entities/api.go deleted file mode 100644 index d4d20a723457..000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/table/entities/api.go +++ /dev/null @@ -1,17 +0,0 @@ -package entities - -import ( - "context" - - "github.com/Azure/go-autorest/autorest" -) - -type StorageTableEntity interface { - Delete(ctx context.Context, accountName, tableName string, input DeleteEntityInput) (result autorest.Response, err error) - Insert(ctx context.Context, accountName, tableName string, input InsertEntityInput) (result autorest.Response, err error) - InsertOrReplace(ctx context.Context, accountName, tableName string, input InsertOrReplaceEntityInput) (result autorest.Response, err error) - InsertOrMerge(ctx context.Context, accountName, tableName string, input InsertOrMergeEntityInput) (result autorest.Response, err error) - Query(ctx context.Context, accountName, tableName string, input QueryEntitiesInput) (result QueryEntitiesResult, err error) - Get(ctx context.Context, accountName, tableName string, input GetEntityInput) (result GetEntityResult, err error) - GetResourceID(accountName, tableName, partitionKey, rowKey string) string -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/table/tables/api.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/table/tables/api.go deleted file mode 100644 index d869819ff21e..000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2018-11-09/table/tables/api.go +++ /dev/null @@ -1,17 +0,0 @@ -package tables - -import ( - "context" - - "github.com/Azure/go-autorest/autorest" -) - -type StorageTable interface { - Delete(ctx context.Context, accountName, tableName string) (result autorest.Response, err error) - Exists(ctx context.Context, accountName, tableName string) (result autorest.Response, err error) - GetACL(ctx context.Context, accountName, tableName string) (result GetACLResult, err error) - Create(ctx context.Context, accountName, tableName string) (result autorest.Response, err error) - GetResourceID(accountName, tableName string) string - Query(ctx context.Context, accountName string, metaDataLevel MetaDataLevel) (result GetResult, err error) - SetACL(ctx context.Context, accountName, tableName string, acls []SignedIdentifier) (result autorest.Response, err error) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/version/version.go b/vendor/github.com/tombuildsstuff/giovanni/version/version.go index 87e310c334fd..629cab9c09b3 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/version/version.go +++ b/vendor/github.com/tombuildsstuff/giovanni/version/version.go @@ -1,3 +1,3 @@ package version -const Number = "v0.11.0" +const Number = "v0.10.0" diff --git a/vendor/modules.txt b/vendor/modules.txt index 5b3bc1530141..16be63af2e0a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -21,7 +21,7 @@ github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-10-01/containerinstance github.com/Azure/azure-sdk-for-go/services/containerregistry/mgmt/2018-09-01/containerregistry github.com/Azure/azure-sdk-for-go/services/containerservice/mgmt/2020-03-01/containerservice -github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb +github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2020-04-01/documentdb github.com/Azure/azure-sdk-for-go/services/costmanagement/mgmt/2019-10-01/costmanagement github.com/Azure/azure-sdk-for-go/services/databricks/mgmt/2018-04-01/databricks github.com/Azure/azure-sdk-for-go/services/datafactory/mgmt/2018-06-01/datafactory @@ -358,7 +358,7 @@ github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/slices github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/tf github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/validate github.com/terraform-providers/terraform-provider-azuread/version -# github.com/tombuildsstuff/giovanni v0.11.0 +# github.com/tombuildsstuff/giovanni v0.10.0 github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/accounts github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/blobs github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/containers diff --git a/website/docs/r/cosmosdb_cassandra_keyspace.html.markdown b/website/docs/r/cosmosdb_cassandra_keyspace.html.markdown index 5e999b9939cf..792011323b0c 100644 --- a/website/docs/r/cosmosdb_cassandra_keyspace.html.markdown +++ b/website/docs/r/cosmosdb_cassandra_keyspace.html.markdown @@ -78,5 +78,5 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/d 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/apis/cassandra/keyspaces/ks1 +terraform import azurerm_cosmosdb_cassandra_keyspace.ks1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/account1/cassandraKeyspaces/ks1 ``` diff --git a/website/docs/r/cosmosdb_gremlin_database.html.markdown b/website/docs/r/cosmosdb_gremlin_database.html.markdown index 02e7e2b094df..5b40417e1024 100644 --- a/website/docs/r/cosmosdb_gremlin_database.html.markdown +++ b/website/docs/r/cosmosdb_gremlin_database.html.markdown @@ -59,5 +59,5 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/d CosmosDB Gremlin Databases can be imported using the `resource id`, e.g. ```shell -terraform import azurerm_cosmosdb_gremlin_database.db1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/account1/apis/gremlin/databases/db1 +terraform import azurerm_cosmosdb_gremlin_database.db1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/account1/gremlinDatabases/db1 ``` diff --git a/website/docs/r/cosmosdb_gremlin_graph.html.markdown b/website/docs/r/cosmosdb_gremlin_graph.html.markdown index 4f6e8e9a1e1b..b0e461ea55e1 100644 --- a/website/docs/r/cosmosdb_gremlin_graph.html.markdown +++ b/website/docs/r/cosmosdb_gremlin_graph.html.markdown @@ -116,5 +116,5 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/d Cosmos Gremlin Graphs can be imported using the `resource id`, e.g. ```shell -terraform import azurerm_cosmosdb_gremlin_graph.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/account1/apis/gremlin/databases/db1/graphs/graphs1 +terraform import azurerm_cosmosdb_gremlin_graph.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/account1/gremlinDatabases/db1/graphs/graphs1 ``` diff --git a/website/docs/r/cosmosdb_mongo_collection.html.markdown b/website/docs/r/cosmosdb_mongo_collection.html.markdown index e71cdf464fbe..28909fe2dfb4 100644 --- a/website/docs/r/cosmosdb_mongo_collection.html.markdown +++ b/website/docs/r/cosmosdb_mongo_collection.html.markdown @@ -86,5 +86,5 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/d 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/apis/mongodb/databases/db1/collections/collection1 +terraform import azurerm_cosmosdb_mongo_collection.collection1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/account1/mongodbDatabases/db1/collections/collection1 ``` diff --git a/website/docs/r/cosmosdb_mongo_database.html.markdown b/website/docs/r/cosmosdb_mongo_database.html.markdown index 0a68df7eac07..ff228a4c009f 100644 --- a/website/docs/r/cosmosdb_mongo_database.html.markdown +++ b/website/docs/r/cosmosdb_mongo_database.html.markdown @@ -59,5 +59,5 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/d 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/apis/mongodb/databases/db1 +terraform import azurerm_cosmosdb_mongo_database.db1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/account1/mongodbDatabases/db1 ``` diff --git a/website/docs/r/cosmosdb_sql_container.html.markdown b/website/docs/r/cosmosdb_sql_container.html.markdown index 601cc20bc74c..97a429e3108e 100644 --- a/website/docs/r/cosmosdb_sql_container.html.markdown +++ b/website/docs/r/cosmosdb_sql_container.html.markdown @@ -73,5 +73,5 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/d Cosmos SQL Containers can be imported using the `resource id`, e.g. ```shell -terraform import azurerm_cosmosdb_sql_container.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.DocumentDB/databaseAccounts/account1/apis/sql/databases/database1/containers/container1 +terraform import azurerm_cosmosdb_sql_container.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/database1/containers/container1 ``` diff --git a/website/docs/r/cosmosdb_sql_database.html.markdown b/website/docs/r/cosmosdb_sql_database.html.markdown index df667c07657a..a07ef600df33 100644 --- a/website/docs/r/cosmosdb_sql_database.html.markdown +++ b/website/docs/r/cosmosdb_sql_database.html.markdown @@ -59,5 +59,5 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/d 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/apis/sql/databases/db1 +terraform import azurerm_cosmosdb_sql_database.db1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/db1 ``` diff --git a/website/docs/r/cosmosdb_table.html.markdown b/website/docs/r/cosmosdb_table.html.markdown index 730aecfb7b12..f3d510a7b72d 100644 --- a/website/docs/r/cosmosdb_table.html.markdown +++ b/website/docs/r/cosmosdb_table.html.markdown @@ -59,5 +59,5 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/d 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/apis/table/tables/table1 +terraform import azurerm_cosmosdb_table.table1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/account1/tables/table1 ```